openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Openexr-devel] Invert lines during reading process ?


From: Florian Kainz
Subject: Re: [Openexr-devel] Invert lines during reading process ?
Date: Mon, 05 Dec 2005 13:36:57 -0800
User-agent: Mozilla Thunderbird 1.0 (X11/20041207)

Hi Gernot,

in order to load an image "upside down" you'd have to set
your frame buffer's yStride to a negative value, but since
yStride is of type size_t, which is unsigned, you can't
do that.

However, there is a workaround: unsigned integer arithmetic
is usually implemented such that results are computed modulo
(1<<b), where b is the number of bits in an unsigned integer.
If n is positive and of type size_t, you can effectively set
yStride to -n like this:

    yStride = (~(size_t(0)) - n + 1);

If x is of type size_t, and x >= n, then computing x + yStride
yields x - n.

Florian


Gernot Ziegler wrote:
Hej !

OpenGL convention requires me to upload images upside down into the
texture data buffer, that is, I need to read the EXR image from the bottom
up - is there a way to do this more efficiently than to read the lines one
by one (the headers lineorder attribute is only changeable for writing
files, correct ?) ?

If only the line-by-line reading remains:
Should I maybe y-flip the data in main memory instead ? (Main memory is
not an issue :-) )

Servus,
  Gernot





reply via email to

[Prev in Thread] Current Thread [Next in Thread]