You are not logged in.

#1 2010-06-05 04:18:45

tony5429
Member
Registered: 2006-03-28
Posts: 1,017

Is there a Better Way to do This? (C++, Qt)

Inside a Qt application I'm using ImageMagick to create an image (from variable text) on-the-fly and save it to the hard drive. Then right afterwards I'm telling Qt to load that image in an object (called currQorA). I know it would be more efficient to skip the hard-drive-writing part and pipe the output of ImageMagick directly to the Qt object. I just don't know how to do it. Here's my code as it currently stands,

sprintf(str, "convert -gravity Center -background transparent -pointsize 12 -size 500x caption:'%s' /var/tmp/text.png", variable_string);
system(str);
currQorA->setIcon(QIcon(QPixmap("/var/tmp/text.png").scaled(500, 200, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
currQorA->setIconSize(QSize(500, 200));

Does anyone know how to pipe the ImageMagick image directly into the button (without writing to a file on the HDD first)? Thanks!

Offline

#2 2010-06-05 09:30:04

draugdel
Member
Registered: 2008-08-12
Posts: 44

Re: Is there a Better Way to do This? (C++, Qt)

Two things I found with a quick google search:

http://www.imagemagick.org/Magick++/
http://lists.trolltech.com/qt-interest/ … 394-0.html

The second post describes the opposite way: QPixmap -> Image, you need Image -> QPixmap. But that shouldn´t be that much more difficult.

€: Should have read the third thing I opened:

http://studio.imagemagick.org/pipermail … 21250.html

both conversions

Last edited by draugdel (2010-06-05 09:33:44)

Offline

Board footer

Powered by FluxBB