On Jun 21, 2008, at 8:41 AM, Dharmendra wrote:

I am trying to get a user-defined image in specific format (m x nm) and want to generate an array with count n containing m x m sized images. I have written the following code, but would like to know if there is better way to
do the same:

Rather than using NSImage, which is really about drawing, you might consider using NSBitmapImageRep directly. Initialize the source from the file data. Then, initialize each sub-image using one of the initWithBitmapDataPlanes:... methods, obtaining the arguments by querying the source and performing a bit of math on the planes value.

That said, read the caveat in the NSBitmapImageRep class overview:

Alpha Premultiplication
If a coverage (alpha) plane exists, a bitmap’s color components are premultiplied with it. If you modify the contents of the bitmap, you are therefore responsible for premultiplying the data. For this reason, though, if you want to manipulate the actual data, an NSBitmapImageRep object is not recommended for storage. If you need to work with unpremultiplied data, you should use Quartz, specifically CGImageCreate with kCGImageAlphaLast.


That caveat would apply to NSImage, too, because it's based on NSBitmapImageRep.

Cheers,
Ken_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to