Handling 16 bpp tiff file in C++ - c++

I need to open 16 bpp grayscale tiff image in C++ program. Trying to do this with GDI+ Image class, I get OutOfMemoryException (GDI+ doesn't support 16 bpp format). Standard Windows tools, like Paint and Picture Viewer, cannot open such image, possibly they use GDI or GDI+. ImageJ program opens such image successfully.
Is there some SDK which can open such images and give access to image raw data? If not, I need TIFF file specification, and implement this in my own code.

Use LibTIFF.

Related

JPG or JPEG Texture in OPENGL

In OpenGL you could read a BMP file and use it as texture.
I know how to read a BMP file in OPENGL.
I just want to know if is it the same thing with JPG or JPEG files? is OpenGL support those files?
OpenGL does not support BMP files. It just cares about raw image date as one-, two or threedimensional arrays of pixel data with up to 4 channels (and a set of different data types). OpenGL does not even know what a file is. And it can't load anything. If you need JPEG files, you have to load them via other means, like libjpeg or some higher level image loading libraries or some of the other image loading libraries.

Importing and looping through a PNG image to check for transparency

I would like to write CPP code that is able to take in a PNG file, scan through its pixels and identify where the transparent pixels are.
I tried doing this with CIMG, but it didn't work out as CIMG only supports the RGB channels. Even after installing image magick, the 4th channel is not giving me the right values.
Anyone can suggest a library I could use?

How can I draw a png ontop of another png?

How can I "draw"\"merge" a png top of another png (background) using libpng, while keeping the alpha section of the png being drawn on top of the backhround png. There does not seem to be any tutorials or anything mentioned in the documentation about it.
libpng is a library for loading images stored in the PNG file format. It is not a library for blitting images, compositing images, or anything of that nature. libpng's basic job is to take a file or memory image and turn it into an array of color values. What you're talking about is very much out of scope for libpng.
If you want to do this, you will have to do the image composition yourself manually. Or use a library that can do image composition (cairo, etc).

GetDIBits() is failing with PNG compression

I am trying to get the size of PNG image (Without storing into file). I am using this code as reference. When calling GetDIBits(), size of image would get updated into bi.biSizeImage. Everything works fine when bi.biCompression is BI_RGB. Then I have changed the compression mode from BI_RGB to BI_PNG; GetDIBits() started to fail. Please help me to solve this.
According to http://msdn.microsoft.com/en-us/library/dd145023%28VS.85%29.aspx:
"This extension is not intended as a means to supply general JPEG and PNG decompression to applications, but rather to allow applications to send JPEG- and PNG-compressed images directly to printers having hardware support for JPEG and PNG images."
using GetDIBits() with BI_PNG is not allowed.

Is there any sample code to read thumbnail from Jpeg exif header?

I am writing application using c++, in windows.
I want to get a thumbnail from jpeg, without decoding the whole image.
How Can I read thumbnail from jpeg exif header?
Can any one offer me a some sample code?
Many thanks!
Unsurprisingly the library is called libexif has win32 port, and there is sample code for reading thubnail from file
Don't bother. You can create tumbnails very fast from JPEGs. They are compressed using DCTs on 8x8 pixel blocks. So, get the DC component (i.e. 0,0) of each block and you have an 1/64th thumbnail without decoding. Further scaling should be fast since there are hardly any pixels left.