openexr-devel
[Top][All Lists]
Advanced

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

[Openexr-devel] C API calls


From: Thomas Lock
Subject: [Openexr-devel] C API calls
Date: Tue, 18 Jul 2006 23:13:24 -0400

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);
}






reply via email to

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