0

I want to use NSBitmapImageRep to construct a 64x64 pixel sprite in code, and then draw it to the screen, blown up very large. The result would be very large "pixels" on the screen. Think old school Mario Bros. or Minecraft. How can I do this?

Edit I want to draw to this off-screen bitmap and then render it later on a CALayer

mtmurdock
  • 12,756
  • 21
  • 65
  • 108

1 Answers1

1

Open an new image context with CGBitmapContextCreate and use

void CGContextSetInterpolationQuality (
   CGContextRef c,
   CGInterpolationQuality quality
);

to set the interpolation quality to kCGInterpolationNone.

Then draw the image into the context.

  • I'm actually looking more for how to use NSBitmapImageRep in the first place. It seems quite complicated. Is there a simple bitmap representation I can use? Or do you know of any good tutorials for this? – mtmurdock Feb 25 '12 at 17:50
  • What do you mean by "is there a simple bitmap representation i can use"? –  Feb 25 '12 at 18:33
  • What I meant was something more like Java's Bitmap class, but I have found another solution inspired by your answer. I individual pixels to a NSImage, and then scale that up when I render it to the screen. This gives me the nice abstraction of NSImage, and the visual effect I want. Thanks! – mtmurdock Feb 25 '12 at 18:41