[Kde-imaging] libksane and returned data

Gilles Caulier caulier.gilles at gmail.com
Fri Nov 23 14:41:46 CET 2007


2007/11/23, Kåre Särs <kare.sars at kolumbus.fi>:
>
> Hi,
>
> I'm just about ready with 16 bit color scanning for libksane. The only
> thing
> to decide now is how to provide the scanned data (this is also a 8bit
> color
> problem).
>
> The problem is that sane returns 3 bytes/pixel for 8 bit color mode (not 4
> bytes as QImage requires)


This is not a problem, QImage support RGA32 mode without alpha channel for 8
bits color depth.

http://doc.trolltech.com/4.3/qimage.html#fromData-2

and 6 bytes/pixel for 16bit color mode.


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:

http://websvn.kde.org/trunk/extragear/libs/kipi-plugins/common/libkipiplugins/kpwriteimage.cpp?revision=737398&view=markup

... and expecially setImageData() method with use QByteArray container for 8
and 16 bits color depth.


> The problem
> is not how to convert the data, but what format the user would want the
> data.



Using a QByteArray  everywhere will be the universal solution. If users want
a QImage (8 bits color depth only), It's trivial to create a QIMage instance
from a QByteArray:

http://doc.trolltech.com/4.3/qimage.html#fromData-2

There is at least two alternatives:
>
> 1) I return the data as is (3 bytes/pixel for 8 bit color and 6
> bytes/pixel
> for 16 bit colors) and provide a function to add the alpha channel or
> return
> a QImage


We don't care about alpha channel. Also QImage with 16bits color depth is
uncompatible. So the QByteArray container will be the utimate and universal
solution


> or
>
> 2) return the data with an added "alpha channel" (4 and 8 bytes / pixel)


No. add a dumy alpha channel will use more memory. If alpha channel do not
exist why you want to add it...

Best

Gilles
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/kde-imaging/attachments/20071123/6c738851/attachment.html 


More information about the Kde-imaging mailing list