Re: Flipping an NSImage (even more trouble with size)
Re: Flipping an NSImage (even more trouble with size)
- Subject: Re: Flipping an NSImage (even more trouble with size)
- From: John Pannell <email@hidden>
- Date: Thu, 6 Oct 2005 14:47:19 -0600
Hi Michael-
I have an app that gathers images from the web; the sizes/resolutions/
bitdepths are all over the place. I have found it helpful to create
the image via NSBitmapImageRep, like so...
NSImage *theImage;
NSData *imageData = [[NSData alloc] initWithContentsOfFile:myFile];
NSBitmapImageRep *bitmapImageRep = [[NSBitmapImageRep alloc]
initWithData:imageData];
theImage = [[NSImage alloc] initWithSize:[bitmapImageRep size]];
[theImage addRepresentation:bitmapImageRep];
The "size" returned by NSImage is affected by the resolution the file
was stored in (I encountered the same problem you have, and figured
things out poking around in Photoshop). The size returned by
NSBitmapImageRep, however, is pixels by pixels.
This doesn't help with the flip, but should assist with the mixed
image resolutions you are seeing.
HTH-
John
John Pannell
Positive Spin Media
http://www.positivespinmedia.com
On Oct 6, 2005, at 1:46 PM, Michael Becker wrote:
Am 06.10.2005 um 19:11 schrieb Michael Becker:
I am using NSImage's drawInRect:fromRect: method to draw the
portions of the images into the frames. If I call
[currentImage drawInRect:frameRect fromRect:NSMakeRect( 0, 0,
100, 100) ...
the upper left part of the image should be displayed, as the
fromRect:-rectangle starts at the image's (flipped) origin. So far
so good. However, *some* images still seem to have their origin in
the LOWER left corner. In that case, the code snippet I wrote
would draw the LOWER left part of the image into frameRect.
The images I use are various JPEGs coming from all kinds of
sources and I cannot see any obvious reason why some of them would
behave strangely when flipped.
I am not an expert at this flipping thing, but for *most* images
it works, and I cannot even determine whether an image will be
"different" beforehand.
There is another question coming up here: I have a JPEG imag with a
size of 800x600 pixels. iPhoto, Preview, PhotoShop and virtually
every other app that I can find on my computer says so. NSImage
does not. Okay, (I thought otherwise but) I obviously am a newbie
to NSImage and friends.
I have a custom view that simply takes the image (created via
NSImage initWithContentsOfFile:) and displays it. Querying its size
via -size reports (192, 144) and the result onscreen looks like
that too. Is it possible that there is some kind of thumbnail
stored in the image and that NSImage takes that?
How can I reach through to the actual image?
- Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40positivespinmedia.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden