• 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 a single pixel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Drawing a single pixel


  • Subject: Re: Drawing a single pixel
  • From: "Dennis C. De Mars" <email@hidden>
  • Date: Sat, 26 May 2001 21:05:23 -0700

on 5/26/01 8:24 PM, Vince DeMarco at email@hidden wrote:

> On Saturday, May 26, 2001, at 08:06 PM, email@hidden wrote:
>
>> I wrote a mset fractal program a while back for Mac OS <9 in C. And I
>> would like to write one in cocoa. Well, I was just wondering how to
>> draw a single pixel. I guess I could use NSBezier and just make a rect
>> that is 1 pixel large but I was wondering if there was a way to just do
>> a single pixel.
>>
>>
> You could create a NSImage with a NSBitmapImageRep (you can get at the
> bitmap data from BitmapImageRep) set the pixel you want then composite
> this back into your View when appropriate.

Yes, he needs to use NSBitmapImageRep. However, I believe the reason he
wants to be able to change a single pixel is because he wants to build a
fractal picture up pixel by pixel and then display it. In that case, he
should just set all of the pixels in NSBitmapImageRep's bitmap to the proper
values and then display that.

I actually have a toy Cocoa program that does exactly this (generate an
image of the Mandelbrot set and display it). I simply use NSImageView in a
window. I create an NSBitmapImageRep, set the NSImage's representation to
this, and write directly into the bitmap. It's very simple to do. I could
post the source code if anybody's interested as a simple example of how to
generate an arbitrary bitmap image and display it using NSBitmapImageRep.

- Dennis D.


  • Follow-Ups:
    • Re: Drawing a single pixel
      • From: Louis Demers <email@hidden>
References: 
 >Re: Drawing a single pixel (From: Vince DeMarco <email@hidden>)

  • Prev by Date: Re: Drawing a single pixel
  • Next by Date: grrr... NSString stringWithFormat: vs. SEL typecasting
  • Previous by thread: Re: Drawing a single pixel
  • Next by thread: Re: Drawing a single pixel
  • Index(es):
    • Date
    • Thread