73
73
// per component. Regardless of what the source image format is
74
74
// (CMYK, Grayscale, and so on) it will be converted over to the format
75
75
// specified here by CGBitmapContextCreate.
76
CGColorSpaceRef colorspace = CGImageGetColorSpace(image);
76
//CGColorSpaceRef colorspace = CGImageGetColorSpace(image);
77
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
77
78
CGContextRef context = CGBitmapContextCreate(bitmapData,dstWidth,dstHeight,8,bitmapBytesPerRow,
78
79
colorspace,kCGImageAlphaPremultipliedFirst);
79
80
CGColorSpaceRelease(colorspace);
308
314
if (!(self = [super initWithCoder: coder]))
311
instructionsView = [[UITextView alloc] initWithFrame: CGRectInset([self bounds], 0.0f, 0.0f)];
317
instructionsView = [[[UITextView alloc] initWithFrame: CGRectInset([self bounds], 0.0f, 0.0f)] autorelease];
312
318
[instructionsView setText: NSLocalizedString(@"ImageWell instruction text", @"\n\n\nTap and hold to paste image,\n\nor\n\nDouble-tap to select image from gallery.")];
313
319
//[instructionsView setBackgroundColor: [UIColor yellowColor]];
314
320
[instructionsView setTextColor: [UIColor whiteColor]];
315
321
[instructionsView setBackgroundColor: [UIColor clearColor]];
316
[instructionsView setFont: [UIFont systemFontOfSize: [UIFont labelFontSize]]];
322
[instructionsView setFont: [UIFont systemFontOfSize: [UIFont labelFontSize]*2.0f]];
317
323
[instructionsView setEditable: NO];
318
324
[instructionsView setUserInteractionEnabled: NO];
319
325
[instructionsView setTextAlignment: UITextAlignmentCenter];
320
326
[self addSubview: instructionsView];
322
328
[instructionsView layer].opacity = 0.0f;
330
activityIndicatorView = [[[UIActivityIndicatorView alloc] initWithFrame: [self bounds]] autorelease];
331
activityIndicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
332
activityIndicatorView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
333
UIViewAutoresizingFlexibleRightMargin |
334
UIViewAutoresizingFlexibleTopMargin |
335
UIViewAutoresizingFlexibleBottomMargin);
336
[activityIndicatorView sizeToFit];
338
[activityIndicatorView layer].opacity = 0.0f;
339
[self addSubview: activityIndicatorView];
341
CGRect bounds = [self bounds];
342
CGSize a = [activityIndicatorView frame].size;
343
[activityIndicatorView setFrame: CGRectMake((bounds.size.width-a.width)*0.5f, (bounds.size.height-a.height)*0.5f, a.width, a.height)];
343
364
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
371
[self showImagePicker];
374
[self pasteAction: nil];
345
379
[alertView dismissWithClickedButtonIndex: buttonIndex animated: YES];
380
[activityIndicatorView stopAnimating];
381
[activityIndicatorView layer].opacity = 0.0;
353
389
[alert autorelease];
394
UIImage* theImage = nil;
395
NSArray* images = [[UIPasteboard generalPasteboard] images];
398
UIImage* img = [images objectAtIndex: 0];
404
id url = [[UIPasteboard generalPasteboard] URL];
407
NSData *data = [NSData dataWithContentsOfURL:url];
408
UIImage *img = [UIImage imageWithData:data];
356
418
- (void) pasteAction: (id) info
358
420
NSArray* images = [[UIPasteboard generalPasteboard] images];
432
494
[anim queueForKey: @"image-opacity" atBeginning: NO cancelPending: NO];
497
- (void) showImagePicker
501
imagePicker = [[UIImagePickerController alloc] init];
503
//[imagePicker setSourceType: UIImagePickerControllerSourceTypeCamera];
504
[imagePicker setDelegate: self];
505
//[imagePicker setAllowsImageEditing: YES];
506
//[imagePicker setShowsCameraControls: NO];
510
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
513
if (!popoverController)
515
Class popoverClass = NSClassFromString(@"UIPopoverController");
516
popoverController = [[popoverClass alloc] initWithContentViewController: imagePicker];
518
[popoverController presentPopoverFromRect: [self bounds] inView: self permittedArrowDirections: UIPopoverArrowDirectionAny animated: YES];
522
[delegate presentModalViewController: imagePicker animated: YES];
435
525
- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event
437
UITouch* touch = [touches anyObject];
527
/* UITouch* touch = [touches anyObject];
439
529
if (([touch tapCount] == 1) && [self isItAPhone])
451
541
[pasteTimer invalidate];
452
542
pasteTimer = nil;
456
imagePicker = [[UIImagePickerController alloc] init];
458
//[imagePicker setSourceType: UIImagePickerControllerSourceTypeCamera];
459
[imagePicker setDelegate: self];
460
//[imagePicker setAllowsImageEditing: YES];
461
//[imagePicker setShowsCameraControls: NO];
465
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
468
if (!popoverController)
470
Class popoverClass = NSClassFromString(@"UIPopoverController");
471
popoverController = [[popoverClass alloc] initWithContentViewController: imagePicker];
473
[popoverController presentPopoverFromRect: [self bounds] inView: self permittedArrowDirections: UIPopoverArrowDirectionAny animated: YES];
477
[delegate presentModalViewController: imagePicker animated: YES];
544
[self showImagePicker];
550
- (void) showSourceDialog
552
NSString* msg = NSLocalizedString(@"ImageWell alert message", @"");
553
NSString* title = NSLocalizedString(@"ImageWell alert title", @"");
555
UIImage* img = [self pbImage];
557
UIAlertView* alert = [[UIAlertView alloc] initWithTitle: title message: msg delegate: self cancelButtonTitle: NSLocalizedString(@"ImageWell alert cancel", @"")
558
otherButtonTitles: NSLocalizedString(@"ImageWell alert picker", @""),
559
(img ? NSLocalizedString(@"ImageWell alert paste", @"") : nil),
481
566
- (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event