Search code examples
cocoascalensbitmapimagerep

cocoa: How can I draw a scaled up version of NSBitmapImageRep?


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


Solution

  • 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.