Re: Any way to draw a PixMapHandle into an NSView??
Re: Any way to draw a PixMapHandle into an NSView??
- Subject: Re: Any way to draw a PixMapHandle into an NSView??
- From: nicolas berloquin <email@hidden>
- Date: Wed, 5 Jun 2002 11:28:17 +0200
On Wednesday, June 5, 2002, at 07:59 , Jeff LaMarche wrote:
On Tuesday, June 4, 2002, at 06:54 PM, Roger O'Brien wrote:
Hi there. Does anybody know by any chance if it is possible to draw a
PixMapHandle
into an NSView? Thanks in advance...
_______________________________________________
NSImage *myImage = [[NSImage alloc] initWithData:[NSData
dataWithBytes:
*pic length:GetHandleSize((Handle)pic)]];
the only problem with this approach (in my opinion) is that you'll have
the overhead of NSImages.
If you're using pixmaphandles for offscreen drawing, seeking efficiency,
you could
do the equivalent of copybits. (I'm sorry I don't have time to look this
up right now), but
there are functions that return the equivalent of a graphics port for
the current window,
then you can use direct carbon calls or cocoa calls on them. (a pixmap
is just a buffer).
It all depends on what you need to do and why you do it that way.
By the way, you can also use an nsimage's equivalent of pixmaphandle and
draw
directly into it. For this, you need to create an NSBitmapImageRep and
associate it with an NSImage.
Here is what I'm doing in order to decompress a jpeg with jpeglib inside
an offscreen:
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: NULL // Let the
class allocate it
pixelsWide: output_width
pixelsHigh: output_height
bitsPerSample: 8 // Each component is
8 bits (one byte)
samplesPerPixel: 3 // Number of
components (R, G, B, no alpha)
hasAlpha: NO
isPlanar: NO
colorSpaceName: NSDeviceRGBColorSpace
bytesPerRow: 0 // 0 means: Let the
class figure it out
bitsPerPixel: 0 // 0 means: Let the
class figure it out
];
bufferPtr = [bitmap bitmapData]; //that's a pointer to the first byte of
the pixmap equivalent
//it's RGBRGBRGB... that's just to give you an example of the use
NSImage *newImage = [[NSImage alloc] initWithSize:
NSMakeSize(output_width, output_height)];
[newImage addRepresentation: bitmap];
hope this helps... ;-)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.