• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Image manipulation in 10.8
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Image manipulation in 10.8


  • Subject: Re: Image manipulation in 10.8
  • From: Roland King <email@hidden>
  • Date: Sat, 05 Jan 2013 16:51:51 +0800

Well for a start, in what does doesn't it work? Doesn't write a file, writes a zero-length file, writes an image file which is invalid, blank, what?

On 5 Jan, 2013, at 4:44 PM, Amy Gibbs <email@hidden> wrote:

> Hi,
> i've got a section of code that worked perfectly in 10.5. It doesn't in 10.8 and I can't see why. It's not too complicated, it basically takes a selection of images and combines them into a single image and saves it to a couple of locations. Can anyone point out the problem to me please? Many Thanks, Amy
>
>
> 		NSLog(@"up to 6 images");
> 		//background images to fill space
> 		float xb = 600;
> 		float yb = 600;
> 		//for each image
> 		NSEnumerator *imageLoop = [kitImages objectEnumerator];
> 		NSString *imgPath;
> 		while ((imgPath = [imageLoop nextObject])) {
> 			NSLog(@"Image Path: %@",imgPath);
> 			NSImage *img = [[NSImage alloc]initWithContentsOfFile:imgPath];
> 			//apply image to view
>
> 			NSLog (@"Coordinates are x:%f  y:%f",x, y);
> 			[targetImage lockFocus];
> 			[img drawInRect:NSMakeRect(x,y,xb,yb) fromRect:NSMakeRect(0,0,0,0) operation:NSCompositeCopy fraction:1];
> 			xb = 201;
> 			yb = 226;
> 			//set new coordinates
> 			x = x+200;
> 			//if coordinates are too wide, start new row - if x>300, reset x to 0 and add 100 to y
> 			if( x > (float)599 ){
> 				x = x-600;
> 				y = y+225;
> 				NSLog(@"x is greater than 300");
> 				}
> 		}
> 	}
>
> 	//apply kit logo to view
> 	NSString *kitLogoFilePath = [kit valueForKeyPath:@"kitClub.clubLogo"];
> 	NSImage *kitLogoImg = [[NSImage alloc]initWithContentsOfFile:kitLogoFilePath];
>
> 	[kitLogoImg drawInRect:NSMakeRect(375,75,150,150) fromRect:NSMakeRect(0,0,0,0) operation:NSCompositeCopy fraction:1];
>
> 	//apply stroke arund edge
> 	NSPoint origin = { 0,0 };
> 	NSRect rect;
> 	rect.origin = origin;
> 	rect.size.width = 600;
> 	rect.size.height = 600;
> 	NSBezierPath * path;
> 	path = [NSBezierPath bezierPathWithRect:rect];
> 	[path setLineWidth:5];
> 	[[NSColor colorWithDeviceRed:(float)0.624
> 						   green:(float)0.694
> 							blue:(float)0.471
> 						   alpha:(float)1.0] set];
> 	[path stroke];
>
> 	//save files out
> 	[targetImage unlockFocus];
> 	//create a NSBitmapImageRep
> 	NSBitmapImageRep *bmpImageRep = [[NSBitmapImageRep alloc]initWithData:[targetImage TIFFRepresentation]];
> 	//add the NSBitmapImage to the representation list of the target
> 	[targetImage addRepresentation:bmpImageRep];
>
> 	//get the data from the representation
> 	NSData *data = [bmpImageRep representationUsingType: NSJPEGFileType properties: nil];
>
> 	//write the data to a file
> 	[data writeToFile: kitimagePath
> 		   atomically: NO];
> 	[[ NSFileManager defaultManager ] copyItemAtPath:kitimagePath toPath:desktopPath error:nil];
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Image manipulation in 10.8
      • From: Amy Gibbs <email@hidden>
References: 
 >Image manipulation in 10.8 (From: Amy Gibbs <email@hidden>)

  • Prev by Date: Image manipulation in 10.8
  • Next by Date: Re: Image manipulation in 10.8
  • Previous by thread: Image manipulation in 10.8
  • Next by thread: Re: Image manipulation in 10.8
  • Index(es):
    • Date
    • Thread