Re: Image manipulation in 10.8
Re: Image manipulation in 10.8
- Subject: Re: Image manipulation in 10.8
- From: Amy Gibbs <email@hidden>
- Date: Sat, 05 Jan 2013 09:42:01 +0000
Sorry, I had to reduce the length of the email to post it and deleted the key info! It doesn't place the images on the canvas. Imagine a grid, and this should put an image in each box, and it worked fine in 10.5, now the images are mainly white with just one image in one of the grid boxes ( the exact box varies), it applies the stroke and creates the files
On 5 Jan 2013, at 8:51AM, Roland King <email@hidden> wrote:
> 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