Weird behavior when modifying pixels using Magick++
Posted: 2013-07-24T23:13:12-07:00
Hi guys,
I'm just starting with ImageMagick so this question might sound a bit newbie like but I just can figure out what the problem is.
I tried geting a pixel_cache, iterating over pixels in there and modifying them to some color but the result I get is always some color with some pattern. The code I used was
And the output I get can be seen here (https://docs.google.com/file/d/0B6m4Eln ... 1oX2s/edit). If you pay attention you will notice the sripes where the green square should be.
Any help would be appreciated...
I'm just starting with ImageMagick so this question might sound a bit newbie like but I just can figure out what the problem is.
I tried geting a pixel_cache, iterating over pixels in there and modifying them to some color but the result I get is always some color with some pattern. The code I used was
Code: Select all
const std::string image_url = "wizard.jpg";
Image image(image_url);
// Ensure that there is only one reference to underlying image
// If this is not done, then image pixels will not be modified.
image.type(TrueColorType);
image.modifyImage();
// Allocate pixel view
Pixels view(image);
size_t columns = 115; size_t rows =115;
Color green("green");
PixelPacket *pixels = view.get(10,10,10+columns,10+rows);
for ( ssize_t row = 0; row < rows ; ++row )
for ( ssize_t column = 0; column < columns ; ++column )
*pixels++=(PixelPacket) green;
// Save changes to image.
view.sync();
image.write("wizardout.jpg");
Any help would be appreciated...