<br><br><div><span class="gmail_quote">2007/11/23, Kåre Särs &lt;<a href="mailto:kare.sars@kolumbus.fi">kare.sars@kolumbus.fi</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I&#39;m just about ready with 16 bit color scanning for libksane. The only thing<br>to decide now is how to provide the scanned data (this is also a 8bit color<br>problem).<br><br>The problem is that sane returns 3 bytes/pixel for 8 bit color mode (not 4
<br>bytes as QImage requires) </blockquote><div><br>This is not a problem, QImage support RGA32 mode without alpha channel for 8 bits color depth.<br><br><a href="http://doc.trolltech.com/4.3/qimage.html#fromData-2">http://doc.trolltech.com/4.3/qimage.html#fromData-2
</a><br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">and 6 bytes/pixel for 16bit color mode. </blockquote><div><br>You cannot use QImage here. You must use a QByteArray container to host all raw image data in RGA. Look how my KPWriteImage class work in this case:
<br><br><a href="http://websvn.kde.org/trunk/extragear/libs/kipi-plugins/common/libkipiplugins/kpwriteimage.cpp?revision=737398&amp;view=markup">http://websvn.kde.org/trunk/extragear/libs/kipi-plugins/common/libkipiplugins/kpwriteimage.cpp?revision=737398&amp;view=markup
</a><br><br>... and expecially setImageData() method with use QByteArray container for 8 and 16 bits color depth.<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The problem<br>is not how to convert the data, but what format the user would want the data.</blockquote><div><br><br>Using a QByteArray&nbsp; everywhere will be the universal solution. If users want a QImage (8 bits color depth only), It&#39;s trivial to create a QIMage instance from a QByteArray:
<br><br><a href="http://doc.trolltech.com/4.3/qimage.html#fromData-2">http://doc.trolltech.com/4.3/qimage.html#fromData-2</a><br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
There is at least two alternatives:<br><br>1) I return the data as is (3 bytes/pixel for 8 bit color and 6 bytes/pixel<br>for 16 bit colors) and provide a function to add the alpha channel or return<br>a QImage</blockquote>
<div><br>We don&#39;t care about alpha channel. Also QImage with 16bits color depth is uncompatible. So the QByteArray container will be the utimate and universal solution<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
or<br><br>2) return the data with an added &quot;alpha channel&quot; (4 and 8 bytes / pixel)</blockquote><div><br>No. add a dumy alpha channel will use more memory. If alpha channel do not exist why you want to add it...<br>
&nbsp;</div></div>Best<br><br>Gilles<br>