Weird behavior when modifying pixels using Magick++

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
markovuksanovic
Posts: 3
Joined: 2010-08-14T14:13:40-07:00
Authentication code: 8675308

Weird behavior when modifying pixels using Magick++

Post by markovuksanovic »

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

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");
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...
Post Reply