Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > [NSImage size] broken?

[NSImage size] broken?
Thread Tools
Fresh-Faced Recruit
Join Date: Jul 2002
Status: Offline
Reply With Quote
Aug 1, 2002, 07:21 PM
 
I'm trying to access the width and height dimensions of an NSImage initialized with a JPEG from disk. However, [NSImage size].width and [NSImage size].height is returning strange values. For instance, for a 100 x 200 JPEG the reported width is 1079574528 and height is 0.

Here's some sample code:

NSImage* image = [[NSImage alloc] initWithContentsOfFile: @"my_picture.jpg"];
NSLog(@"Width: %i Height: %i",[image size].width, [image size].height);

And output:

Width: 1079574528 Height: 0

Is [NSImage size] broken or am I just using it incorrectly?

Cheers
     
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status: Offline
Reply With Quote
Aug 2, 2002, 11:19 PM
 
I'm not very familiar with all the printf arguments, but what's %i? [image size].width returns a float, so I'd usually use %f. Try that and see if it works; it always has for me.

Matt Fahrenbacher
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Aug 4, 2002, 07:41 AM
 
I think %i is the same as %d, but I'm not sure.
     
Professional Poster
Join Date: Apr 2001
Location: Long Beach, CA
Status: Offline
Reply With Quote
Aug 4, 2002, 11:05 AM
 
Originally posted by Ghoser777:
I'm not very familiar with all the printf arguments, but what's %i? [image size].width returns a float, so I'd usually use %f. Try that and see if it works; it always has for me.

Matt Fahrenbacher
Cool... that fixed my problems too!

ACSA 10.4/10.3, ACTC 10.3, ACHDS 10.3
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:17 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2