[Magick-bugs] Magick++ Image constructor bug
mbritton at astro.caltech.edu
mbritton at astro.caltech.edu
Thu May 28 17:07:15 PDT 2009
Hello:
I'm having difficulty with the Magick::Image constructor under Windows
library v 6.5.2.Q16. The constructor is
Magick::Image(const unsigned int width_,
const unsigned int height_,
std::string map_,
const StorageType type_,
const void *pixels_);
The constructor appears to prepend some garbage characters onto map_,
which causes the routine ImportImagePixels to throw an error. Example and
output appear below.
I would appreciate a simple workaround, if at all possible.
Sincerely yours
Matthew Britton
#######################
##################
# Source code: #
##################
#include <iostream>
#include <Magick++.h>
int main() {
unsigned int n = 128;
char * c = new char[n*n];
try {
std::string s("RGB");
Magick::Image img(n, n, s, Magick::CharPixel, c);
} catch(Magick::Exception & error) {
std::cout << "caught Magick++ exception: "
<< error.what() << std::endl;
}
try {
std::string s("R");
Magick::Image img(n, n, s, Magick::CharPixel, c);
} catch(Magick::Exception & error) {
std::cout << "caught Magick++ exception: "
<< error.what() << std::endl;
}
try {
std::string s("G");
Magick::Image img(n, n, s, Magick::CharPixel, c);
} catch(Magick::Exception & error) {
std::cout << "caught Magick++ exception: "
<< error.what() << std::endl;
}
try {
std::string s("B");
Magick::Image img(n, n, s, Magick::CharPixel, c);
} catch(Magick::Exception & error) {
std::cout << "caught Magick++ exception: "
<< error.what() << std::endl;
}
}
#############
# Output: #
#############
caught Magick++ exception: ImageMagick: unrecognized pixel map
`����RGB' @ pixel.c/ImportImagePixels/1815
caught Magick++ exception: ImageMagick: unrecognized pixel map
`����R' @ pixel.c/ImportImagePixels/1815
caught Magick++ exception: ImageMagick: unrecognized pixel map
`����G' @ pixel.c/ImportImagePixels/1815
caught Magick++ exception: ImageMagick: unrecognized pixel map
`����B' @ pixel.c/ImportImagePixels/1815
More information about the Magick-bugs
mailing list