• 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
Re: drawing pixels
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing pixels


  • Subject: Re: drawing pixels
  • From: Tobias Klüpfel <email@hidden>
  • Date: Mon, 22 Mar 2004 10:39:23 +0100

The NSBitmapImageRep solution is exactly what I was hoping for.

Thanks to everyone who took the time to help me out.

Cheers,
Toby

On 21.03.2004, at 21:10, Chris Hanson wrote:

> On Mar 21, 2004, at 7:26 AM, Tobias Kl|pfel wrote:
>> control the data object of an NSBitmapImageRep (I gave up trying to
>> figure out the format - there has to be an easier way)
>
> With an NSBitmapImageRep, the format is what whatever you want it to
> be:
>
> NSMutableData *rasterData = [[NSMutableData alloc]
> initWithLength:((640 * 4) * 480)];
>
> unsigned char *rasterDataPlanes[1];
>
> rasterDataPlanes[0] = [rasterData mutableBytes];
>
> NSBitmapImageRep *imageRep
> = [[NSBitmapImageRep alloc]
> initWithBitmapDataPlanes:rasterDataPlanes
> pixelsWide:640
> pixelsHigh:480
> bitsPerSample:8
> samplesPerPixel:4
> hasAlpha:YES
> isPlanar:NO
>
> colorSpaceName:NSCalibratedRGBColorSpace
> bytesPerRow:(640 * 4)
> bitsPerPixel:32];
>
> With this, rasterDataPlanes[0] is your raw raster data, stored in row
> order, using chunky RGBA 8/8/8/8 pixels. You can manipulate this
> information directly, and draw it by setting up a view appropriately
> and sending your imageRep -draw. Or you can set it as a
> representation for an NSImage, or...
>
> You can also choose to use planar data (each color stored in its own
> buffer) by passing YES for the isPlanar: argument, passing an array of
> four pointers in for the data planes, and passing appropriate values
> for bytesPerRow: and bitsPerPixel:. (Or three if there are only 3
> samples per pixel.) This is handy for some algorithms that operate on
> different color channels independently. You can even use some non-RGB
> color spaces.
>
> -- Chris
>
> --
> Chris Hanson <email@hidden>
> http://www.livejournal.com/users/chanson/
> _______________________________________________
> 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.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.


References: 
 >drawing pixels (From: Tobias Klüpfel <email@hidden>)
 >Re: drawing pixels (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: [Q] How to detect missing storage allocation?
  • Next by Date: Re: NSTask with complexe command
  • Previous by thread: Re: drawing pixels
  • Next by thread: Re: drawing pixels
  • Index(es):
    • Date
    • Thread