Spec:
Magick++: 6.8.5
Qt: 5.0.2
Compiler: MSVC2010
Test Image: 600x600 JPEG
What I want to achieve is load with Magick++ images with various format (i.e. psd), put it in QPixmap and display in window.
Attempt 1:
Code: Select all
Magick::Image image;
try {
image.read(qPrintable(fileName));
}
catch (Magick::Exception &error_) {
QMessageBox::warning(this, "Error!", QString("%1").arg(error_.what()));
return QPixmap();
}
Magick::Blob blob;
image.write(&blob, "XPM");
QPixmap pixmap;
pixmap.loadFromData((char*)blob.data(), "XPM");
return pixmap;
Code: Select all
image.write(&blob, "XPM");
Attempt 2:
Code: Select all
Magick::Image image;
try {
image.read(qPrintable(fileName));
}
catch (Magick::Exception &error_) {
QMessageBox::warning(this, "Error!", QString("%1").arg(error_.what()));
return QPixmap();
}
QImage img(image.columns(), image.rows(), QImage::Format_RGB32);
Magick::ColorRGB rgb;
for (int x = 0; x < img.width(); x++) {
for (int y = 0; y < img.height(); y++) {
rgb = *image.getPixels(x, y, 1, 1);
QColor color(rgb.redQuantum(), rgb.greenQuantum(), rgb.blueQuantum());
img.setPixel(x, y, color.rgb());
}
}
return QPixmap::fromImage(img);
I tested this code also with image 1x1 which had color (R: 183, G: 113, B: 51), but Magick++ returns it as (R: 113, G: 51, B: 51).
Any ideas what are the problem in those attempts?