Česky
Kamil Dudka

GED 2006 (C++)

File detail

Name:Downloadpngimage.h [Download]
Location: ged2006 > src
Size:1.4 KB
Last modification:2022-09-09 13:06

Source code

/*
 * File: pngimage.h - Module loading/saving PNG images
 * Project: GED - bitmap editor (ICP)
 * Author: Jakbub Filak, xfilak01
 * Team: xdudka00, xfilak01, xhefka00, xhradi08
 * Created: 2006-03-10
 */
 
#ifndef PNGIMAGE_H
#define PNGIMAGE_H
 
#include <string>
#include <png.h>
#include "image.h"
 
/**
 * Class loading/saving PNG images.
 */
class PNGImage: public Image {
public:
	/**
	 * Create new png image.
	 * \param size New image size.
	 */
	PNGImage (const BoxSize &size);
 
	/**
	 * Create new png image opening png image file.
	 * This method throws Image::ErrLoad exception if can't open image.
	 * \param fileName PNG image file name.
	 */
	PNGImage (const std::string &fileName);
 
	/**
	 * Create PNGImage object from base class Image.
	 * Default png image properties are used.
	 */
	PNGImage (const Image &img);
	virtual ~PNGImage();
 
	/**
	 * Save png image to file.
	 * This method throw Image::ErrSave exception if can't save image.
	 * \param fileName File name to save with.
	 */
	virtual void save (const std::string &fileName);
 
private:		
	static const int _png_sig_num_bytes = 4;		///< how many bytes are used for sig png file
	png_structp _png_read;					///< pointer to png structure
	png_infop _info;					///< pointer to info png structure
	int _n_of_passes;					///< number of passes
	int _color_type;					///< original color type
	void createPNGInfo();					///< for creating structures
	void initPNGInfo();					///< init new info structures
};
 
#endif