Error writing cineon files?

Moe Goldberg <[email protected]> Thu, 02 Oct 2008 16:37:52 -0400
Newsgroups gmane.comp.video.graphicsmagick.bugs
Message-ID <[email protected]>
Hi,

I'm using graphics magick to write cineon files and I'm not getting the 
values that I expect.
When I write a file and then read it back, I am getting different values 
that what I wrote (or at least tried to write).
(I have compiled GraphicsMagick with 16 bit Quanutm depth)


I have included a quick sample. I create a 100x100 solid colour image, 
and I write it to file, then I open it back up and read the first pixel. 
Am I doing something wrong? If so, what?

/////// CODE START
#include <iostream>
#include <Magick++.h>

const MagickLib::PixelPacket* cin_test()
{
    unsigned bitDepth = 10;
    unsigned i_count = 100;
    unsigned j_count = 100;

    unsigned char* myBuffer = new unsigned char[80000];
    
    Magick::Image myImg;
    myImg.type(Magick::TrueColorType);
    myImg.size(Magick::Geometry(i_count, j_count));
    myImg.read(i_count, j_count, "RGB", Magick::ShortPixel, myBuffer);
    myImg.depth(bitDepth);
    
    for (unsigned j=0; j<j_count; ++j)
    {
        MagickLib::PixelPacket* pp = myImg.setPixels(0, j, i_count, 1);
        for (unsigned i=0; i<i_count; ++i)
        {
            MagickLib::PixelPacket& ppref = pp[i];
            
            ppref.red = 65472;
            ppref.green = 6080;
            ppref.blue = 43840;
            ppref.opacity = 0;
        }
    }

    myImg.write("test.cin");

    // open the file back up to make sure I'm getting the expected result
    Magick::Image im("test.cin");
    return im.getConstPixels(0, 0, 1, 1);

}


int main(int argc, char *argv[])
{
    const MagickLib::PixelPacket* pp = cin_test();
    std::cout << pp->red << " " << pp->green << " " << pp->blue << 
std::endl;
}
/////// CODE END


I get the following result:

43776 24832 40512

which is clearly different than the

65472 6080 43840

that I expect



Thanks in advance!
-Moe

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/