Re: Problem with reading raw 16bit RGB data

Bob Friesenhahn <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.help
Message-ID <[email protected]>
On Mon, 9 Nov 2015, Manuel Koch wrote:

> I try to extract 16bit image from RAW camera image [1] using libraw.
>
> The output of libraw is described as 16bit plain bitmap of RGB values.
> See http://www.libraw.org/docs/API-CXX-eng.html#dcraw_make_mem_image.
>
> Somehow I’m unable to create an Magick::Image() instance of this extracted 16bit RGB bitmap data using the following code :
>
> // „image“ is a structure returned from libraw containing the data of the extracted image
> Magick::Blob blob( image->data, image->data_size ); // „data_size“ is 61011696
> Magick::Image img;
> img.size( Magick::Geometry(image->width,image->height) ); // „width“ is 3908, „height“ is 2602
> img.depth( image->bits ); // „bits“ is 16
> img.magick( "RGB" );
> img.read( blob );
>
> After read() the call to isValid() returns true.
> Saving this image to a file succeeds, but results in unrecognizable image waste !?

Since these are 16-bit values, the bytes in each value could be stored 
in big-endian or little-endian format.  GraphicsMagick likely defaults 
to big-endian.  If the data is in little-endian format (like x86 
Intel), then you should add a request for LSBEndian endianness.

For example

   img.endian(LSBEndian);

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140

_______________________________________________
Graphicsmagick-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.