• 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 with NSBezierPath
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing Pixels with NSBezierPath


  • Subject: Re: Drawing Pixels with NSBezierPath
  • From: Shawn Erickson <email@hidden>
  • Date: Tue, 6 Jul 2004 13:52:13 -0700

On Jul 6, 2004, at 12:00 PM, Shaun Wexler wrote:

On Jul 3, 2004, at 11:34 AM, Christopher O'Neill wrote:

Hi all. The program I am writing requires a view to be drawn with every pixel being a different color. The only way I can see to do it is to create a new 1x1 NSRect and draw them to their correct locations. However, this takes a long time to draw. It constantly has to be redrawn as one pixel changes color with every click of the mouse. I have increased speed dramatically by splitting it up into smaller subviews and only updating the ones that need updating, but sometimes every pixel needs to be changed, so it will again take a long time to update. Is there a faster way to do it that I have not seen, possibly by drawing an array of colors at one pixel each? Any help is appreciated.

Use OpenGL.

<http://developer.apple.com/opengl>
<http://developer.apple.com/documentation/Cocoa/Conceptual/OpenGL>

Create a rectangular texture the same size as your view's bounds, and set the context to per-pixel orthogonal projection. Enable client storage and texture range, and texture priority 0. Now you can write into the texture's memory buffer and store direct pixel color values, using row/col indexing. Many ways to do what you want with the pixels. Your speed should increase a hundred-fold, and it's only a little more complicated to support hardware that requires power-of-2 texture sizes (ATI Rage 128/Pro/M3).

Only fall back on doing this if needed because of performance and consider any need to print out or otherwise export the images generated. Finally consider the assumption of 1 pixel per point in the 72 DPI world because that assumption may change in the future.

Using Quartz2D/Cocoa will give you the ability to rasterize your "pixel" grid at arbitrary resolutions and dump it various output formats. Also it will be fully color corrected.

-Shawn
_______________________________________________
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: Drawing Pixels with NSBezierPath
      • From: Shaun Wexler <email@hidden>
    • Re: Drawing Pixels with NSBezierPath
      • From: Steve Sims <email@hidden>
References: 
 >Drawing Pixels with NSBezierPath (From: "Christopher O'Neill" <email@hidden>)
 >Re: Drawing Pixels with NSBezierPath (From: Shaun Wexler <email@hidden>)

  • Prev by Date: Re: Prevent file access.
  • Next by Date: Re: Prevent file access.
  • Previous by thread: Re: Drawing Pixels with NSBezierPath
  • Next by thread: Re: Drawing Pixels with NSBezierPath
  • Index(es):
    • Date
    • Thread