Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

image.h

Go to the documentation of this file.
00001 /*********************************************************************
00002 * lescegra                                                           *
00003 *                                                                    *
00004 * http://geeky.kicks-ass.org/projects/lescegra.html                  *
00005 *                                                                    *
00006 * Copyright 2003 by Enno Cramer <uebergeek@web.de>                   *
00007 *                                                                    *
00008 * This library is free software; you can redistribute it and/or      *
00009 * modify it under the terms of the GNU Library General Public        *
00010 * License as published by the Free Software Foundation; either       *
00011 * version 2 of the License, or (at your option) any later version.   *
00012 *                                                                    *
00013 * This library is distributed in the hope that it will be useful,    *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  *
00016 * Library General Public License for more details.                   *
00017 *                                                                    *
00018 * You should have received a copy of the GNU Library General Public  *
00019 * License along with this library; if not, write to the Free         *
00020 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
00021 *********************************************************************/
00022 
00023 #ifndef LSG_IMAGE_H
00024 #define LSG_IMAGE_H 1
00025 
00026 #include <lescegra/util/object.h>
00027 
00028 /**
00029  * \file  image.h
00030  * \brief Bitmap
00031  */
00032 
00033 #define IMAGE_GRAYSCALE 1
00034 #define IMAGE_RGB       3
00035 #define IMAGE_RGBA      4
00036 
00037 /**
00038  * \brief Bitmap
00039  *
00040  * A bitmap with a variable number of color channels.
00041  * Every channel has a resolution of 8 bit per pixel.
00042  */
00043 typedef struct {
00044     LsgObject super;
00045     int width;
00046     int height;
00047     int bpp;
00048     unsigned char* data;
00049 } LsgImage;
00050 
00051 /**
00052  * \relates LsgImage
00053  * Allocate and initialize an image with the given resolution and number
00054  * of channels.
00055  * @param width     The width of the bitmap
00056  * @param height    The height of the bitmap
00057  * @param bpp       The number of channels
00058  * @return An image with the given width, height and number of channels
00059  */
00060 LsgImage* LsgImage_create(int width, int height, int bpp);
00061 
00062 /**
00063  * \relates LsgImage
00064  * Constructor for LsgImage. Allocate a pixel buffer of the given dimension
00065  * and resolution.
00066  * @param self      The instance variable
00067  * @param width     The image width in pixel
00068  * @param height    The image height in pixel
00069  * @param bpp       The image resolution in byte per pixel (number of color channels)
00070  */
00071 void LsgImage_init(LsgImage* self, int width, int height, int bpp);
00072 
00073 /**
00074  * \relates LsgImage
00075  * Mirror the image horizontally.
00076  * @param self      The instance variable
00077  */
00078 void LsgImage_mirrorX(LsgImage* self);
00079 
00080 /**
00081  * \relates LsgImage
00082  * Mirror the image vertically.
00083  * @param self      The instance variable
00084  */
00085 void LsgImage_mirrorY(LsgImage* self);
00086 
00087 /**
00088  * \relates LsgImage
00089  * Destructor for LsgImage. Free the allocated pixel buffer.
00090  * @param self      The instance variable
00091  */
00092 void LsgImage_destroy(LsgImage* self);
00093 
00094 /**
00095  * \relates LsgImage
00096  * Load an image stored in any of the supported image formats (currently
00097  * PCX and TGA). The apropriate loader is determined from the filename.
00098  * @param filename  The name of the image file to load
00099  * @return The bitmap stored  in the file referenced by filename
00100  */
00101 LsgImage* LsgImage_load(const char* filename);
00102 
00103 /**
00104  * \relates LsgImage
00105  * Load an image stored in PCX format.
00106  * @param filename  The name of the PCX file
00107  * @return The bitmap stored in the file referenced by filename
00108  */
00109 LsgImage* LsgImage_loadPCX(const char* filename);
00110 
00111 /**
00112  * \relates LsgImage
00113  * Load an image stored in TGA format. Supported are Indexed and True Color 
00114  * images, either uncompressed or RLE encoded.
00115  * @param filename  The name of the TGA file
00116  * @return The bitmap stored in the file referenced by filename
00117  */
00118 LsgImage* LsgImage_loadTGA(const char* filename);
00119 
00120 #endif

(c) 2003, by Enno Cramer
generated on 13 Jul 2003
lescegra - doxygen