A repository containing pngdib, which is planned to be incorporated into WinDirStat.
Its original home is over at http://entropymine.com/jason/pngdib/
Rev. | Zeit | Autor | Nachricht |
---|---|---|---|
e91a56f73252 | 2014-01-18 13:26:03 | Oliver Schneider | tip Added tag Version-3.1.0 for changeset fbd43ef03174 |
ab9340d0253f | 2014-01-18 13:25:50 | Oliver Schneider | Added tag Version-3.0.2 for changeset 01ac235d4a64 |
2e684e44dbd3 | 2014-01-18 13:25:40 | Oliver Schneider | Added tag Version-3.0.1 for changeset d318a549c7e1 |
fbd43ef03174 | 2014-01-18 13:25:27 | Oliver Schneider | Version-3.1.0 Version 3.1.0 from ZIP at http://entropymine.com/jason/pn... |
01ac235d4a64 | 2014-01-18 13:24:47 | Oliver Schneider | Version-3.0.2 Version 3.0.2 from ZIP at http://entropymine.com/jason/pn... |
d318a549c7e1 | 2014-01-18 13:23:01 | Oliver Schneider | Version-3.0.1 Version 3.0.1 from ZIP at http://entropymine.com/jason/pn... |
667e755bce23 | 2014-01-18 13:21:42 | Oliver Schneider | Moving in preparation for v3.0.1 |
fc50cede3040 | 2014-01-18 13:19:04 | Oliver Schneider | Renaming in preparation for v3.0.1 |
fa2167302d23 | 2014-01-18 13:18:19 | Oliver Schneider | Added tag Version-2.2.2 for changeset 03757ef47fe3 |
03757ef47fe3 | 2014-01-18 13:17:44 | Oliver Schneider | Version-2.2.2 Version 2.2.2 from ZIP at http://entropymine.com/jason/pn... |
Name | Rev. | Zeit | Autor |
---|---|---|---|
Version-2.2.2 | 03757ef47fe3 | 2014-01-18 13:17:44 | Oliver Schneider |
Version-3.0.1 | d318a549c7e1 | 2014-01-18 13:23:01 | Oliver Schneider |
Version-3.0.2 | 01ac235d4a64 | 2014-01-18 13:24:47 | Oliver Schneider |
Version-3.1.0 | fbd43ef03174 | 2014-01-18 13:25:27 | Oliver Schneider |
tip | e91a56f73252 | 2014-01-18 13:26:03 | Oliver Schneider |
Name | Rev. | Zeit | Autor | Nachricht |
---|---|---|---|---|
default | e91a56f73252 | 2014-01-18 13:26:03 | Oliver Schneider | Added tag Version-3.1.0 for... |
A DIB-PNG conversion library for Win32
By Jason Summers <jason1@pobox.com>
Version 3.1.0, Jul. 2010
Web site: <http://entropymine.com/jason/pngdib/>
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Permission is hereby granted to use, copy, modify, and distribute this source code for any purpose, without fee.
PNGDIB is a library that makes it easy to convert between PNG images and Windows Device Independent Bitmaps (DIBs). PNGDIB is designed to be quick and easy to use, but it does not attempt to support every feature that one might want. If you wish use the PNG format to its full capabilities, you may need to use libpng directly, or write our own extensions to PNGDIB.
When using PNGDIB to read PNG files, it will create version 3.0 DIBs/BMPs. The DIB will be uncompressed, with either 1, 4, 8, or 24 bits-per-pixel.
(Note: A BMP image file is basically just a DIB copied directly from memory, with a 14-byte file header tacked onto the front. The terms DIB and BMP may sometimes be used almost interchangeably.)
When writing PNG files, PNGDIB supports approximately version 3.0 DIBs, and also OS/2-style DIBs. It supports bit depths of 1, 4, 8, 16, 24, and 32 bits-per-pixel. It supports 4 bpp and 8 bpp compressed DIBs (it uses Windows GDI functions to uncompress them).
The library itself currently consists of just two files: pngdib.c and pngdib.h.
Two sample programs, png2bmp.c and bmp2png.c, are included which demonstrate the use of library functions. They can be compiled as "console mode" Win32 applications.
A third sample, "smview", is a bare-bones Windows program that uses pngdib to read and display PNG files. This is intended to demonstrate that it is easy to add PNG support to an application that uses DIBs.
First call pngdib_d2p_init() or pngdib_p2d_init() to create a PNGDIB object. A few functions can accept either type of object, but most only work with one of the two types. Call pngdib_done() when finished.
The code samples below show an overview of the process.
void save_dib_to_png_file(char *png_filename, LPBITMAPINFOHEADER dib, int dib_size) { PNGDIB *pngdib; pngdib = pngdib_d2p_init(); pngdib_d2p_set_dib(pngdib,dib,dib_size,NULL,0); pngdib_d2p_set_png_filename(pngdib,png_filename); pngdib_d2p_run(pngdib); pngdib_done(pngdib); }
void read_png_from_file(char *png_filename) { PNGDIB *pngdib; LPBITMAPINFOHEADER dib; pngdib = pngdib_p2d_init(); pngdib_p2d_set_png_filename(pngdib,png_filename); pngdib_p2d_run(pngdib); pngdib_p2d_get_dib(pngdib,&dib,NULL); pngdib_done(pngdib); /* ... do something with dib ... */ pngdib_p2d_free_dib(NULL,dib); }
Unless otherwise specified, functions that return a value return nonzero on success, and zero on failure.
Note: If you are not using Unicode, "TCHAR" means exactly the same thing as "char".
Some changes I might conceivably make in some future version...
Load a PNG image by selecting File|Open from the menu, or by drag-and-drop from Windows Explorer.
Gamma Correction - Toggles gamma correction. If you turn this off, some images, or parts of images, will look too light or too dark.
Save As PNG - Saves the visible image to a file. This saves the image as it is currently being displayed. The saved image will not have any transparency, and the background color and gamma correction will be applied to the image, not saved as meta-data. This means that you can lose information by loading and then saving a PNG image.
Background colors - You can define a background color that will be used in certain situations. The following logic is used to select a background color: If "Use Image's Background Color" is checked, and the current PNG image file contains a suggested background color, that suggested background color will be used. Otherwise, if "Use Custom Background Color" is checked, your custom background color will be used (by default this is a very light gray color). Otherwise, no background color will be used at all, and transparency information in the image will be completely ignored. Some images will not look very good in this situation. (A default background color – usually white – will be used for the window, but will not be applied to the image.)
Any time you make a change to the gamma or background color settings, the PNG file will be reloaded from disk. That's not the ideal thing to do, but this is just a demo program...