Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I read JPEG and PNG pixels in C++ on Linux?

Tags:

I'm doing some image processing, and I'd like to individually read each pixel value in a JPEG and PNG images.

In my deployment scenario, it would be awkward for me to use a 3rd party library (as I have restricted access on the target computer), but I'm assuming that there's no standard C or C++ library for reading JPEG/PNG...

So, if you know of a way of not using a library then great, if not then answers are still welcome!

like image 755
Nick Bolton Avatar asked Mar 29 '09 03:03

Nick Bolton


People also ask

How many pixels is a PNG?

The standard allows indexed color PNGs to have 1, 2, 4 or 8 bits per pixel; grayscale images with no alpha channel may have 1, 2, 4, 8 or 16 bits per pixel. Everything else uses a bit depth per channel of either 8 or 16.

Is PNG pixels per inch?

PNG stores resolution internally as pixels per meter, so when calculating back to pixels per inch, some programs may show excessive decimal digits, perhaps 299.999 ppi instead of 300 ppi (no big deal).


1 Answers

There is no standard library in the C-standard to read the file-formats.

However, most programs, especially on the linux platform use the same library to decode the image-formats:

For jpeg it's libjpeg, for png it's libpng.

The chances that the libs are already installed is very high.

http://www.libpng.org

http://www.ijg.org

like image 170
Nils Pipenbrinck Avatar answered Oct 02 '22 14:10

Nils Pipenbrinck