openexr-devel
[Top][All Lists]
Advanced

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

Re: [Openexr-devel] C API calls


From: Florian Kainz
Subject: Re: [Openexr-devel] C API calls
Date: Wed, 19 Jul 2006 21:05:57 -0700
User-agent: Mozilla Thunderbird 1.0 (X11/20041207)

What does "fail" mean in this case?  Does the application crash?
If it does, have you tried using a debugger to get a stack trace?

Does ImfOpenOutputFile return a null pointer?  If you do get a null
pointer, have you tried calling ImfErrorMessage() to find get some
diagnostic output?  Your example contains no error checking code.
Unlike the C++ interface, the C interface does not throw exceptions;
you must explicitly check the return values of the functions you call.

Thomas Lock wrote:
Hi Drew

             I completely rewrote my code to meet the C API calls. This time
i get zero warnings or errors but the app specifically fails on this call
"file = ImfOpenOutputFile(filenames, header, IMF_WRITE_RGBA );". I tried a
variety of filename options and nothing seems to work. I can't verify if my
remaining code works, but i believe it is correct.

extern "C" void WINAPI writeOpenEXR (char *filename, int width, int height,
float* Bits128)
{
        int LineWidth=width*4;
        float fwidth;
        const char fileName[] = "c:\foo2.exr";
        const char *filenames = "c:\foo2.exr";

        ImfOutputFile *file;
        ImfRgba *base;
        base = (ImfRgba *)malloc(width * height * sizeof(ImfRgba));
        fwidth = (float)width;
        ImfHeader *header;
        header = ImfNewHeader();
        ImfHeaderSetDisplayWindow(header, 0, 0, width - 1, height - 1);
        ImfHeaderSetDataWindow(header, 0, 0, width - 1, height - 1);
        ImfHeaderSetScreenWindowWidth(header, fwidth);
        file = ImfOpenOutputFile(filenames, header, IMF_WRITE_RGBA );

        ImfDeleteHeader(header);

        for(int h=0;h<height;h++)for(int b=0;b<width;b++)
       {
            ImfHalf half;

            int i=h*LineWidth+(b<<2);
            int j=h*LineWidth+b;

            ImfFloatToHalf(Bits128[i], &half);
            base[j].b = half;

            ImfFloatToHalf(Bits128[i + 1], &half);
            base[j].g = half;

            ImfFloatToHalf(Bits128[i + 2], &half);
            base[j].r = half;

            ImfFloatToHalf(Bits128[i + 3], &half);
            base[j].a = half;
        }

        ImfOutputSetFrameBuffer( file, base, 1, width );
        ImfOutputWritePixels(file, height );
        ImfCloseOutputFile(file);

        free(base);
}




_______________________________________________
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]