PDA

View Full Version : loadFromData failed for DPX which is loaded using Imagemagick



ankireddy
9th January 2012, 07:03
Hi,

I created an application to load images. To support many formats i used ImageMagick. I wrote the following code to read images



void OpenImage(QString path)
{
magickImage.read(path.toStdString());
magickImage.write(&blob);

cimgData=((const uchar*)(blob.data()));

if(pxmap.loadFromData(cimgData,blob.length())==fal se)
QMessageBox::information(this,"ImageView","Failed to LoadFromData");

update();




void WImageView::paintEvent(QPaintEvent *event)
{

QPainter p(this);

p.drawPixmap(0,0,pxmap.width(),pxmap.height(),pxma p);
}

The above code is working for TIF, JPEG, PNG etc. but not working for DPX, CIN, TGA, jp2 (Motion JPG).

For these images "loadFromData" returns false.

Can you please help me how to convert the dpx data to QPixmap?

Thanks in advance
anki.n

ChrisW67
9th January 2012, 07:20
QPixmap has a range of formats it knows about. The ones it knows about work directly. You can construct a QImage from raw data in a number of formats, and you can convert a QImage to a QPixmap.

Use ImageMagick to convert the foreign formats to ones that Qt can handle.