00001 /*****************************************************************************
00002 *
00003 * File : MicrosoftBMP_RT.h
00004 *
00005 * Module : ImageLib.a
00006 *
00007 * Author : Derek Magee, School of Computer Science, Leeds University.
00008 *
00009 * Created : 31 October 1997
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 MicrosoftBMP_RT which deals with reading and writing 24
00029 * bit Microsoft v3 bitmaps.
00030 *
00031 *****************************************************************************
00032 *
00033 * Revision History:
00034 *
00035 * Date By Revision
00036 *
00037 * 31/10/97 DRM Created.
00038 *
00039 ****************************************************************************/
00040
00041 #ifndef MICROSOFTBMP_H
00042 #define MICROSOFTBMP_H
00043
00044
00045 #include <stdio.h>
00046 #include <string.h>
00047
00048 #define IMAGE_DATA_OFFSET 54
00049 #define HEADER_SIZE 40
00050 #define NO_OF_IMAGE_PLANES 1
00051 #define BITS_PER_PIXEL 24
00052 #define COMPRESSION_METHOD 0
00053 #define SIZE_OF_BITMAP 0
00054 #define NO_COLOURS_USED 0
00055 #define NO_SIGNIFICANT_COLS 0
00056
00057 #define MAX_FILENAME_LEN 99
00058
00059 class MicrosoftBMP_RT
00060 {
00061 public:
00062 /*
00063 * This class deals with 24 bit uncompressed Microsoft v3 bitmap files only
00064 * thus the following parameters are constant:
00065 *
00066 * ImageFileType 4D42h ("BM")
00067 * ImageDataOffset 52
00068 *
00069 * HeaderSize 40
00070 * NumberOfImagePlanes 1
00071 * BitsPerPixel 24
00072 * CompressionMethod 0
00073 * SizeOfBitmap 0
00074 * NumColorsUsed 0
00075 * NumSignificantColors 0
00076 *
00077 */
00078
00079 /* Bitmap header Data */
00080
00081 unsigned int FileSize; /* DWORD */
00082
00083 /* Bitmap information header data */
00084
00085 unsigned int ImageWidth; /* DWORD */
00086 unsigned int ImageHeight; /* DWORD */
00087 unsigned int HorizResolution; /* DWORD */
00088 unsigned int VertResolution; /* DWORD */
00089
00090 /* Header items that should be const. For reading in only */
00091
00092 unsigned char type1;
00093 unsigned char type2;
00094 unsigned int reserved;
00095 unsigned int data_off;
00096 unsigned int head_size;
00097 unsigned int no_planes;
00098 unsigned int bits_per_pixel;
00099 unsigned int comp_method;
00100 unsigned int bitmap_size;
00101 unsigned int no_cols;
00102 unsigned int no_sig_cols;
00103
00104 private:
00105 /* Internal stuff */
00106
00107 char file_name[MAX_FILENAME_LEN+1];
00108 FILE *file_pnt;
00109 unsigned char *raw_data;
00110
00111 public:
00112
00113 MicrosoftBMP_RT(const char *filename);
00114 ~MicrosoftBMP_RT();
00115
00116 bool read();
00117 bool write();
00118 void extract_data(int *);
00119 void extract_data_grey(int *);
00120 void put_data(int *);
00121 void put_data_grey(int *);
00122 bool set_size(unsigned int, unsigned int);
00123 void set_filename(const char *);
00124
00125 private:
00126
00127 bool read_byte(unsigned char *);
00128 bool read_word(unsigned int *);
00129 bool read_dword(unsigned int *);
00130 bool write_byte(char);
00131 bool write_word(unsigned int);
00132 bool write_dword(unsigned int);
00133 bool allocate_storage();
00134 void calculate_filesize();
00135 bool check_header_valid();
00136 };
00137
00138 #endif
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001