reading an image

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
User avatar
magick
Site Admin
Posts: 10965
Joined: 2003-05-31T11:32:55-07:00

Post by magick » 2006-04-07T12:55:48-07:00

You probably want to use this method from the MagickWand API:

Code: Select all

  MagickGetImagePixels() extracts pixel data from an image and returns it to
  you.  The method returns MagickTrue on success otherwise MagickFalse if an
  error is encountered.  The data is returned as char, short int, int, long,
  float, or double in the order specified by map.

  Suppose you want to extract the first scanline of a 640x480 image as
  character data in red-green-blue order:

      MagickGetImagePixels(wand,0,0,640,1,"RGB",CharPixel,pixels);

  The format of the MagickGetImagePixels method is:

      MagickBooleanType MagickGetImagePixels(MagickWand *wand,
        const long x,const long y,const unsigned long columns,
        const unsigned long rows,const char *map,const StorageType storage,
        void *pixels)

  A description of each parameter follows:

    o wand: The magick wand.

    o x, y, columns, rows:  These values define the perimeter
      of a region of pixels you want to extract.

    o map:  This string reflects the expected ordering of the pixel array.
      It can be any combination or order of R = red, G = green, B = blue,
      A = alpha (0 is transparent), O = opacity (0 is opaque), C = cyan,
      Y = yellow, M = magenta, K = black, I = intensity (for grayscale),
      P = pad.

    o storage: Define the data type of the pixels.  Float and double types are
      expected to be normalized [0..1] otherwise [0..QuantumRange].  Choose from
      these types: CharPixel, DoublePixel, FloatPixel, IntegerPixel,
      LongPixel, QuantumPixel, or ShortPixel.

    o pixels: This array of values contain the pixel components as defined by
      map and type.  You must preallocate this array where the expected
      length varies depending on the values of width, height, map, and type.

Post Reply