I got a problem.
the output image has black instead red.
1>c:\program files\imagemagick-6.8.6-q16\include\magick/pixel-accessor.h(160): warning C4244: '=' : conversion from 'double' to 'MagickCore::MagickRealType', possible loss of data
here is my code.
Code: Select all
InitializeMagick(*argv);
Image master;
master.read("D:\\work\\ex4\\q1.jpg");
int x;
int y;
int h = 480;
PixelPacket *pixels = master.getPixels(0, 0, 640, 480);
int w = 640;
for (int y = 0; y != h; ++y)
for (int x = 0; x != w; ++x)
{
pixels[w * y + x].red = 255;
pixels[w * y + x].green = 0;
pixels[w * y + x].blue = 0;
}
master.syncPixels();
master.write("D:\\work\\ex4\\out_q1.jpg");
//master.addNoise(ImpulseNoise);
//master.write("D:\\work\\ex4\\out_q1.jpg");
return 0;
}