Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making Subimages



Hi,

I'm trying to obtain subimage of an existing image, and have been having
some trouble.

Here's what I'm doing.

I've got an NSBitmapImageRep:

NSBitmapImageRep * imageRep = ...

I can write this to a .tiff file, and it looks normal.

I want to get subimages of this image. In order to do that, I first create
an NSImage* :

NSData *tiffData = [imageRep TIFFRepresentation];
NSImage * myimage = [[NSImage alloc] initWithData:tiffData];

Then, try to chop it up:

NSPoint pt = NSMakePoint(0, 0);
NSRect box = NSMakeRect(0, 0, 100, 100);
[img lockFocus];
[myimage compositeToPoint:pt fromRect:box operation:NSCompositeCopy];
[img unlockFocus];

.. but the resulting images are not drawn as I expect. It appears it's using
(0, h),
as opposed to (0, 0) as the origin of myimage. In other words, if I try to
create a
10x10 image starting from (0, 0), I will get a 10x10 image from (0, height)
instead.

Why is this happening? Is this a problem with the bitmap->TIFF conversion?

Thanks.

~m
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.