Allocate memory for pixel map of a image in C

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
cam
Posts: 12
Joined: 2013-11-29T23:24:10-07:00
Authentication code: 6789

Allocate memory for pixel map of a image in C

Post by cam »

Hello,

How can i allocate memory for the entire pixel array of a image read from disk?.
I need to allocate with calloc but I don't know all the structs and datatypes of magickwand,

Please give that 1 line of code to do what i need.

Thanks a lot!.


Ps: I am using imagemagick Q8 and C languague.
cam
Posts: 12
Joined: 2013-11-29T23:24:10-07:00
Authentication code: 6789

Re: Allocate memory for pixel map of a image in C

Post by cam »

Is this correct to edit the second pixel of the space allocated?

Code: Select all

MagickPixelPacket *pixels_map = (MagickPixelPacket *) malloc(sizeof(MagickPixelPacket) * image_width * image_height);
pixels_map[1].red = 255;
pixels_map[1].green 255;
pixels_map[1].blue = 255;
Post Reply