mbed code for Farrari board
Dependencies: DDRO_Farrari mbed
Fork of DDRO_Farrari by
EasyBMP.h
00001 /************************************************* 00002 * * 00003 * EasyBMP Cross-Platform Windows Bitmap Library * 00004 * * 00005 * Author: Paul Macklin * 00006 * email: macklin01@users.sourceforge.net * 00007 * support: http://easybmp.sourceforge.net * 00008 * * 00009 * file: EasyBMP.h * 00010 * date added: 01-31-2005 * 00011 * date modified: 12-01-2006 * 00012 * version: 1.06 * 00013 * * 00014 * License: BSD (revised/modified) * 00015 * Copyright: 2005-6 by the EasyBMP Project * 00016 * * 00017 * description: Main include file * 00018 * * 00019 *************************************************/ 00020 00021 //#include <iostream> 00022 #include <cmath> 00023 #include <cctype> 00024 #include <cstring> 00025 00026 #include "mbed.h" 00027 00028 #ifndef EasyBMP 00029 #define EasyBMP 00030 //static LocalFileSystem local("local"); 00031 00032 #include "pinout.h" 00033 00034 #include <cstdio> 00035 00036 00037 #ifndef _DefaultXPelsPerMeter_ 00038 #define _DefaultXPelsPerMeter_ 00039 #define DefaultXPelsPerMeter 3780 00040 // set to a default of 96 dpi 00041 #endif 00042 00043 #ifndef _DefaultYPelsPerMeter_ 00044 #define _DefaultYPelsPerMeter_ 00045 #define DefaultYPelsPerMeter 3780 00046 // set to a default of 96 dpi 00047 #endif 00048 00049 00050 int IntPow( int base, int exponent ); 00051 int ceildiv(int n, int d); 00052 00053 #ifndef _EasyBMP_Defined_WINGDI 00054 #define _EasyBMP_Defined_WINGDI 00055 typedef unsigned char ebmpBYTE; 00056 typedef unsigned short ebmpWORD; 00057 typedef unsigned int ebmpDWORD; 00058 #endif 00059 00060 #ifndef _EasyBMP_DataStructures_h_ 00061 #define _EasyBMP_DataStructures_h_ 00062 00063 00064 // it's easier to use a struct than a class 00065 // because we can read/write all four of the bytes 00066 // at once (as we can count on them being continuous 00067 // in memory 00068 00069 typedef struct RGBApixel { 00070 ebmpBYTE Blue; 00071 ebmpBYTE Green; 00072 ebmpBYTE Red; 00073 ebmpBYTE Alpha; 00074 } RGBApixel; 00075 00076 class BMFH{ 00077 public: 00078 ebmpWORD bfType; 00079 ebmpDWORD bfSize; 00080 ebmpWORD bfReserved1; 00081 ebmpWORD bfReserved2; 00082 ebmpDWORD bfOffBits; 00083 00084 BMFH(); 00085 }; 00086 00087 class BMIH{ 00088 public: 00089 ebmpDWORD biSize; 00090 ebmpDWORD biWidth; 00091 ebmpDWORD biHeight; 00092 ebmpWORD biPlanes; 00093 ebmpWORD biBitCount; 00094 ebmpDWORD biCompression; 00095 ebmpDWORD biSizeImage; 00096 ebmpDWORD biXPelsPerMeter; 00097 ebmpDWORD biYPelsPerMeter; 00098 ebmpDWORD biClrUsed; 00099 ebmpDWORD biClrImportant; 00100 00101 BMIH(); 00102 }; 00103 00104 #endif 00105 00106 #ifndef _EasyBMP_BMP_h_ 00107 #define _EasyBMP_BMP_h_ 00108 00109 00110 bool SafeFread( char* buffer, int size, int number, FILE* fp ); 00111 bool EasyBMPcheckDataSize( void ); 00112 00113 class BMP 00114 {private: 00115 00116 char BitDepth; 00117 short Width; 00118 short Height; 00119 00120 RGBApixel* Colors; 00121 short XPelsPerMeter; 00122 short YPelsPerMeter; 00123 00124 ebmpBYTE* MetaData1; 00125 short SizeOfMetaData1; 00126 ebmpBYTE* MetaData2; 00127 short SizeOfMetaData2; 00128 00129 bool Read1bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); 00130 bool Write4bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); 00131 00132 public: 00133 00134 unsigned int** PixelsBW; 00135 unsigned int** PixelsR; 00136 00137 int TellBitDepth( void ); 00138 int TellWidth( void ); 00139 int TellHeight( void ); 00140 int TellNumberOfColors( void ); 00141 00142 BMP(); 00143 ~BMP(); 00144 00145 unsigned char GetPixel( int i, int j ) const; 00146 bool SetPixel( int i, int j); 00147 00148 bool CreateStandardColorTable( void ); 00149 00150 bool SetSize( int NewWidth, int NewHeight ); 00151 bool SetBitDepth( int NewDepth ); 00152 bool WriteToFile( const char* FileName ); 00153 bool ReadFromFile( const char* FileName ); 00154 00155 }; 00156 00157 #endif 00158 00159 00160 #endif
Generated on Wed Jul 27 2022 00:15:18 by
1.7.2
