I'm using MagickCore, and I have a problem with changing RGB value of pixel.
what I am doing is:
1.read a gif picture
2.change some pixels's RGB value of each frame
3.save the picture as gif
my code looks like this:
Code: Select all
int main(int argc, char* argv[])
{
ExceptionInfo
*exception;
Image *images;
ImageInfo *image_info;
FILE * f = fopen("/home/somedir/1.gif", "rb");
fseek(f, 0, SEEK_END);
long fileLength = ftell(f);
fseek(f,0, SEEK_SET);
unsigned char * fileData = (unsigned char *)malloc(fileLength);
fread(fileData, 1, fileLength, f);
exception=AcquireExceptionInfo();
image_info=CloneImageInfo((ImageInfo *) NULL);
unsigned int length;
char * base64data = Base64Encode(fileData, fileLength, &length);
length = 0;
images = ReadInlineImage(image_info, base64data, exception);
if (exception->severity != UndefinedException)
CatchException(exception);
if (images == (Image *) NULL)
{
printf("Read image fail!\n");
return 1;
}
int imageCount = 0;
Image * currentImage = images;
while(currentImage != (Image *) NULL)
{
imageCount++;
/***************************************************************************/
//I want to change some piexls here ,how can I do ?
// for example, change point(10,10)'s RGB value to (255,255,255)
/***************************************************************************/
currentImage = currentImage->next;
}
if(imageCount == 0)
{
printf("Image error!\n");
return 1;
}
WriteImages(image_info, images, "/home/somedir/2.gif", exception);
printf("OK!\n");
return 0;
}
please help me ,thanks very much!