Get pixel data from an image?

Discussion in 'Mac Programming' started by printz, Sep 9, 2013.

  1. macrumors regular

    Joined:
    Dec 23, 2012
    #1
    I'm trying to make a photomosaic generator for OSX. What I need is to be able to get direct bitmap/pixel data from images (so I can determine the average colour of a mosaic tile), but NSImage seems too high level for this. Any help please? The Apple documentation about drawing looks huge and has lots of variants (Cocoa, Quartz, OpenGL)… I'd prefer Cocoa here.
     
  2. macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    Get your image as a NSBitmapImageRep then use colorAtX:y: on it.
     
  3. macrumors 68040

    Joined:
    Feb 2, 2008
    #3
    From an NS image you can extract an image representation and then get bitmap data pointed to by an unsigned char pointer.
     

Share This Page