On Thu, Jul 14, 2011 at 10:18 AM, Larry Gritz <[email protected]> wrote:

> That is still fairly inefficient -- I bet that there's a way to set an entire 
> scanline (or image) at once, without having to call setPixel separately for 
> every pixel, that's going to be very slow.  Also, you are allocating 'pixels' 
> on every scanline, which will make quite a memory leak.
>

QImage::QImage ( uchar * data, int width, int height, Format format )

This form of teh constructor lets you basically create your own buffer
for an image, and then "wrap" it in a QImage for use in Qt.  Qt
doesn't really believe in images that are too large to display
(because it is basically a GUI toolkit) so it doesn't tend to have
things like "per scanline" functionality.  If you build your image in
memory yourself, and then pass it to that constructor as the "data"
pointer, it will probably be faster than doing a function call on
every pixel.  You just have to be responsible for the buffer, so
delete it when you delete a QImage that wraps it, etc.


> Now, back to the meat of your question.  The way your code is structured, 
> you're reading the OpenEXR file (which is inherently floating point, either 
> full or half precision, with 1.0 meaning "white") and converting it into 
> UINT8 (8 bit unsigned integer, 255 means white) in read_scanline, then 
> copying those values back to r, g, b, which are float -- copying without any 
> rescaling -- and passing those to qRgb.
>
> So here's an important question: does qRgb expect those floating-point values 
> to be in the 0.0-1.0 range?  Or 0.0-255.0?  You're passing the latter right 
> now.  I'll try to give a solution both ways.

qRgb, IIRC, expects ints from 0-255.  (I don't know anyone who
considers this to be the most obvious way to do it)  Here is the
prototype:
QRgb qRgb ( int r, int g, int b )
where QRgb is "An ARGB quadruplet on the format #AARRGGBB, equivalent
to an unsigned int."


Hopefully, that helps clarify some of the Qt half of this for folks
following the thread.
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to