[Qt-interest] 16-bit grayscale images

Andreas Steinel A.Steinel+qt at googlemail.com
Mon Apr 27 00:54:12 CEST 2009


Hi Judy,

I recently programed a simple wrapper for that purpose. It works straight
forward if you inherit QImage. Afterwards, you can easily use your class
with the normal QT stuff, if you 'flush' the raw data, to the real image
stored in the inherited QImage class.

I achieve this by using something like this for writing back the data (if
the QImage is already set up correctly: size, bit-format, depth, etc.). The
method is called explicitly before a QImage action with a raw-image.


    uchar *pixeldata = bits();

    unsigned int pos = 0, pos4 = 0;
    for (unsigned int y=0; y < h; y++)
        for(unsigned int x=0; x < w; x++)
        {
            // current position
            pos  = x + y*w;
            pos4 = pos << 2;

            // alpha is stores at pixeldata[pos4]
            // you can do your tone-mapping here.
            pixeldata[pos4 + 2 ] = (uchar) red(x,y);
            pixeldata[pos4 + 1 ] = (uchar) green(x,y);
            pixeldata[pos4 + 0 ] = (uchar) blue(x,y);
        }

Best regards,
Andreas

On Sun, Apr 26, 2009 at 7:50 PM, Judy Duncan <jduncan at duncanimaging.com>wrote:

>  I need to manipulate and display 16-bit grayscale images in an
> application… something fairly common with scientific data.  I have been
> studying QImage, QPixMap, and other graphics support in Qt and am not
> finding (or perhaps just not recognizing) what I need.  None of the
> supported image formats I see in the documentation will support high-bit
> depth, single channel images.
>
>
>
> Displaying high-bit depth data is always sticky because you have to settle
> on some mapping of the high-depth data to the (usually 8-bit) depth of the
> screen.  Based on what I’ve seen in the docs I’m thinking I may have to
> create my own data buffer and then map the pixels into an 8-bit grayscale
> image.  Any suggestions, or easiest Qt approach for doing this?  As an
> alternative, does anyone recommend a particular 3rd party plug-in? I’m
> hesitant to go the 3rd party direction due to deadlines and the risks of
> an unknown package – but if it comes with recommendations, it could save
> some time.
>
>
>
> Thanks in advance to all you incredibly helpful people…
>
>
>
> Judy
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090427/eae582f8/attachment.html 


More information about the Qt-interest-old mailing list