Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

MicrosoftRCBMP_RT.h

00001 /*****************************************************************************
00002  *
00003  * File :       MicrosoftRCBMP_RT.h
00004  *
00005  * Module :     ImageLib.a
00006  *
00007  * Author :     Derek Magee, School of Computer Science, Leeds University.
00008  *
00009  * Created :    3 November 1998
00010  *
00011  *****************************************************************************
00012  *
00013  * Source code for Image Library MkII
00014  *
00015  * The author, Derek Magee, gives permission for this code to be copied,
00016  * modified and distributed within the University of Leeds subject to the
00017  * following conditions:-
00018  *
00019  * - The code is not to be used for commercial gain.
00020  * - The code and use thereof will be attributed to the author where
00021  *   appropriate (inluding demonstrations which rely on it's use).
00022  * - All modified, distributions of the source files will retain this header.
00023  *
00024  *****************************************************************************
00025  *
00026  * Description:
00027  *
00028  * Header file for class MicrosoftRCBMP_RT which deals with reading 
00029  * reduced colour Microsoft v3 bitmaps.
00030  *
00031  *****************************************************************************
00032  *
00033  * Revision History:
00034  *
00035  * Date         By              Revision
00036  *
00037  * 3/11/98      DRM             Created.
00038  *
00039  ****************************************************************************/
00040 
00041 #ifndef MICROSOFTRCBMP_H
00042 #define MICROSOFTRCBMP_H
00043 
00044 
00045 #include <stdio.h>
00046 #include <string.h>
00047 
00048 #define IMAGE_DATA_OFFSET_R    (54+256*4) 
00049 #define HEADER_SIZE_R          40
00050 #define NO_OF_IMAGE_PLANES_R   1
00051 #define BITS_PER_PIXEL_R       8 
00052 #define COMPRESSION_METHOD_R   0
00053 #define SIZE_OF_BITMAP_R       0
00054 #define NO_COLOURS_USED_R      0
00055 #define NO_SIGNIFICANT_COLS_R  0
00056 
00057 #if 0
00058 #define PALETTE0_R           0
00059 #define PALETTE0_G           0
00060 #define PALETTE0_B           0
00061 #define PALETTE1_R           255
00062 #define PALETTE1_G           255
00063 #define PALETTE1_B           255
00064 #endif
00065 
00066 #define MAX_FILENAME_LEN     99
00067 
00068 struct rgb{
00069            unsigned char red ;
00070            unsigned char green ;
00071            unsigned char blue ;
00072 };
00073 
00074 class MicrosoftRCBMP_RT 
00075 {
00076 public:
00077 /* 
00078  * This class deals with 24 bit uncompressed Microsoft v3 bitmap files only
00079  * thus the following parameters are constant:
00080  * 
00081  * ImageFileType         4D42h ("BM")
00082  * ImageDataOffset       52
00083  *
00084  * HeaderSize            40
00085  * NumberOfImagePlanes   1
00086  * BitsPerPixel          24
00087  * CompressionMethod     0
00088  * SizeOfBitmap          0
00089  * NumColorsUsed         0
00090  * NumSignificantColors  0
00091  * 
00092  */
00093 
00094     /* Bitmap header Data */
00095 
00096     unsigned int FileSize;              /* DWORD */
00097 
00098     /* Bitmap information header data */
00099 
00100     unsigned int ImageWidth;            /* DWORD */
00101     unsigned int ImageHeight;           /* DWORD */
00102     unsigned int HorizResolution;       /* DWORD */
00103     unsigned int VertResolution;        /* DWORD */
00104     rgb          *palette;
00105 
00106     /* Header items that should be const. For reading in only */
00107 
00108     char type1;
00109     char type2;
00110     unsigned int  reserved;
00111     unsigned int  data_off;
00112     unsigned int  head_size;
00113     unsigned int  no_planes;
00114     unsigned int  bits_per_pixel;
00115     unsigned int  comp_method;
00116     unsigned int  bitmap_size;
00117     unsigned int  no_cols;
00118     unsigned int  no_sig_cols;
00119 
00120 private:
00121     /* Internal stuff */
00122 
00123     char          file_name[MAX_FILENAME_LEN+1];
00124     FILE          *file_pnt;
00125     unsigned char *raw_data;
00126  
00127 public:
00128           
00129     MicrosoftRCBMP_RT(const char *);
00130     ~MicrosoftRCBMP_RT();
00131 
00132     bool                read();
00133     bool                write();
00134     void                extract_data(int *);
00135     void                extract_data_grey(int *);
00136     void                put_data(int*) ;
00137     void                put_data_grey(int*) ;
00138     bool                set_size(unsigned int, unsigned int);
00139     bool                set_palette_grey256() ;
00140 
00141 private:
00142 
00143     void                set_filename(const char *);
00144     bool                read_byte(char *);
00145     bool                read_word(unsigned int *);
00146     bool                read_dword(unsigned int *);
00147     bool                write_byte(char);
00148     bool                write_word(unsigned int);
00149     bool                write_dword(unsigned int);
00150     bool                allocate_storage();
00151     void                calculate_filesize();
00152     bool                check_header_valid();
00153     unsigned char       palette_lookup(int*) ;
00154 };
00155 
00156 #endif

Generated on Tue Jan 24 11:58:57 2006 for VETLib by  doxygen 1.4.4