how to modify pixel values?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
2049651
Posts: 29
Joined: 2015-10-20T07:29:42-07:00
Authentication code: 1151

how to modify pixel values?

Post by 2049651 » 2015-10-27T06:22:36-07:00

Hi.

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;
}
What am I do for solving?

Post Reply