Hi all,

that fixes my null  issue, thanks, I can't believe I didn't see that.

I still can't work out how to get the original height and width of my image though, I'm trawling through google searches for nsimage and size etc but nothing seems to work I get various error messages,

while ((imgPath = [imageLoop nextObject])) {
                        NSImage *img = [[NSImage 
alloc]initWithContentsOfFile:imgPath];
                        float imgsize = [img bounds].size.height;
                                
                        float scalefactor = 225 /imgsize ;
                        

On 10 Nov 2010, at 1:57PM, Thomas Wetmore wrote:

Amy,

%@ is not the right format character to use in NSLog to see floating point numbers. Try %f.

Good luck,

Tom Wetmore

On Nov 10, 2010, at 8:35 AM, Amy Gibbs wrote:

Hi,

I can't quite get my head around obj-c sometimes, so i was just wondering if anyone could point me in the right direction.

I've got a fairly simple coredata app that I code and use to keep track of some work stuff (I run my own business), and it automatically generates composite images for me. At the moment it's set to re-size the original images and fit them into a 3x4 grid, but if theres only a few images it looks very odd, so I want to change it so if there are less than 8 images it lays them out differently. In non code what I want to do is:


for NSMakeRect(0,0,x,y)

origin to stay at 0,0
calculate scale factor (sf) by dividing 225(required height) by the original height: sf = 225 / originalheight

x = requiredwidth / sf

y = originalheight

I can't work out how to get the original height and width of the image, and I think i'm getting confused with number formats, I've got the following at the moment but my width variable is coming out as null?

NSArray* kitImages = [kit valueForKeyPath:@"kitItems.kitItemProduct.productImage"];
        int ki = [kitImages count];
        NSLog(@"Number of images: %i",ki);
        //calc image width
        float width = 300 / ki;
        NSLog(@"Width: %@",width);

I'd appreciate any help.

Many Thanks

Amy
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/ttw4%40verizon.net

This email sent to t...@verizon.net


_______________________________________________

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

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

Reply via email to