00001 00002 00003 00004 00005 00006 00007 #ifndef SIMPLE_PIXEL_IMAGE_H 00008 #define SIMPLE_PIXEL_IMAGE_H 00009 00010 //########################################################################### 00011 //# DATA TYPES 00012 //########################################################################### 00013 00015 typedef unsigned char PixelType; 00017 typedef PixelType** PixelPlane; 00018 00025 typedef enum _ImageType 00026 { 00027 IMAGE_BW, 00028 IMAGE_RGB, 00029 IMAGE_HSV, 00030 IMAGE_HSL, 00031 //************************************************************************ 00032 //* WARNING: When adding terms to the enumeration 00033 //* keep always this item at the end of the enumeration 00034 //************************************************************************ 00035 IMAGE_TYPES_NUMBER 00036 } 00037 ImageType; 00038 00042 00043 00044 typedef enum _BWImagePlane 00045 { 00046 BW_GREY, 00047 //************************************************************************ 00048 //* WARNING: When adding terms to the enumeration 00049 //* keep always this item at the end of the enumeration 00050 //************************************************************************ 00051 BW_PLANES_NUMBER 00052 } 00053 BWImagePlane; 00054 00055 //Planes for a RGB IMAGE 00056 typedef enum _RGBImagePlane 00057 { 00058 RGB_RED, 00059 RGB_GREEN, 00060 RGB_BLUE, 00061 //************************************************************************ 00062 //* WARNING: When adding terms to the enumeration 00063 //* keep always this item at the end of the enumeration 00064 //************************************************************************ 00065 RGB_PLANES_NUMBER 00066 } 00067 RGBImagePlane; 00068 00069 //??????????? 00070 //?? TO BE DONE: Planes for HUE 00071 //??????????? 00072 00074 00075 //SIMPLE PIXEL IMAGE STRUCTURE DATA TYPE 00076 00089 typedef struct _PixelSize 00090 { 00091 size_t maxLevel; //maximum value a pixel can hold 00092 size_t bits; //size of pixel in bits 00093 size_t bytes; //size of pixel in bytes 00094 } PixelSize; 00095 00096 //************************************************************************************ 00097 //* NOTE: The _SimplePixelImage structure is intended to hold pixels of size 00098 //* sizeof(PixelType) bytes. 00099 //* (The most used is PixelType 00100 //************************************************************************************ 00101 00129 00130 typedef struct _SimplePixelImage 00131 { 00132 PixelSize SinglePixelSize; 00133 unsigned uNumCols; 00134 unsigned uNumRows; 00135 unsigned uPlanesNumber; 00136 ImageType SimplePixelImageType; 00137 PixelPlane *ucPlanesArray; 00138 } 00139 SimplePixelImage; 00140 00141 //############################################################################### 00142 //# ALLOCATE/FREE PixelPlanes and SimplePixelImage functions 00143 //############################################################################### 00144 00147 PixelPlane allocPixelPlane (unsigned uNumrows, unsigned uNumcols); 00148 00156 PixelPlane *allocPixelPlaneArray (SimplePixelImage const &inputImage); 00171 00172 void allocPixelPlanesArrayInSimplePixelImage (SimplePixelImage &inputImage); 00173 00174 void freePixelPlane ( PixelPlane pixelPlaneToFree ); 00175 00176 void freePixelPlanesArray ( PixelPlane *PlanesArray ); //Free a PixelPlaneArray 00177 00178 //Free the PixelPlaneArray stored in inputImage SimplePixelImage 00179 void freePixelPlanesArrayInSimplePixelImage (SimplePixelImage &inputImage); 00180 00181 00182 //############################################################################## 00183 //# OUTPUT/INPUT FILE functions 00184 //############################################################################## 00185 00186 //********************************************************************************** 00187 //* writeSimplePixelImageToPortableMap: Saves the image held in outputImage 00188 //* SimplePixelImage to Portable Map File 00189 //************************************************************************************ 00190 void writeSimplePixelImageToPortableMap(SimplePixelImage const &outputImage, 00191 char const *file_name); 00192 //**************************************************************************************** 00193 //* readPortableMapToSimplePixelImage: Gets a Portable Map image stored in a source_file 00194 //* file and stores it on SimplePixelImage. 00195 //* ALLOCATING the necessary memory for the PixelPlanes 00196 //***************************************************************************************** 00197 00201 00202 void readPortableMapToSimplePixelImage(char const *source_file, SimplePixelImage &inputImage); 00203 00204 //################################################################################### 00205 //# DATA COPYING functions 00206 //################################################################################### 00207 00208 //*********************************************************************************** 00209 //* copySimplePixelImageParameters: Copies all the records of SimplePixelImage 00210 //* sourceImage except the PixelPlanesArray to 00211 //* destinationImage 00212 //*********************************************************************************** 00213 void copySimplePixelImageParameters (SimplePixelImage &destinationImage, 00214 SimplePixelImage const &sourceImage); 00215 00216 //*************************************************************************************** 00217 //* copyPixelPlaneInSimplePixelImage: Copy a pixel plane in the uImagePlane-th 00218 //* simple pixel image plane (begining in the zero-th) 00219 //*************************************************************************************** 00220 void copyPixelPlaneInSimplePixelImage(SimplePixelImage &inputImage, PixelPlane pixelPlane, 00221 unsigned uImagePlane); 00222 00223 //*************************************************************************************** 00224 //* copyPixelPlanesArrayInSimplePixelImage: Copy the first destinationImage.uPlaneNumber 00225 //* planes of sourcePlanesArray are copied 00226 //*************************************************************************************** 00227 void copyPixelPlanesArrayInSimplePixelImage (SimplePixelImage &destinationImage, 00228 PixelPlane *sourcePlanesArray); 00229 00230 //################################################################################# 00231 //# PIXELS PROCESSING functions 00232 //################################################################################## 00233 00234 //**************************************************************************************** 00235 //* drawFrameInSimplePixelImage: Draw a 1-pixel frame of colour frameLevel around an image 00236 //**************************************************************************************** 00237 void drawFrameInSimplePixelImage (SimplePixelImage &image, unsigned long frameLevel); 00238 00239 #endif //SIMPLE_PIXEL_IMAGE_H 00240