Skip navigation.
 
mlRe: BitMap data format and autorelease
FROM : Adam R. Maxwell
DATE : Wed Mar 12 21:58:12 2008

On Wednesday, March 12, 2008, at 01:26PM, "Trygve Inda" <<email_removed>> wrote:
>>

>Is there a benefit to calling:
>
>image = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
>[image addRepresentation:imageRep];
>
>Then using:
>
>[image lockFocusOnRepresentation:imageRep];
>
>[image unlockFocus];
>
>This would give me an NSImage which uses my bitmap. Any pros/cons here?


I'd use something like this (typed in Mail):

[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:imageRep]];

// draw here

[NSGraphicsContext restoreGraphicsState];

which avoids creating an NSImage.

--
adam

Related mailsAuthorDate
mlBitMap data format and autorelease Trygve Inda Mar 12, 17:09
mlRe: BitMap data format and autorelease Jens Alfke Mar 12, 17:23
mlRe: BitMap data format and autorelease Trygve Inda Mar 12, 18:03
mlRe: BitMap data format and autorelease Trygve Inda Mar 12, 18:11
mlRe: BitMap data format and autorelease Trygve Inda Mar 12, 20:01
mlRe: BitMap data format and autorelease Jens Alfke Mar 12, 20:57
mlRe: BitMap data format and autorelease Trygve Inda Mar 12, 21:20
mlRe: BitMap data format and autorelease Adam R. Maxwell Mar 12, 21:58
mlRe: BitMap data format and autorelease Jens Alfke Mar 12, 23:19
mlRe: BitMap data format and autorelease Trygve Inda Mar 14, 01:44
mlRe: BitMap data format and autorelease Jens Alfke Mar 14, 02:01
mlRe: BitMap data format and autorelease Adam R. Maxwell Mar 14, 02:03