Hello, I've written following code:
bool CMerchandizeBrowser
::embeddedPicPath(QImage image,
QString strFilename
) {
picImageWriter.setFormat(strSupportedFormat); // sets supported format
{
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
}
bool CMerchandizeBrowser::embeddedPicPath(QImage image, QString strFilename)
{
QImageWriter picImageWriter; // image key writer
picImageWriter.setFormat(strSupportedFormat); // sets supported format
if (picImageWriter.supportsOption(QImageIOHandler::Description))
{
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
}
To copy to clipboard, switch view to plain text mode
which is responsible to embedd a QImage path into image, but
return image.save(strFilename, strSupportedFormat);
return image.save(strFilename, strSupportedFormat);
To copy to clipboard, switch view to plain text mode
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
) {
picImageWriter.setFormat(strSupportedFormat); // sets supported format
{
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(strNameExtDelimiter), 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
}
bool CMerchandizeBrowser::embeddedPicPath(QImage image, QString strFilename)
{
QImageWriter picImageWriter; // image key writer
picImageWriter.setFormat(strSupportedFormat); // sets supported format
if (picImageWriter.supportsOption(QImageIOHandler::Description))
{
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(strNameExtDelimiter), 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
}
To copy to clipboard, switch view to plain text mode
It works now, thank you all anyway!
Bookmarks