openexr-devel
[Top][All Lists]
Advanced

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

Re: [Openexr-devel] OpenEXR from shared libs.


From: Nikolaj Thygesen
Subject: Re: [Openexr-devel] OpenEXR from shared libs.
Date: Tue, 27 Feb 2007 23:51:51 +0100
User-agent: Thunderbird 1.5.0.9 (X11/20070128)

Hi,

I realize my example was badly and incompletely reproduced. The slightly modified version incorporating your suggested changes follows below.

           RgbaInputFile input_file;
           Box2i dw = input_file.dataWindow();
           Rgba pixels[width];
            while (dw.min.y <= dw.max.y)
             {
           input_file.setFrameBuffer(pixels - dw.min.x, 1, 0);
           input_file.readPixels(dw.min.y);
           dw.min.y++;
             }

Unfortunately even after implementing your fixes my shared lib still crashes in readPixels() during the first scanline :o( In fact this is what I get:

pure virtual method called
terminate called without an active exception
Abort trap: 6 (core dumped)


What you write makes much sense to me. I just can't make it fit with the example from section 2.5 of the OpenEXR document, in which they read a partial image, and do this calculation for every block:

Array2D<Rgba> pixels (10, width);
while (dw.min.y <= dw.max.y)
{
file.setFrameBuffer (&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width);
file.readPixels (dw.min.y, min (dw.min.y + 9, dw.max.y));
 dw.min.y += 10;
}

To me "&pixels[0][0] - dw.min.x - dw.min.y * width" looks like you need to offset the scanline from the origo of the virtual complete frame buffer?! I suspect that perhaps the zero byte row stride saves us in your example - no?

    Best regards - Nikolaj

Florian Kainz wrote:
Hi Nicolaj,

I am not entirely sure how to interpret your example.  I assume that your
program contains a loop to read all the scan lines in a given file, but I
am not sure which of the code in your example is meant to be included in
the loop; it does make a difference.  Let's say your code is analogous to
this:

    RgbaInputFile input_file;

    Box2i dw = input_file.dataWindow();
    Rgba pixels[width];
    input_file.setFrameBuffer(pixels - dw.min.x - dw.min.y * width, 1, width);

    while (dw.min.y <= dw.max.dy)
    {
        input_file.readPixels(dw.min.y);
        dw.min.y++;
    }

If this is the case, then frame buffer address arithmetic is wrong.
No matter which scan line you are reading, you want the leftmost pixel,
t x coordinate, dw.min.x to be stored in pixels[0].  The pixels at x
coordinates dw.min.x+1, dw.min.x+2, etc. should to to pixels[1], pixels[2],
etc.  In other words, the address of pixel (x,y) is:

    pixels - dw.min.x + x

Here's the corresponding setFrameBuffer() call (see also section 2.2 of
the Reading and Writing OpenEXR Image Files document):

    input_file.setFrameBuffer (pixels - dw.min.x, 1, 0);

Hope this helps,

Florian



Nikolaj Thygesen wrote:
Hi list,

   I'm currently trying to interface to the OpenEXR library from my own shared library reading scanlines one at a time. My code is heavily based on the sample code on the OpenEXR home page describing the reading of an RGBA file using the RgbaInputFile class + a raw copy-paste of the C_IStream class using the old-skool stdio FILE *'s to access the bytes of files. When compiling my program as a stand-alone program, everything works fine for all sample *.exr files, but as soon as the code goes into a *.so, reading crashes in the "input_file.readPixels(dw.min.y);" call of the snippet below.

   I should mention that I'm running FreeBSD 6.2, using gcc 4.1and OpenEXR V1.2.2, which is the release currently available in the ports tree. My question is: Does OpenEXR have any issues with shared libs?? Do I need or should I avoid any certain compiler/linker flags??

           RgbaInputFile input_file;

           Box2i dw = input_file.dataWindow();
           Rgba pixels[width];
           input_file.setFrameBuffer(pixels - dw.min.x - dw.min.y * width, 1, width);
           input_file.readPixels(dw.min.y);
           dw.min.y++;
           lineno = line_number++;



   br - Nikolaj Thygesen





_______________________________________________
Openexr-devel mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/openexr-devel





reply via email to

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