IvfBmpImage.h

00001 //
00002 // Copyright 1999-2003 by John Aspras
00003 //
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Library General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later version.
00008 //
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Library General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Library General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00017 // USA.
00018 //
00019 // Please report all bugs and problems to "ivf@byggmek.lth.se".
00020 //
00021 //
00022 // Written by John Aspras
00023 //
00024 
00025 #ifndef _CIvfBmpImage_h_
00026 #define _CIvfBmpImage_h_
00027 
00028 #include <ivfimage/IvfFileImage.h>
00029 
00030 IvfSmartPointer(CIvfBmpImage);
00031 
00038 class IVFEXT_API CIvfBmpImage : public CIvfFileImage {
00039 private:
00040         bool m_alphaChannel;
00041         unsigned char *imageData;
00042     int width_ret;
00043     int height_ret;
00044     int numComponents_ret;
00045 
00046 
00047 
00048 struct bmpheader {
00049     short FileType; //always MB
00050     short siz[2]; // a dword for whole file size
00051     short Reserved1, Reserved2; //reserved for future purposes
00052     short offset[2]; //offset to image in bytes
00053 };
00054 
00055 struct BMPInfo {
00056     long width;   //width of the image in pixels
00057     long height;    //   height of the image in pixels
00058     short planes;       //:word: number of planes (always 1)
00059     short Colorbits;       //word: number of bits used to describe color in each pixel
00060     long compression;  //compression used
00061     long ImageSize;    //image size in bytes
00062     long XpixPerMeter; //pixels per meter in X
00063     long YpixPerMeter; //pixels per meter in Y
00064     long ColorUsed;   //number of colors used
00065     long Important;   //number of "important" colors
00066     long os2stuff[6]; // allows os2.1 with 64 bytes to be read.  Dont know what these are yet.
00067 };
00068 
00069 /* byte order workarounds *sigh* */
00070 void swapbyte(long *i);
00071 void swapbyte(unsigned long *i);
00072 void swapbyte(float *i);
00073 void swapbyte(unsigned short *i);
00074 void swapbyte(short *i);
00075 
00076 unsigned char * bmp_load(const char *filename,
00077                          int *width_ret,
00078                          int *height_ret,
00079                          int *numComponents_ret);
00080 
00081 public:
00083         CIvfBmpImage();
00084 
00086         CIvfBmpImage(const char* name);
00087 
00089         virtual ~CIvfBmpImage();
00090 
00091         IvfClassInfo("CIvfBmpImage",CIvfFileImage);
00092 
00094         virtual bool read();
00095 
00102         void setAlphaChannel(bool flag);
00103 };
00104 
00105 #endif

Generated on Fri Sep 1 15:36:46 2006 for Interactive Visualisation Framework - Ivf++ by  doxygen 1.4.6-NO