[SOLVED]Writing a white image: after a certain size it gives me a "pixels are not authentic" error

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
edrid
Posts: 2
Joined: 2017-07-30T01:53:37-07:00
Authentication code: 1151

[SOLVED]Writing a white image: after a certain size it gives me a "pixels are not authentic" error

Post by edrid » 2017-08-03T04:21:59-07:00

I'm playing around with Magick++ prior to a uni project I've to do in C++.
In particular, as of now, I'm implementing some kernel image processing. Long story short, after certain operations (i.e. exporting, doing the convolution on the 2D std::vectors, etc.) I want to set the pixel of a completely white image to those i calculated with the convolution, so I do the following:

Code: Select all

for(unsigned int i = 0; i < elaboratedImage.size().height()-1; i++){
        for(unsigned int j = 0; j < elaboratedImage.size().width()-1; j++){
            elaboratedImage.pixelColor(i,j, Color(reds.at(i).at(j), greens.at(i).at(j), blues.at(i).at(j), 0));
            //std::cout << "i = " << i << "\tj = " << j << std::endl;
        }
    }
However, after the 0th iteration of the outer for-loop and 479th iteration of the inner for-loop it throws me the following error:
terminate called after throwing an instance of 'Magick::ErrorCache'
what(): ImMagPlayground: pixels are not authentic `#FFFFFF' @ error/cache.c/QueueAuthenticPixelCacheNexus/3961
The image is 640x480, that I created using

Code: Select all

Image elaboratedImage(Geometry(640,480), Color(QuantumRange, QuantumRange, QuantumRange));
, so a white image of the specified dimensions (I do display and it shows correctly).

However it seems like the library, at a certain point, considers this image as a 480x480, in fact, if I do the for(s), both using the height it works (obviously it only shows me a square of the processed image and a white bar on the right (the remaining 640-480 not set pixels)).

I also tried to manually set one pixel in the outer range (e.g. pixel(1,500)) and it gives me the same error..

I'm sure it's a simple error.. however I'm not getting it..
Last edited by edrid on 2017-08-04T02:38:09-07:00, edited 1 time in total.

snibgo
Posts: 9253
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Writing a white image: after a certain size it gives me a "pixels are not authentic" error

Post by snibgo » 2017-08-03T11:39:49-07:00

pixelColor, like most functions, expects the coordinates in the order x then y. Not y then x.
snibgo's IM pages: im.snibgo.com

edrid
Posts: 2
Joined: 2017-07-30T01:53:37-07:00
Authentication code: 1151

Re: Writing a white image: after a certain size it gives me a "pixels are not authentic" error

Post by edrid » 2017-08-04T02:37:41-07:00

Oh my gosh.. yeah, that was the problem.. sorry and thanks :shock:

Post Reply