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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to