Page 1 of 1

Allocate memory for pixel map of a image in C

Posted: 2013-12-01T18:49:08-07:00
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.

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

Posted: 2013-12-02T05:07:39-07:00
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;