I use as test image the following:
Code: Select all
$identify test.jpg
test.jpg JPEG 500x500 500x500+0+0 8-bit sRGB 193KB 0.000u 0:00.000
Code: Select all
$convert test.jpg txt:-
# ImageMagick pixel enumeration: 500,500,255,srgb
0,0: (66,70,82) #424652 srgb(66,70,82)
1,0: (65,68,83) #414453 srgb(65,68,83)
2,0: (62,68,82) #3E4452 srgb(62,68,82)
3,0: (62,70,81) #3E4651 srgb(62,70,81)
...
Code: Select all
ExceptionInfo
*exception;
Image
*origin_image,
*clone_image;
ImageInfo
*origin_image_info;
const PixelPacket
*p;
PixelPacket
*q;
ssize_t
x,
y;
origin_image_info = AcquireImageInfo();
(void) strcpy(origin_image_info->filename, origin_filename);
exception = AcquireExceptionInfo();
origin_image = ReadImage(origin_image_info, exception);
if (exception->severity != UndefinedException)
CatchException(exception);
if (origin_image == (Image *) NULL)
MagickFatalError(ResourceLimitError, "Fatal Error", "can't open the image");
clone_image = CloneImage(origin_image, origin_image->columns, origin_image->rows, MagickTrue, exception);
if (clone_image == (Image *) NULL)
{ /* an exception was thrown */ }
for (y=0; y < (ssize_t) origin_image->rows; y++)
{
p=GetVirtualPixels(origin_image,0,y,origin_image->columns,1,exception);
q=GetAuthenticPixels(clone_image,0,y,clone_image->columns,1,exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL)) break;
for (x=0; x < (ssize_t) clone_image->columns; x++)
{
printf("\n(%d,%d) %d %d %d", x, y, p->red, p->green, p->blue);
SetPixelRed(q,p->red);
SetPixelGreen(q,p->green);
SetPixelBlue(q,p->blue);
p++;
q++;
}
if (SyncAuthenticPixels(clone_image,exception) == MagickFalse)
break;
}
if (y < (ssize_t) clone_image->rows)
{ MagickFatalError(ResourceLimitError, "Fatal Error", "error"); }
(void) strcpy(clone_image->filename, clone_filename);
WriteImage(origin_image_info, clone_image);
Code: Select all
(0,0) 16962 17990 21074
(1,0) 16705 17476 21331
(2,0) 15934 17476 21074
(3,0) 15934 17990 20817
...
If now I take a look to the clone_image pixel with the convert utility, I get another difference:
Code: Select all
$convert clone_test.jpg txt:-
# ImageMagick pixel enumeration: 500,500,255,srgb
0,0: (66,70,82) #424652 srgb(66,70,82)
1,0: (65,68,83) #414453 srgb(65,68,83)
2,0: (63,69,83) #3F4553 srgb(63,69,83)
3,0: (62,70,81) #3E4651 srgb(62,70,81)
...
Thanks for the help