RSX
28th April 2013, 15:33
Hi, I have some problems using Magick++ with Qt. It's almost working, but almost in this case is not acceptable.
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;
This code does it's thing, but...
image.write(&blob, "XPM");
takes 4 seconds, and the displayed image looks like lost some of it's quality.
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);
There's no noticeable delay now when loading image, but displayed image has wrong colors (gets blue-ish kinda).
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).
The problems might be more Magick++ related, but perhaps someone knows what's wrong or has managed to load image in other way without problems?
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;
This code does it's thing, but...
image.write(&blob, "XPM");
takes 4 seconds, and the displayed image looks like lost some of it's quality.
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);
There's no noticeable delay now when loading image, but displayed image has wrong colors (gets blue-ish kinda).
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).
The problems might be more Magick++ related, but perhaps someone knows what's wrong or has managed to load image in other way without problems?