Getting a bunch of pixels leads me to segmentation fault...
Posted: 2017-04-20T15:14:51-07:00
This simple code:
gives me segmentation fault. What do I do wrong here? It works only if I use const:
but I need to modify some of those pixels so it shouldn't be const in my case. What's wrong with my code?
ImageMagick 7.0.5-2 Q16 x86_64 2017-03-11
Code: Select all
Magick::Image *imagePtr = new Magick::Image( "images/horse.jpg" );
Magick::Pixels view( *imagePtr );
Magick::Quantum *pixels = view.get( 0, 0, imagePtr->columns(), imagePtr->rows() );
unsigned int r = 255 * QuantumScale * ( *( pixels + 0 ) );
Code: Select all
const Magick::Quantum *pixels = view.getConst( 0, 0, imagePtr->columns(), imagePtr->rows() );
unsigned int r = 255 * QuantumScale * ( *( pixels + 0 ) );
ImageMagick 7.0.5-2 Q16 x86_64 2017-03-11