• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Bitmaps and Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bitmaps and Cocoa


  • Subject: Bitmaps and Cocoa
  • From: Darren Ford <email@hidden>
  • Date: Sun, 20 Jul 2003 07:28:32 +1000

Hi all,

I've implemented a cross-platform raytracer (in C++) and have hooked it into a Cocoa frontend. The raytracer works on a pixel-by-pixel basis and I have a question regarding pixel information and NSImage.

Currently I'm using the 'bitmapData' on a NSBitmapImageRep in order to place pixel data into an NSImage ie.

myRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:x pixelsHigh:y bitsPerSample:8 samplesPerPixel:4 hasAlpha:YES isPlanar:NO colorSpaceName:(NSString *)NSDeviceRGBColorSpace bytesPerRow:0 bitsPerPixel:0];
pData = [myRep bitmapData];

myImage = [[NSImage alloc] initWithSize:ImageSize];
[myImage addRepresentation:mySmoothedImage];

pData = [myImage bitmapData];

and then using weird offsets in order to place the raw pixel data ie.
pData[yy*4*x + xx*4 + 2] = 50;
pData[yy*4*x + xx*4 + 3] = 70;
etc..

All of this appears to work fine, however I was wondering whether there was a more elegant way of approaching raw bitmaps? I'm concerned with the current implementation in that it is not thread safe (my accessing the data is, however with Cocoa's automatic redrawing there's the potential that cocoa tries to read at the same time I'm trying to write my raw data).

Thanks in advance -- Darren.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Bitmaps and Cocoa
      • From: John Randolph <email@hidden>
    • Re: Bitmaps and Cocoa
      • From: Dietmar Planitzer <email@hidden>
  • Prev by Date: Re: Interfacing with the Real Player or Windows Media?
  • Next by Date: Re: Accessor method for array of floats
  • Previous by thread: Fwd: SplitView
  • Next by thread: Re: Bitmaps and Cocoa
  • Index(es):
    • Date
    • Thread