Re: Writing x, y to NSBitmapImageRep
Re: Writing x, y to NSBitmapImageRep
- Subject: Re: Writing x, y to NSBitmapImageRep
- From: Jean-Daniel Dupas <email@hidden>
- Date: Mon, 31 Mar 2008 16:42:21 +0200
NSBitmapImageRep is a subclass of NSImageRep, and so, it responds to -
draw, -drawAtPoint: and -drawInRect:.
Maybe trying to directly draw the bitmap representation will avoid
caching and other NSImage optimization issues.
[rayTracer.imageRep drawInrect:rect];
Le 31 mars 08 à 16:21, Eddie Hebert a écrit :
It appears to be properly storing the values, through inspection
from NSLog and colorAt.
The next step is drawing, I am trying to show incremental updates of
the progress of the render engine,
within the drawRect method of an NSImageView I am calling (at an
interval based on NSTimer)
[[self image] drawRepresentation:rayTracer.imageRep inRect:rect];
I have set up the image by using
[self setImage:[[NSImage alloc] initWithSize:rect.size]];
[[self image] setCacheMode:NSImageCacheNever];
Is this an issue now of not using [NSGraphicsContext saveState], etc.?
merci beaucop
On Mar 31, 2008, at 10:02 AM, Jean-Daniel Dupas wrote:
You should use
-[NSBitmapImageRep
initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bitmapFormat:bytesPerRow:bitsPerPixel
:]
to initialize your bitmap.
A bitmap representation initialized using -initForIncrementalLoad
expects that you call -incrementalLoadFromData:complete:
Le 31 mars 08 à 15:54, Eddie Hebert a écrit :
I have a need to store and draw an image that I create iteratively
over each pixel.
I am trying to use NSBitmapImageRep with setColor: x: y:, to do so.
Within the constructor of my "rendering engine" class, I
instantiate a NSBitmapImageRep, thusly:
_imageRep = [[NSBitmapImageRep alloc] initForIncrementalLoad];
[_imageRep setSize:NSMakeSize(aWidth, aHeight)];
[_imageRep setPixelsWide:aWidth];
[_imageRep setPixelsHigh:aHeight];
[_imageRep setColorSpaceName:@"NSDeviceRGBColorSpace"];
[_imageRep setAlpha:NO];
Then in the main loop of my engine I call, [_imageRep
setColor:color atX:col y:row]
When I do so I get the error:
Mon Mar 31 09:41:41 ***.local Ray Tracer[15727] <Error>:
CGImageSourceCopyPropertiesAtIndex image source parameter is nil\n
Mon Mar 31 09:41:41 ***.local Ray Tracer[15727] <Error>:
CGImageSourceCreateImageAtIndex image source parameter is nil\n
Mon Mar 31 09:41:41 ***.local Ray Tracer[15727] <Error>:
CGImageSourceCopyPropertiesAtIndex image source parameter is nil\n
Mon Mar 31 09:41:41 ***.local Ray Tracer[15727] <Error>:
CGImageSourceCreateImageAtIndex image source parameter is nil\n
And when I call [_imageRep colorAtX:col y:row], I get back
NSDeviceRGBColorSpace 1 1 1 1, which is not the NSColor that I
sent it.
Is there some parameter/property of NSBitmapImageRep that I am not
setting that is causing these errors?
Or does this have something to do with not locking properly?
Thanks in advance,
Ed Hebert Jr.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden