PDA

View Full Version : [SOLVED] QImage problem - adding/reading path of image with key/text [SOLVED]



MarkoSan
14th December 2007, 01:33
Hello, I've written following code:
bool CMerchandizeBrowser::embeddedPicPath(QImage image, QString strFilename)
{
QImageWriter picImageWriter; // image key writer

picImageWriter.setFormat(strSupportedFormat); // sets supported format
if (picImageWriter.supportsOption(QImageIOHandler::De scription))
{
qDebug() << strSupportedFormat << " supports embedded text.";
if (image.text(strKeyImagePathName).isEmpty())
{
// pic path has not yet been saved
image.setText(strKeyImagePathName, strFilename); // sets embedded text
return image.save(strFilename, strSupportedFormat); // saves pic with embedded text
} else {
return false; // path already embedded, abort operation
}
} else {
qDebug() << strSupportedFormat << " does not support embedded text.";
return false; // operation failure
}
return false; // operation failure
}which is responsible to embedd a QImage path into image, but
return image.save(strFilename, strSupportedFormat); returns false. Does anyone has idea why?

Now I thought the chenged picture cannot be written into same filename and I've changed code to:
bool CMerchandizeBrowser::embeddedPicPath(QImage image, QString strFilename)
{
QImageWriter picImageWriter; // image key writer

picImageWriter.setFormat(strSupportedFormat); // sets supported format
if (picImageWriter.supportsOption(QImageIOHandler::De scription))
{
qDebug() << strSupportedFormat << " supports embedded text.";
if (image.text(strKeyImagePathName).isEmpty())
{
// pic path has not yet been saved
image.setText(strKeyImagePathName, strFilename); // sets embedded text
strFilename.insert(strFilename.indexOf(strNameExtD elimiter), strFilenameEmbeddedExtendtor);
qDebug() << "strFilename: " << strFilename; // debug
return image.save(strFilename, strSupportedFormat); // saves pic with embedded text
} else {
return false; // path already embedded, abort operation
}
} else {
qDebug() << strSupportedFormat << " does not support embedded text.";
return false; // operation failure
}
//return true; // operation sucess
}It works now, thank you all anyway!