<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Writing QImage into a buffer always returns error]]></title><description><![CDATA[<p dir="auto">Hi,<br />
I tried to write a QImage into buffer as follows,<br />
@<br />
bool MainWindow::somefunction(QImage &amp;image)<br />
{<br />
QByteArray bytes;<br />
QBuffer buffer(&amp;bytes);</p>
<pre><code>buffer.open(QIODevice::WriteOnly);

if(image.save(&amp;buffer, "JPG"))
{
    qDebug() &lt;&lt; "Error in writing to buffer";
    ui-&gt;imgLabel-&gt;setPixmap(QPixmap::fromImage(image)); // A test write, and it displays correctly in imgLabel
    buffer.close();
    return false;
}
buffer.close();
return true;
</code></pre>
<p dir="auto">}<br />
@<br />
The image contained in QImage is verified using a write to imgLabel, but the above code always retuns error</p>
]]></description><link>https://forum.qt.io/topic/24613/writing-qimage-into-a-buffer-always-returns-error</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 22:09:37 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/24613.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Feb 2013 15:38:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Writing QImage into a buffer always returns error on Mon, 25 Feb 2013 16:29:06 GMT]]></title><description><![CDATA[<p dir="auto">Thank you, I missed the not sign</p>
]]></description><link>https://forum.qt.io/post/168416</link><guid isPermaLink="true">https://forum.qt.io/post/168416</guid><dc:creator><![CDATA[ras123]]></dc:creator><pubDate>Mon, 25 Feb 2013 16:29:06 GMT</pubDate></item><item><title><![CDATA[Reply to Writing QImage into a buffer always returns error on Mon, 25 Feb 2013 16:23:10 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="ras123" date="1361806714"]<br />
@<br />
if(image.save(&amp;buffer, "JPG"))<br />
{<br />
qDebug() &lt;&lt; "Error in writing to buffer";<br />
@<br />
[/quote]That displays an error message when you succeed :)</p>
]]></description><link>https://forum.qt.io/post/168414</link><guid isPermaLink="true">https://forum.qt.io/post/168414</guid><dc:creator><![CDATA[JKSH]]></dc:creator><pubDate>Mon, 25 Feb 2013 16:23:10 GMT</pubDate></item></channel></rss>