From 044ad7c3987460ede48ff27afd6bdb0ca05a0432 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 4 Jul 2011 20:52:54 +0200 Subject: import at91lib from at91lib_20100901_softpack_1_9_v_1_0_svn_v15011 it's sad to see that atmel doesn't publish their svn repo or has a centralized location or even puts proper version/release info into the library itself --- .../lib/EasyBMP/BSD_(revised)_license.txt | 10 + .../pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.cpp | 1917 ++++++++++++++++++++ .../pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.h | 86 + .../CreateDemoBin/lib/EasyBMP/EasyBMP_BMP.h | 86 + .../lib/EasyBMP/EasyBMP_ChangeLog.txt | 821 +++++++++ .../lib/EasyBMP/EasyBMP_DataStructures.h | 104 ++ .../lib/EasyBMP/EasyBMP_VariousBMPutilities.h | 53 + .../lib/EasyBMP/sample/EasyBMPbackground.bmp | Bin 0 -> 308278 bytes .../lib/EasyBMP/sample/EasyBMPsample.cpp | 82 + .../lib/EasyBMP/sample/EasyBMPtext.bmp | Bin 0 -> 113266 bytes .../CreateDemoBin/lib/EasyBMP/sample/makefile | 53 + .../demo-fw/pc-tools/CreateDemoBin/lib/libregex.a | Bin 0 -> 182428 bytes 12 files changed, 3212 insertions(+) create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/BSD_(revised)_license.txt create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.cpp create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.h create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_BMP.h create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_ChangeLog.txt create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_DataStructures.h create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_VariousBMPutilities.h create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPbackground.bmp create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPsample.cpp create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPtext.bmp create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/makefile create mode 100644 utility/demo-fw/pc-tools/CreateDemoBin/lib/libregex.a (limited to 'utility/demo-fw/pc-tools/CreateDemoBin/lib') diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/BSD_(revised)_license.txt b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/BSD_(revised)_license.txt new file mode 100644 index 0000000..6785262 --- /dev/null +++ b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/BSD_(revised)_license.txt @@ -0,0 +1,10 @@ +Copyright (c) 2005, The EasyBMP Project (http://easybmp.sourceforge.net) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.cpp b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.cpp new file mode 100644 index 0000000..07d33ef --- /dev/null +++ b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.cpp @@ -0,0 +1,1917 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMP.cpp * +* date added: 03-31-2006 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Actual source file * +* * +*************************************************/ + +#include "EasyBMP.h" + +/* These functions are defined in EasyBMP.h */ + +bool EasyBMPwarnings = true; + +void SetEasyBMPwarningsOff( void ) +{ EasyBMPwarnings = false; } +void SetEasyBMPwarningsOn( void ) +{ EasyBMPwarnings = true; } +bool GetEasyBMPwarningState( void ) +{ return EasyBMPwarnings; } + +/* These functions are defined in EasyBMP_DataStructures.h */ + +int IntPow( int base, int exponent ) +{ + int i; + int output = 1; + for( i=0 ; i < exponent ; i++ ) + { output *= base; } + return output; +} + +BMFH::BMFH() +{ + bfType = 19778; + bfReserved1 = 0; + bfReserved2 = 0; +} + +void BMFH::SwitchEndianess( void ) +{ + bfType = FlipWORD( bfType ); + bfSize = FlipDWORD( bfSize ); + bfReserved1 = FlipWORD( bfReserved1 ); + bfReserved2 = FlipWORD( bfReserved2 ); + bfOffBits = FlipDWORD( bfOffBits ); + return; +} + +BMIH::BMIH() +{ + biPlanes = 1; + biCompression = 0; + biXPelsPerMeter = DefaultXPelsPerMeter; + biYPelsPerMeter = DefaultYPelsPerMeter; + biClrUsed = 0; + biClrImportant = 0; +} + +void BMIH::SwitchEndianess( void ) +{ + biSize = FlipDWORD( biSize ); + biWidth = FlipDWORD( biWidth ); + biHeight = FlipDWORD( biHeight ); + biPlanes = FlipWORD( biPlanes ); + biBitCount = FlipWORD( biBitCount ); + biCompression = FlipDWORD( biCompression ); + biSizeImage = FlipDWORD( biSizeImage ); + biXPelsPerMeter = FlipDWORD( biXPelsPerMeter ); + biYPelsPerMeter = FlipDWORD( biYPelsPerMeter ); + biClrUsed = FlipDWORD( biClrUsed ); + biClrImportant = FlipDWORD( biClrImportant ); + return; +} + +void BMIH::display( void ) +{ + using namespace std; + cout << "biSize: " << (int) biSize << endl + << "biWidth: " << (int) biWidth << endl + << "biHeight: " << (int) biHeight << endl + << "biPlanes: " << (int) biPlanes << endl + << "biBitCount: " << (int) biBitCount << endl + << "biCompression: " << (int) biCompression << endl + << "biSizeImage: " << (int) biSizeImage << endl + << "biXPelsPerMeter: " << (int) biXPelsPerMeter << endl + << "biYPelsPerMeter: " << (int) biYPelsPerMeter << endl + << "biClrUsed: " << (int) biClrUsed << endl + << "biClrImportant: " << (int) biClrImportant << endl << endl; +} + +void BMFH::display( void ) +{ + using namespace std; + cout << "bfType: " << (int) bfType << endl + << "bfSize: " << (int) bfSize << endl + << "bfReserved1: " << (int) bfReserved1 << endl + << "bfReserved2: " << (int) bfReserved2 << endl + << "bfOffBits: " << (int) bfOffBits << endl << endl; +} + +/* These functions are defined in EasyBMP_BMP.h */ + +RGBApixel BMP::GetPixel( int i, int j ) const +{ + using namespace std; + bool Warn = false; + if( i >= Width ) + { i = Width-1; Warn = true; } + if( i < 0 ) + { i = 0; Warn = true; } + if( j >= Height ) + { j = Height-1; Warn = true; } + if( j < 0 ) + { j = 0; Warn = true; } + if( Warn && EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Attempted to access non-existent pixel;" << endl + << " Truncating request to fit in the range [0," + << Width-1 << "] x [0," << Height-1 << "]." << endl; + } + return Pixels[i][j]; +} + +bool BMP::SetPixel( int i, int j, RGBApixel NewPixel ) +{ + Pixels[i][j] = NewPixel; + return true; +} + + +bool BMP::SetColor( int ColorNumber , RGBApixel NewColor ) +{ + using namespace std; + if( BitDepth != 1 && BitDepth != 4 && BitDepth != 8 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Attempted to change color table for a BMP object" << endl + << " that lacks a color table. Ignoring request." << endl; + } + return false; + } + if( !Colors ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Attempted to set a color, but the color table" << endl + << " is not defined. Ignoring request." << endl; + } + return false; + } + if( ColorNumber >= TellNumberOfColors() ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Requested color number " + << ColorNumber << " is outside the allowed" << endl + << " range [0," << TellNumberOfColors()-1 + << "]. Ignoring request to set this color." << endl; + } + return false; + } + Colors[ColorNumber] = NewColor; + return true; +} + +// RGBApixel BMP::GetColor( int ColorNumber ) const +RGBApixel BMP::GetColor( int ColorNumber ) +{ + RGBApixel Output; + Output.Red = 255; + Output.Green = 255; + Output.Blue = 255; + Output.Alpha = 0; + + using namespace std; + if( BitDepth != 1 && BitDepth != 4 && BitDepth != 8 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Attempted to access color table for a BMP object" << endl + << " that lacks a color table. Ignoring request." << endl; + } + return Output; + } + if( !Colors ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Requested a color, but the color table" << endl + << " is not defined. Ignoring request." << endl; + } + return Output; + } + if( ColorNumber >= TellNumberOfColors() ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Requested color number " + << ColorNumber << " is outside the allowed" << endl + << " range [0," << TellNumberOfColors()-1 + << "]. Ignoring request to get this color." << endl; + } + return Output; + } + Output = Colors[ColorNumber]; + return Output; +} + +BMP::BMP() +{ + Width = 1; + Height = 1; + BitDepth = 24; + Pixels = new RGBApixel* [Width]; + Pixels[0] = new RGBApixel [Height]; + Colors = NULL; + + XPelsPerMeter = 0; + YPelsPerMeter = 0; + + MetaData1 = NULL; + SizeOfMetaData1 = 0; + MetaData2 = NULL; + SizeOfMetaData2 = 0; +} + +// BMP::BMP( const BMP& Input ) +BMP::BMP( BMP& Input ) +{ + // first, make the image empty. + + Width = 1; + Height = 1; + BitDepth = 24; + Pixels = new RGBApixel* [Width]; + Pixels[0] = new RGBApixel [Height]; + Colors = NULL; + XPelsPerMeter = 0; + YPelsPerMeter = 0; + + MetaData1 = NULL; + SizeOfMetaData1 = 0; + MetaData2 = NULL; + SizeOfMetaData2 = 0; + + // now, set the correct bit depth + + SetBitDepth( Input.TellBitDepth() ); + + // set the correct pixel size + + SetSize( Input.TellWidth() , Input.TellHeight() ); + + // set the DPI information from Input + + SetDPI( Input.TellHorizontalDPI() , Input.TellVerticalDPI() ); + + // if there is a color table, get all the colors + + if( BitDepth == 1 || BitDepth == 4 || + BitDepth == 8 ) + { + for( int k=0 ; k < TellNumberOfColors() ; k++ ) + { + SetColor( k, Input.GetColor( k )); + } + } + + // get all the pixels + + for( int j=0; j < Height ; j++ ) + { + for( int i=0; i < Width ; i++ ) + { + Pixels[i][j] = *Input(i,j); +// Pixels[i][j] = Input.GetPixel(i,j); // *Input(i,j); + } + } +} + +BMP::~BMP() +{ + int i; + for(i=0;i= Width ) + { i = Width-1; Warn = true; } + if( i < 0 ) + { i = 0; Warn = true; } + if( j >= Height ) + { j = Height-1; Warn = true; } + if( j < 0 ) + { j = 0; Warn = true; } + if( Warn && EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Attempted to access non-existent pixel;" << endl + << " Truncating request to fit in the range [0," + << Width-1 << "] x [0," << Height-1 << "]." << endl; + } + return &(Pixels[i][j]); +} + +// int BMP::TellBitDepth( void ) const +int BMP::TellBitDepth( void ) +{ return BitDepth; } + +// int BMP::TellHeight( void ) const +int BMP::TellHeight( void ) +{ return Height; } + +// int BMP::TellWidth( void ) const +int BMP::TellWidth( void ) +{ return Width; } + +// int BMP::TellNumberOfColors( void ) const +int BMP::TellNumberOfColors( void ) +{ + int output = IntPow( 2, BitDepth ); + if( BitDepth == 32 ) + { output = IntPow( 2, 24 ); } + return output; +} + +bool BMP::SetBitDepth( int NewDepth ) +{ + using namespace std; + if( NewDepth != 1 && NewDepth != 4 && + NewDepth != 8 && NewDepth != 16 && + NewDepth != 24 && NewDepth != 32 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: User attempted to set unsupported bit depth " + << NewDepth << "." << endl + << " Bit depth remains unchanged at " + << BitDepth << "." << endl; + } + return false; + } + + BitDepth = NewDepth; + if( Colors ) + { delete [] Colors; } + int NumberOfColors = IntPow( 2, BitDepth ); + if( BitDepth == 1 || BitDepth == 4 || BitDepth == 8 ) + { Colors = new RGBApixel [NumberOfColors]; } + else + { Colors = NULL; } + if( BitDepth == 1 || BitDepth == 4 || BitDepth == 8 ) + { CreateStandardColorTable(); } + + return true; +} + +bool BMP::SetSize(int NewWidth , int NewHeight ) +{ + using namespace std; + if( NewWidth <= 0 || NewHeight <= 0 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: User attempted to set a non-positive width or height." << endl + << " Size remains unchanged at " + << Width << " x " << Height << "." << endl; + } + return false; + } + + int i,j; + + for(i=0;i -1 ) + { + bool Success = false; + if( BitDepth == 32 ) + { Success = Write32bitRow( Buffer, BufferSize, j ); } + if( BitDepth == 24 ) + { Success = Write24bitRow( Buffer, BufferSize, j ); } + if( BitDepth == 8 ) + { Success = Write8bitRow( Buffer, BufferSize, j ); } + if( BitDepth == 4 ) + { Success = Write4bitRow( Buffer, BufferSize, j ); } + if( BitDepth == 1 ) + { Success = Write1bitRow( Buffer, BufferSize, j ); } + if( Success ) + { + int BytesWritten = (int) fwrite( (char*) Buffer, 1, BufferSize, fp ); + if( BytesWritten != BufferSize ) + { Success = false; } + } + if( !Success ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: Could not write proper amount of data." << endl; + } + j = -1; + } + j--; + } + + delete [] Buffer; + } + + if( BitDepth == 16 ) + { + // write the bit masks + + ebmpWORD BlueMask = 31; // bits 12-16 + ebmpWORD GreenMask = 2016; // bits 6-11 + ebmpWORD RedMask = 63488; // bits 1-5 + ebmpWORD ZeroWORD; + + if( IsBigEndian() ) + { RedMask = FlipWORD( RedMask ); } + fwrite( (char*) &RedMask , 2 , 1 , fp ); + fwrite( (char*) &ZeroWORD , 2 , 1 , fp ); + + if( IsBigEndian() ) + { GreenMask = FlipWORD( GreenMask ); } + fwrite( (char*) &GreenMask , 2 , 1 , fp ); + fwrite( (char*) &ZeroWORD , 2 , 1 , fp ); + + if( IsBigEndian() ) + { BlueMask = FlipWORD( BlueMask ); } + fwrite( (char*) &BlueMask , 2 , 1 , fp ); + fwrite( (char*) &ZeroWORD , 2 , 1 , fp ); + + int DataBytes = Width*2; + int PaddingBytes = ( 4 - DataBytes % 4 ) % 4; + + // write the actual pixels + + for( j=Height-1 ; j >= 0 ; j-- ) + //int WriteNumber; + //for(j=0, WriteNumber=0; j < Height; ++j) + { + // write all row pixel data + i=0; + int WriteNumber = 0; + while( WriteNumber < DataBytes ) + //for(i = 0; i 3, then something strange is going on + // it's probably an OS2 bitmap file. + + if( bmih.biCompression > 3 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: " << FileName << " is in an unsupported format." + << endl + << " (bmih.biCompression = " + << bmih.biCompression << ")" << endl + << " The file is probably an old OS2 bitmap or corrupted." + << endl; + } + SetSize(1,1); + SetBitDepth(1); + fclose(fp); + return false; + } + + if( bmih.biCompression == 3 && bmih.biBitCount != 16 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: " << FileName + << " uses bit fields and is not a" << endl + << " 16-bit file. This is not supported." << endl; + } + SetSize(1,1); + SetBitDepth(1); + fclose(fp); + return false; + } + + // set the bit depth + + int TempBitDepth = (int) bmih.biBitCount; + if( TempBitDepth != 1 && TempBitDepth != 4 + && TempBitDepth != 8 && TempBitDepth != 16 + && TempBitDepth != 24 && TempBitDepth != 32 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: " << FileName << " has unrecognized bit depth." << endl; + } + SetSize(1,1); + SetBitDepth(1); + fclose(fp); + return false; + } + SetBitDepth( (int) bmih.biBitCount ); + + // set the size + + if( (int) bmih.biWidth <= 0 || (int) bmih.biHeight <= 0 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: " << FileName + << " has a non-positive width or height." << endl; + } + SetSize(1,1); + SetBitDepth(1); + fclose(fp); + return false; + } + SetSize( (int) bmih.biWidth , (int) bmih.biHeight ); + + // some preliminaries + + double dBytesPerPixel = ( (double) BitDepth ) / 8.0; + double dBytesPerRow = dBytesPerPixel * (Width+0.0); + dBytesPerRow = ceil(dBytesPerRow); + + int BytePaddingPerRow = 4 - ( (int) (dBytesPerRow) )% 4; + if( BytePaddingPerRow == 4 ) + { BytePaddingPerRow = 0; } + + // if < 16 bits, read the palette + + if( BitDepth < 16 ) + { + // determine the number of colors specified in the + // color table + + int NumberOfColorsToRead = ((int) bmfh.bfOffBits - 54 )/4; + if( NumberOfColorsToRead > IntPow(2,BitDepth) ) + { NumberOfColorsToRead = IntPow(2,BitDepth); } + + if( NumberOfColorsToRead < TellNumberOfColors() ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: file " << FileName << " has an underspecified" << endl + << " color table. The table will be padded with extra" << endl + << " white (255,255,255,0) entries." << endl; + } + } + + int n; + for( n=0; n < NumberOfColorsToRead ; n++ ) + { + SafeFread( (char*) &(Colors[n]) , 4 , 1 , fp); + } + for( n=NumberOfColorsToRead ; n < TellNumberOfColors() ; n++ ) + { + RGBApixel WHITE; + WHITE.Red = 255; + WHITE.Green = 255; + WHITE.Blue = 255; + WHITE.Alpha = 0; + SetColor( n , WHITE ); + } + + + } + + // skip blank data if bfOffBits so indicates + + int BytesToSkip = bmfh.bfOffBits - 54;; + if( BitDepth < 16 ) + { BytesToSkip -= 4*IntPow(2,BitDepth); } + if( BitDepth == 16 && bmih.biCompression == 3 ) + { BytesToSkip -= 3*4; } + if( BytesToSkip < 0 ) + { BytesToSkip = 0; } + if( BytesToSkip > 0 && BitDepth != 16 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Extra meta data detected in file " << FileName << endl + << " Data will be skipped." << endl; + } + ebmpBYTE* TempSkipBYTE; + TempSkipBYTE = new ebmpBYTE [BytesToSkip]; + SafeFread( (char*) TempSkipBYTE , BytesToSkip , 1 , fp); + delete [] TempSkipBYTE; + } + + // This code reads 1, 4, 8, 24, and 32-bpp files + // with a more-efficient buffered technique. + + int i,j; + if( BitDepth != 16 ) + { + int BufferSize = (int) ( (Width*BitDepth) / 8.0 ); + while( 8*BufferSize < Width*BitDepth ) + { BufferSize++; } + while( BufferSize % 4 ) + { BufferSize++; } + ebmpBYTE* Buffer; + Buffer = new ebmpBYTE [BufferSize]; + j= Height-1; + while( j > -1 ) + { + int BytesRead = (int) fread( (char*) Buffer, 1, BufferSize, fp ); + if( BytesRead < BufferSize ) + { + j = -1; + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: Could not read proper amount of data." << endl; + } + } + else + { + bool Success = false; + if( BitDepth == 1 ) + { Success = Read1bitRow( Buffer, BufferSize, j ); } + if( BitDepth == 4 ) + { Success = Read4bitRow( Buffer, BufferSize, j ); } + if( BitDepth == 8 ) + { Success = Read8bitRow( Buffer, BufferSize, j ); } + if( BitDepth == 24 ) + { Success = Read24bitRow( Buffer, BufferSize, j ); } + if( BitDepth == 32 ) + { Success = Read32bitRow( Buffer, BufferSize, j ); } + if( !Success ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: Could not read enough pixel data!" << endl; + } + j = -1; + } + } + j--; + } + delete [] Buffer; + } + + if( BitDepth == 16 ) + { + int DataBytes = Width*2; + int PaddingBytes = ( 4 - DataBytes % 4 ) % 4; + + // set the default mask + + ebmpWORD BlueMask = 31; // bits 12-16 + ebmpWORD GreenMask = 992; // bits 7-11 + ebmpWORD RedMask = 31744; // bits 2-6 + + // read the bit fields, if necessary, to + // override the default 5-5-5 mask + + if( bmih.biCompression != 0 ) + { + // read the three bit masks + + ebmpWORD TempMaskWORD; + ebmpWORD ZeroWORD=0; + + SafeFread( (char*) &RedMask , 2 , 1 , fp ); + if( IsBigEndian() ) + { RedMask = FlipWORD(RedMask); } + SafeFread( (char*) &TempMaskWORD , 2, 1, fp ); + + SafeFread( (char*) &GreenMask , 2 , 1 , fp ); + if( IsBigEndian() ) + { GreenMask = FlipWORD(GreenMask); } + SafeFread( (char*) &TempMaskWORD , 2, 1, fp ); + + SafeFread( (char*) &BlueMask , 2 , 1 , fp ); + if( IsBigEndian() ) + { BlueMask = FlipWORD(BlueMask); } + SafeFread( (char*) &TempMaskWORD , 2, 1, fp ); + } + + // read and skip any meta data + + if( BytesToSkip > 0 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Extra meta data detected in file " + << FileName << endl + << " Data will be skipped." << endl; + } + ebmpBYTE* TempSkipBYTE; + TempSkipBYTE = new ebmpBYTE [BytesToSkip]; + SafeFread( (char*) TempSkipBYTE , BytesToSkip , 1 , fp); + delete [] TempSkipBYTE; + } + + // determine the red, green and blue shifts + + int GreenShift = 0; + ebmpWORD TempShiftWORD = GreenMask; + while( TempShiftWORD > 31 ) + { TempShiftWORD = TempShiftWORD>>1; GreenShift++; } + int BlueShift = 0; + TempShiftWORD = BlueMask; + while( TempShiftWORD > 31 ) + { TempShiftWORD = TempShiftWORD>>1; BlueShift++; } + int RedShift = 0; + TempShiftWORD = RedMask; + while( TempShiftWORD > 31 ) + { TempShiftWORD = TempShiftWORD>>1; RedShift++; } + + // read the actual pixels + + for( j=Height-1 ; j >= 0 ; j-- ) + { + i=0; + int ReadNumber = 0; + while( ReadNumber < DataBytes ) + { + ebmpWORD TempWORD; + SafeFread( (char*) &TempWORD , 2 , 1 , fp ); + if( IsBigEndian() ) + { TempWORD = FlipWORD(TempWORD); } + ReadNumber += 2; + + ebmpWORD Red = RedMask & TempWORD; + ebmpWORD Green = GreenMask & TempWORD; + ebmpWORD Blue = BlueMask & TempWORD; + + ebmpBYTE BlueBYTE = (ebmpBYTE) 8*(Blue>>BlueShift); + ebmpBYTE GreenBYTE = (ebmpBYTE) 8*(Green>>GreenShift); + ebmpBYTE RedBYTE = (ebmpBYTE) 8*(Red>>RedShift); + + (Pixels[i][j]).Red = RedBYTE; + (Pixels[i][j]).Green = GreenBYTE; + (Pixels[i][j]).Blue = BlueBYTE; + + i++; + } + ReadNumber = 0; + while( ReadNumber < PaddingBytes ) + { + ebmpBYTE TempBYTE; + SafeFread( (char*) &TempBYTE , 1, 1, fp); + ReadNumber++; + } + } + + } + + fclose(fp); + return true; +} + +bool BMP::CreateStandardColorTable( void ) +{ + using namespace std; + if( BitDepth != 1 && BitDepth != 4 && BitDepth != 8 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Attempted to create color table at a bit" << endl + << " depth that does not require a color table." << endl + << " Ignoring request." << endl; + } + return false; + } + + if( BitDepth == 1 ) + { + int i; + for( i=0 ; i < 2 ; i++ ) + { + Colors[i].Red = i*255; + Colors[i].Green = i*255; + Colors[i].Blue = i*255; + Colors[i].Alpha = 0; + } + return true; + } + + if( BitDepth == 4 ) + { + int i = 0; + int j,k,ell; + + // simplify the code for the first 8 colors + for( ell=0 ; ell < 2 ; ell++ ) + { + for( k=0 ; k < 2 ; k++ ) + { + for( j=0 ; j < 2 ; j++ ) + { + Colors[i].Red = j*128; + Colors[i].Green = k*128; + Colors[i].Blue = ell*128; + i++; + } + } + } + + // simplify the code for the last 8 colors + for( ell=0 ; ell < 2 ; ell++ ) + { + for( k=0 ; k < 2 ; k++ ) + { + for( j=0 ; j < 2 ; j++ ) + { + Colors[i].Red = j*255; + Colors[i].Green = k*255; + Colors[i].Blue = ell*255; + i++; + } + } + } + + // overwrite the duplicate color + i=8; + Colors[i].Red = 192; + Colors[i].Green = 192; + Colors[i].Blue = 192; + + for( i=0 ; i < 16 ; i++ ) + { Colors[i].Alpha = 0; } + return true; + } + + if( BitDepth == 8 ) + { + int i=0; + int j,k,ell; + + // do an easy loop, which works for all but colors + // 0 to 9 and 246 to 255 + for( ell=0 ; ell < 4 ; ell++ ) + { + for( k=0 ; k < 8 ; k++ ) + { + for( j=0; j < 8 ; j++ ) + { + Colors[i].Red = j*32; + Colors[i].Green = k*32; + Colors[i].Blue = ell*64; + Colors[i].Alpha = 0; + i++; + } + } + } + + // now redo the first 8 colors + i=0; + for( ell=0 ; ell < 2 ; ell++ ) + { + for( k=0 ; k < 2 ; k++ ) + { + for( j=0; j < 2 ; j++ ) + { + Colors[i].Red = j*128; + Colors[i].Green = k*128; + Colors[i].Blue = ell*128; + i++; + } + } + } + + // overwrite colors 7, 8, 9 + i=7; + Colors[i].Red = 192; + Colors[i].Green = 192; + Colors[i].Blue = 192; + i++; // 8 + Colors[i].Red = 192; + Colors[i].Green = 220; + Colors[i].Blue = 192; + i++; // 9 + Colors[i].Red = 166; + Colors[i].Green = 202; + Colors[i].Blue = 240; + + // overwrite colors 246 to 255 + i=246; + Colors[i].Red = 255; + Colors[i].Green = 251; + Colors[i].Blue = 240; + i++; // 247 + Colors[i].Red = 160; + Colors[i].Green = 160; + Colors[i].Blue = 164; + i++; // 248 + Colors[i].Red = 128; + Colors[i].Green = 128; + Colors[i].Blue = 128; + i++; // 249 + Colors[i].Red = 255; + Colors[i].Green = 0; + Colors[i].Blue = 0; + i++; // 250 + Colors[i].Red = 0; + Colors[i].Green = 255; + Colors[i].Blue = 0; + i++; // 251 + Colors[i].Red = 255; + Colors[i].Green = 255; + Colors[i].Blue = 0; + i++; // 252 + Colors[i].Red = 0; + Colors[i].Green = 0; + Colors[i].Blue = 255; + i++; // 253 + Colors[i].Red = 255; + Colors[i].Green = 0; + Colors[i].Blue = 255; + i++; // 254 + Colors[i].Red = 0; + Colors[i].Green = 255; + Colors[i].Blue = 255; + i++; // 255 + Colors[i].Red = 255; + Colors[i].Green = 255; + Colors[i].Blue = 255; + + return true; + } + return true; +} + +bool SafeFread( char* buffer, int size, int number, FILE* fp ) +{ + using namespace std; + int ItemsRead; + if( feof(fp) ) + { return false; } + ItemsRead = (int) fread( buffer , size , number , fp ); + if( ItemsRead < number ) + { return false; } + return true; +} + +void BMP::SetDPI( int HorizontalDPI, int VerticalDPI ) +{ + XPelsPerMeter = (int) ( HorizontalDPI * 39.37007874015748 ); + YPelsPerMeter = (int) ( VerticalDPI * 39.37007874015748 ); +} + +// int BMP::TellVerticalDPI( void ) const +int BMP::TellVerticalDPI( void ) +{ + if( !YPelsPerMeter ) + { YPelsPerMeter = DefaultYPelsPerMeter; } + return (int) ( YPelsPerMeter / (double) 39.37007874015748 ); +} + +// int BMP::TellHorizontalDPI( void ) const +int BMP::TellHorizontalDPI( void ) +{ + if( !XPelsPerMeter ) + { XPelsPerMeter = DefaultXPelsPerMeter; } + return (int) ( XPelsPerMeter / (double) 39.37007874015748 ); +} + +/* These functions are defined in EasyBMP_VariousBMPutilities.h */ + +BMFH GetBMFH( const char* szFileNameIn ) +{ + using namespace std; + BMFH bmfh; + + FILE* fp; + fp = fopen( szFileNameIn,"rb"); + + if( !fp ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: Cannot initialize from file " + << szFileNameIn << "." << endl + << " File cannot be opened or does not exist." + << endl; + } + bmfh.bfType = 0; + return bmfh; + } + + SafeFread( (char*) &(bmfh.bfType) , sizeof(ebmpWORD) , 1 , fp ); + SafeFread( (char*) &(bmfh.bfSize) , sizeof(ebmpDWORD) , 1 , fp ); + SafeFread( (char*) &(bmfh.bfReserved1) , sizeof(ebmpWORD) , 1 , fp ); + SafeFread( (char*) &(bmfh.bfReserved2) , sizeof(ebmpWORD) , 1 , fp ); + SafeFread( (char*) &(bmfh.bfOffBits) , sizeof(ebmpDWORD) , 1 , fp ); + + fclose( fp ); + + if( IsBigEndian() ) + { bmfh.SwitchEndianess(); } + + return bmfh; +} + +BMIH GetBMIH( const char* szFileNameIn ) +{ + using namespace std; + BMFH bmfh; + BMIH bmih; + + FILE* fp; + fp = fopen( szFileNameIn,"rb"); + + if( !fp ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: Cannot initialize from file " + << szFileNameIn << "." << endl + << " File cannot be opened or does not exist." + << endl; + } + return bmih; + } + + // read the bmfh, i.e., first 14 bytes (just to get it out of the way); + + ebmpBYTE TempBYTE; + int i; + for( i = 14 ; i > 0 ; i-- ) + { SafeFread( (char*) &TempBYTE , sizeof(ebmpBYTE) , 1, fp ); } + + // read the bmih + + SafeFread( (char*) &(bmih.biSize) , sizeof(ebmpDWORD) , 1 , fp ); + SafeFread( (char*) &(bmih.biWidth) , sizeof(ebmpDWORD) , 1 , fp ); + SafeFread( (char*) &(bmih.biHeight) , sizeof(ebmpDWORD) , 1 , fp ); + SafeFread( (char*) &(bmih.biPlanes) , sizeof(ebmpWORD) , 1 , fp ); + + SafeFread( (char*) &(bmih.biBitCount) , sizeof(ebmpWORD) , 1 , fp ); + SafeFread( (char*) &(bmih.biCompression) , sizeof(ebmpDWORD) , 1 , fp ); + SafeFread( (char*) &(bmih.biSizeImage) , sizeof(ebmpDWORD) , 1 , fp ); + SafeFread( (char*) &(bmih.biXPelsPerMeter) , sizeof(ebmpDWORD) , 1 , fp ); + + SafeFread( (char*) &(bmih.biYPelsPerMeter) , sizeof(ebmpDWORD) , 1 , fp ); + SafeFread( (char*) &(bmih.biClrUsed) , sizeof(ebmpDWORD) , 1 , fp ); + SafeFread( (char*) &(bmih.biClrImportant) , sizeof(ebmpDWORD) , 1 , fp ); + + fclose( fp ); + + if( IsBigEndian() ) + { bmih.SwitchEndianess(); } + + return bmih; +} + +void DisplayBitmapInfo( const char* szFileNameIn ) +{ + using namespace std; + FILE* fp; + fp = fopen( szFileNameIn,"rb"); + + if( !fp ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: Cannot initialize from file " + << szFileNameIn << "." << endl + << " File cannot be opened or does not exist." + << endl; + } + return; + } + fclose( fp ); + + // don't duplicate work! Just use the functions from above! + + BMFH bmfh = GetBMFH(szFileNameIn); + BMIH bmih = GetBMIH(szFileNameIn); + + cout << "File information for file " << szFileNameIn + << ":" << endl << endl; + + cout << "BITMAPFILEHEADER:" << endl + << "bfType: " << bmfh.bfType << endl + << "bfSize: " << bmfh.bfSize << endl + << "bfReserved1: " << bmfh.bfReserved1 << endl + << "bfReserved2: " << bmfh.bfReserved2 << endl + << "bfOffBits: " << bmfh.bfOffBits << endl << endl; + + cout << "BITMAPINFOHEADER:" << endl + << "biSize: " << bmih.biSize << endl + << "biWidth: " << bmih.biWidth << endl + << "biHeight: " << bmih.biHeight << endl + << "biPlanes: " << bmih.biPlanes << endl + << "biBitCount: " << bmih.biBitCount << endl + << "biCompression: " << bmih.biCompression << endl + << "biSizeImage: " << bmih.biSizeImage << endl + << "biXPelsPerMeter: " << bmih.biXPelsPerMeter << endl + << "biYPelsPerMeter: " << bmih.biYPelsPerMeter << endl + << "biClrUsed: " << bmih.biClrUsed << endl + << "biClrImportant: " << bmih.biClrImportant << endl << endl; + return; +} + +int GetBitmapColorDepth( const char* szFileNameIn ) +{ + BMIH bmih = GetBMIH( szFileNameIn ); + return (int) bmih.biBitCount; +} + +void PixelToPixelCopy( BMP& From, int FromX, int FromY, + BMP& To, int ToX, int ToY) +{ + *To(ToX,ToY) = *From(FromX,FromY); + return; +} + +void PixelToPixelCopyTransparent( BMP& From, int FromX, int FromY, + BMP& To, int ToX, int ToY, + RGBApixel& Transparent ) +{ + if( From(FromX,FromY)->Red != Transparent.Red || + From(FromX,FromY)->Green != Transparent.Green || + From(FromX,FromY)->Blue != Transparent.Blue ) + { *To(ToX,ToY) = *From(FromX,FromY); } + return; +} + +void RangedPixelToPixelCopy( BMP& From, int FromL , int FromR, int FromB, int FromT, + BMP& To, int ToX, int ToY ) +{ + // make sure the conventions are followed + if( FromB < FromT ) + { int Temp = FromT; FromT = FromB; FromB = Temp; } + + // make sure that the copied regions exist in both bitmaps + if( FromR >= From.TellWidth() ) + { FromR = From.TellWidth()-1; } + if( FromL < 0 ){ FromL = 0; } + + if( FromB >= From.TellHeight() ) + { FromB = From.TellHeight()-1; } + if( FromT < 0 ){ FromT = 0; } + + if( ToX+(FromR-FromL) >= To.TellWidth() ) + { FromR = To.TellWidth()-1+FromL-ToX; } + if( ToY+(FromB-FromT) >= To.TellHeight() ) + { FromB = To.TellHeight()-1+FromT-ToY; } + + int i,j; + for( j=FromT ; j <= FromB ; j++ ) + { + for( i=FromL ; i <= FromR ; i++ ) + { + PixelToPixelCopy( From, i,j, + To, ToX+(i-FromL), ToY+(j-FromT) ); + } + } + + return; +} + +void RangedPixelToPixelCopyTransparent( + BMP& From, int FromL , int FromR, int FromB, int FromT, + BMP& To, int ToX, int ToY , + RGBApixel& Transparent ) +{ + // make sure the conventions are followed + if( FromB < FromT ) + { int Temp = FromT; FromT = FromB; FromB = Temp; } + + // make sure that the copied regions exist in both bitmaps + if( FromR >= From.TellWidth() ) + { FromR = From.TellWidth()-1; } + if( FromL < 0 ){ FromL = 0; } + + if( FromB >= From.TellHeight() ) + { FromB = From.TellHeight()-1; } + if( FromT < 0 ){ FromT = 0; } + + if( ToX+(FromR-FromL) >= To.TellWidth() ) + { FromR = To.TellWidth()-1+FromL-ToX; } + if( ToY+(FromB-FromT) >= To.TellHeight() ) + { FromB = To.TellHeight()-1+FromT-ToY; } + + int i,j; + for( j=FromT ; j <= FromB ; j++ ) + { + for( i=FromL ; i <= FromR ; i++ ) + { + PixelToPixelCopyTransparent( From, i,j, + To, ToX+(i-FromL), ToY+(j-FromT) , + Transparent); + } + } + + return; +} + +bool CreateGrayscaleColorTable( BMP& InputImage ) +{ + using namespace std; + int BitDepth = InputImage.TellBitDepth(); + if( BitDepth != 1 && BitDepth != 4 && BitDepth != 8 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Warning: Attempted to create color table at a bit" << endl + << " depth that does not require a color table." << endl + << " Ignoring request." << endl; + } + return false; + } + int i; + int NumberOfColors = InputImage.TellNumberOfColors(); + + ebmpBYTE StepSize; + if( BitDepth != 1 ) + { StepSize = 255/(NumberOfColors-1); } + else + { StepSize = 255; } + + for( i=0 ; i < NumberOfColors ; i++ ) + { + ebmpBYTE TempBYTE = i*StepSize; + RGBApixel TempColor; + TempColor.Red = TempBYTE; + TempColor.Green = TempBYTE; + TempColor.Blue = TempBYTE; + TempColor.Alpha = 0; + InputImage.SetColor( i , TempColor ); + } + return true; +} + +bool BMP::Read32bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int i; + if( Width*4 > BufferSize ) + { return false; } + for( i=0 ; i < Width ; i++ ) + { memcpy( (char*) &(Pixels[i][Row]), (char*) Buffer+4*i, 4 ); } + return true; +} + +bool BMP::Read24bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int i; + if( Width*3 > BufferSize ) + { return false; } + for( i=0 ; i < Width ; i++ ) + { memcpy( (char*) &(Pixels[i][Row]), Buffer+3*i, 3 ); } + return true; +} + +bool BMP::Read8bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int i; + if( Width > BufferSize ) + { return false; } + for( i=0 ; i < Width ; i++ ) + { + int Index = Buffer[i]; + *( this->operator()(i,Row) )= GetColor(Index); + } + return true; +} + +bool BMP::Read4bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int Shifts[2] = {4 ,0 }; + int Masks[2] = {240,15}; + + int i=0; + int j; + int k=0; + if( Width > 2*BufferSize ) + { return false; } + while( i < Width ) + { + j=0; + while( j < 2 && i < Width ) + { + int Index = (int) ( (Buffer[k]&Masks[j]) >> Shifts[j]); + *( this->operator()(i,Row) )= GetColor(Index); + i++; j++; + } + k++; + } + return true; +} +bool BMP::Read1bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int Shifts[8] = {7 ,6 ,5 ,4 ,3,2,1,0}; + int Masks[8] = {128,64,32,16,8,4,2,1}; + + int i=0; + int j; + int k=0; + + if( Width > 8*BufferSize ) + { return false; } + while( i < Width ) + { + j=0; + while( j < 8 && i < Width ) + { + int Index = (int) ( (Buffer[k]&Masks[j]) >> Shifts[j]); + *( this->operator()(i,Row) )= GetColor(Index); + i++; j++; + } + k++; + } + return true; +} + +bool BMP::Write32bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int i; + if( Width*4 > BufferSize ) + { return false; } + for( i=0 ; i < Width ; i++ ) + { memcpy( (char*) Buffer+4*i, (char*) &(Pixels[i][Row]), 4 ); } + return true; +} + +bool BMP::Write24bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int i; + if( Width*3 > BufferSize ) + { return false; } + for( i=0 ; i < Width ; i++ ) + { memcpy( (char*) Buffer+3*i, (char*) &(Pixels[i][Row]), 3 ); } + return true; +} + +bool BMP::Write8bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int i; + if( Width > BufferSize ) + { return false; } + for( i=0 ; i < Width ; i++ ) + { Buffer[i] = FindClosestColor( Pixels[i][Row] ); } + return true; +} + +bool BMP::Write4bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int PositionWeights[2] = {16,1}; + + int i=0; + int j; + int k=0; + if( Width > 2*BufferSize ) + { return false; } + while( i < Width ) + { + j=0; + int Index = 0; + while( j < 2 && i < Width ) + { + Index += ( PositionWeights[j]* (int) FindClosestColor( Pixels[i][Row] ) ); + i++; j++; + } + Buffer[k] = (ebmpBYTE) Index; + k++; + } + return true; +} + +bool BMP::Write1bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ) +{ + int PositionWeights[8] = {128,64,32,16,8,4,2,1}; + + int i=0; + int j; + int k=0; + if( Width > 8*BufferSize ) + { return false; } + while( i < Width ) + { + j=0; + int Index = 0; + while( j < 8 && i < Width ) + { + Index += ( PositionWeights[j]* (int) FindClosestColor( Pixels[i][Row] ) ); + i++; j++; + } + Buffer[k] = (ebmpBYTE) Index; + k++; + } + return true; +} + +ebmpBYTE BMP::FindClosestColor( RGBApixel& input ) +{ + using namespace std; + + int i=0; + int NumberOfColors = TellNumberOfColors(); + ebmpBYTE BestI = 0; + int BestMatch = 999999; + + while( i < NumberOfColors ) + { + RGBApixel Attempt = GetColor( i ); + int TempMatch = IntSquare( (int) Attempt.Red - (int) input.Red ) + + IntSquare( (int) Attempt.Green - (int) input.Green ) + + IntSquare( (int) Attempt.Blue - (int) input.Blue ); + if( TempMatch < BestMatch ) + { BestI = (ebmpBYTE) i; BestMatch = TempMatch; } + if( BestMatch < 1 ) + { i = NumberOfColors; } + i++; + } + return BestI; +} + +bool EasyBMPcheckDataSize( void ) +{ + using namespace std; + bool ReturnValue = true; + if( sizeof( ebmpBYTE ) != 1 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: ebmpBYTE has the wrong size (" + << sizeof( ebmpBYTE ) << " bytes)," << endl + << " Compared to the expected 1 byte value" << endl; + } + ReturnValue = false; + } + if( sizeof( ebmpWORD ) != 2 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: ebmpWORD has the wrong size (" + << sizeof( ebmpWORD ) << " bytes)," << endl + << " Compared to the expected 2 byte value" << endl; + } + ReturnValue = false; + } + if( sizeof( ebmpDWORD ) != 4 ) + { + if( EasyBMPwarnings ) + { + cout << "EasyBMP Error: ebmpDWORD has the wrong size (" + << sizeof( ebmpDWORD ) << " bytes)," << endl + << " Compared to the expected 4 byte value" << endl; + } + ReturnValue = false; + } + return ReturnValue; +} + +bool Rescale( BMP& InputImage , char mode, ScaleParam scale ) +{ + using namespace std; + int CapMode = toupper( mode ); + + BMP OldImage( InputImage ); + + if( CapMode != 'P' && + CapMode != 'W' && + CapMode != 'H' && + CapMode != 'F' && + CapMode != 'D' ) + { + if( EasyBMPwarnings ) + { + char ErrorMessage [1024]; + sprintf( ErrorMessage, "EasyBMP Error: Unknown rescale mode %c requested\n" , mode ); + cout << ErrorMessage; + } + return false; + } + + int NewWidth =0; + int NewHeight =0; + + int OldWidth = OldImage.TellWidth(); + int OldHeight= OldImage.TellHeight(); + + if( CapMode == 'P' ) + { + NewWidth = (int) floor( OldWidth * scale.ratio / 100.0 ); + NewHeight = (int) floor( OldHeight * scale.ratio / 100.0 ); + } + if( CapMode == 'F' ) + { + if( OldWidth > OldHeight ) + { CapMode = 'W'; } + else + { CapMode = 'H'; } + } + + if( CapMode == 'W' ) + { + double percent = (double) scale.keepsize / (double) OldWidth; + NewWidth = scale.keepsize; + NewHeight = (int) floor( OldHeight * percent ); + } + if( CapMode == 'H' ) + { + double percent = (double) scale.keepsize / (double) OldHeight; + NewHeight = scale.keepsize; + NewWidth = (int) floor( OldWidth * percent ); + } + + if( CapMode == 'D') + { + NewWidth = scale.dimension.width; + NewHeight = scale.dimension.height; + } + + if( NewWidth < 1 ) + { NewWidth = 1; } + if( NewHeight < 1 ) + { NewHeight = 1; } + + InputImage.SetSize( NewWidth, NewHeight ); + InputImage.SetBitDepth( 24 ); + + int I,J; + double ThetaI,ThetaJ; + + for( int j=0; j < NewHeight-1 ; j++ ) + { + ThetaJ = (double)(j*(OldHeight-1.0)) + /(double)(NewHeight-1.0); + J = (int) floor( ThetaJ ); + ThetaJ -= J; + + for( int i=0; i < NewWidth-1 ; i++ ) + { + ThetaI = (double)(i*(OldWidth-1.0)) + /(double)(NewWidth-1.0); + I = (int) floor( ThetaI ); + ThetaI -= I; + + InputImage(i,j)->Red = (ebmpBYTE) + ( (1.0-ThetaI-ThetaJ+ThetaI*ThetaJ)*(OldImage(I,J)->Red) + +(ThetaI-ThetaI*ThetaJ)*(OldImage(I+1,J)->Red) + +(ThetaJ-ThetaI*ThetaJ)*(OldImage(I,J+1)->Red) + +(ThetaI*ThetaJ)*(OldImage(I+1,J+1)->Red) ); + InputImage(i,j)->Green = (ebmpBYTE) + ( (1.0-ThetaI-ThetaJ+ThetaI*ThetaJ)*OldImage(I,J)->Green + +(ThetaI-ThetaI*ThetaJ)*OldImage(I+1,J)->Green + +(ThetaJ-ThetaI*ThetaJ)*OldImage(I,J+1)->Green + +(ThetaI*ThetaJ)*OldImage(I+1,J+1)->Green ); + InputImage(i,j)->Blue = (ebmpBYTE) + ( (1.0-ThetaI-ThetaJ+ThetaI*ThetaJ)*OldImage(I,J)->Blue + +(ThetaI-ThetaI*ThetaJ)*OldImage(I+1,J)->Blue + +(ThetaJ-ThetaI*ThetaJ)*OldImage(I,J+1)->Blue + +(ThetaI*ThetaJ)*OldImage(I+1,J+1)->Blue ); + } + InputImage(NewWidth-1,j)->Red = (ebmpBYTE) + ( (1.0-ThetaJ)*(OldImage(OldWidth-1,J)->Red) + + ThetaJ*(OldImage(OldWidth-1,J+1)->Red) ); + InputImage(NewWidth-1,j)->Green = (ebmpBYTE) + ( (1.0-ThetaJ)*(OldImage(OldWidth-1,J)->Green) + + ThetaJ*(OldImage(OldWidth-1,J+1)->Green) ); + InputImage(NewWidth-1,j)->Blue = (ebmpBYTE) + ( (1.0-ThetaJ)*(OldImage(OldWidth-1,J)->Blue) + + ThetaJ*(OldImage(OldWidth-1,J+1)->Blue) ); + } + + for( int i=0 ; i < NewWidth-1 ; i++ ) + { + ThetaI = (double)(i*(OldWidth-1.0)) + /(double)(NewWidth-1.0); + I = (int) floor( ThetaI ); + ThetaI -= I; + InputImage(i,NewHeight-1)->Red = (ebmpBYTE) + ( (1.0-ThetaI)*(OldImage(I,OldHeight-1)->Red) + + ThetaI*(OldImage(I,OldHeight-1)->Red) ); + InputImage(i,NewHeight-1)->Green = (ebmpBYTE) + ( (1.0-ThetaI)*(OldImage(I,OldHeight-1)->Green) + + ThetaI*(OldImage(I,OldHeight-1)->Green) ); + InputImage(i,NewHeight-1)->Blue = (ebmpBYTE) + ( (1.0-ThetaI)*(OldImage(I,OldHeight-1)->Blue) + + ThetaI*(OldImage(I,OldHeight-1)->Blue) ); + } + + *InputImage(NewWidth-1,NewHeight-1) = *OldImage(OldWidth-1,OldHeight-1); + return true; +} diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.h b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.h new file mode 100644 index 0000000..52012db --- /dev/null +++ b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP.h @@ -0,0 +1,86 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMP.h * +* date added: 01-31-2005 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Main include file * +* * +*************************************************/ + +#ifdef _MSC_VER +// MS Visual Studio gives warnings when using +// fopen. But fopen_s is not going to work well +// with most compilers, and fopen_s uses different +// syntax than fopen. (i.e., a macro won't work) +// So, we'lll use this: +#define _CRT_SECURE_NO_DEPRECATE +#endif + +#include +#include +#include +#include + +#ifndef EasyBMP +#define EasyBMP + +#ifdef __BCPLUSPLUS__ +// The Borland compiler must use this because something +// is wrong with their cstdio file. +#include +#else +#include +#endif + +#ifdef __GNUC__ +// If g++ specific code is ever required, this is +// where it goes. +#endif + +#ifdef __INTEL_COMPILER +// If Intel specific code is ever required, this is +// where it goes. +#endif + +#ifndef _DefaultXPelsPerMeter_ +#define _DefaultXPelsPerMeter_ +#define DefaultXPelsPerMeter 3780 +// set to a default of 96 dpi +#endif + +#ifndef _DefaultYPelsPerMeter_ +#define _DefaultYPelsPerMeter_ +#define DefaultYPelsPerMeter 3780 +// set to a default of 96 dpi +#endif + +#include "EasyBMP_DataStructures.h" +#include "EasyBMP_BMP.h" +#include "EasyBMP_VariousBMPutilities.h" + +#ifndef _EasyBMP_Version_ +#define _EasyBMP_Version_ 1.06 +#define _EasyBMP_Version_Integer_ 106 +#define _EasyBMP_Version_String_ "1.06" +#endif + +#ifndef _EasyBMPwarnings_ +#define _EasyBMPwarnings_ +#endif + +void SetEasyBMPwarningsOff( void ); +void SetEasyBMPwarningsOn( void ); +bool GetEasyBMPwarningState( void ); + +#endif diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_BMP.h b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_BMP.h new file mode 100644 index 0000000..7161435 --- /dev/null +++ b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_BMP.h @@ -0,0 +1,86 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMP_VariousBMPutilities.h * +* date added: 05-02-2005 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Defines BMP class * +* * +*************************************************/ + +#ifndef _EasyBMP_BMP_h_ +#define _EasyBMP_BMP_h_ + +bool SafeFread( char* buffer, int size, int number, FILE* fp ); +bool EasyBMPcheckDataSize( void ); + +class BMP +{private: + + int BitDepth; + int Width; + int Height; + RGBApixel** Pixels; + RGBApixel* Colors; + int XPelsPerMeter; + int YPelsPerMeter; + + ebmpBYTE* MetaData1; + int SizeOfMetaData1; + ebmpBYTE* MetaData2; + int SizeOfMetaData2; + + bool Read32bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Read24bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Read8bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Read4bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Read1bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + + bool Write32bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Write24bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Write8bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Write4bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + bool Write1bitRow( ebmpBYTE* Buffer, int BufferSize, int Row ); + + ebmpBYTE FindClosestColor( RGBApixel& input ); + + public: + + int TellBitDepth( void ); + int TellWidth( void ); + int TellHeight( void ); + int TellNumberOfColors( void ); + void SetDPI( int HorizontalDPI, int VerticalDPI ); + int TellVerticalDPI( void ); + int TellHorizontalDPI( void ); + + BMP(); + BMP( BMP& Input ); + ~BMP(); + RGBApixel* operator()(int i,int j); + + RGBApixel GetPixel( int i, int j ) const; + bool SetPixel( int i, int j, RGBApixel NewPixel ); + + bool CreateStandardColorTable( void ); + + bool SetSize( int NewWidth, int NewHeight ); + bool SetBitDepth( int NewDepth ); + bool WriteToFile( const char* FileName ); + bool ReadFromFile( const char* FileName ); + + RGBApixel GetColor( int ColorNumber ); + bool SetColor( int ColorNumber, RGBApixel NewColor ); +}; + +#endif diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_ChangeLog.txt b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_ChangeLog.txt new file mode 100644 index 0000000..b0a2c14 --- /dev/null +++ b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_ChangeLog.txt @@ -0,0 +1,821 @@ +EasyBMP Cross-Platform Windows Bitmap Library: Change Log + +Library Author(s): Paul Macklin + Library License: BSD (revised). See the BSD_(revised)_license.txt + file for further information. + Copyright: 2005-6 by the EasyBMP Project + Email: macklin01@users.sourceforge.net + Support: http://easybmp.sourceforge.net + +All changes by Paul Macklin unless otherwise noted. + +*--------------------------------------------------------------------* + +Version: 0.50 + Date: 1-31-2005 + + None! (first release) + +*--------------------------------------------------------------------* + +Version: 0.51 + Date: 2-14-2005 + + Added full 32-bit BMP file support + + Took out annoying "colors: " message from BMP8 initialization + from scratch + + Added more license and copyright info to each file + + Added change log to library + + To do next: + Should update the error messages for the initializations + Should simplify the reading and writing code + +*--------------------------------------------------------------------* + +Version: 0.52 + Date: 2-19-2005 + + Fixed a minor bug in the MakeGreyscalePalette function where the + 0 color turned out to be (255,255,255), rather than (0,0,0) + + Updated standard colors for 4-bit, 8-bit, and 24-bit + +*--------------------------------------------------------------------* + +Version: 0.53 + Date: 2-27-2005 + + Fixed unsigned / signed problem that VS.net shows + + + Tried fix of line 186 in EasyBMP_BMP4.h file. If it works, + I'll apply it consistently. I think that VS.net wants us + to clear char* blah, then char = new blah [size], just + like the old days for g++. + + Removed EasyBMP_StandardColors.h from standard package + +*--------------------------------------------------------------------* + +Version: 0.54 + Date: 2-27-2005 + + The fix of line 186 in EasyBMP_BMP4.h file appears to have + worked. I applied it through the remainder of the code. + Hopefully, this should ensure Visual Studio.Net compati- + bility. + + Fixed some typos in the comment lines + +*--------------------------------------------------------------------* + +Version: 0.55 + Date: 5-2-2005 + + Introduced RGBApixel struct. + + Introduced BMFH, BMIH, and BMP classes. + + Deprecated all old code to *_legacy.h. + + Rewrote EasyBMP_VariousBMPutilities.h to use the new + BMP class. + +*--------------------------------------------------------------------* + +Version: 0.56 + Date: 5-4-2005 + + Made Width, Height, and BitDepth private members and added + functions for accessing them. + + Made a new function, SetBitDepth, as the only means to + change the bit depth. It will create/resize a palette as + necessary. This simplifies the WriteToFile code, as well as + any palette altering algorithms. (All algorithms can now + assume that a properly-sized palette exists.) This will + help improve code stability greatly. + + Made a new function, SetSize, as the only way to change the + width and height of the image. + + Eliminated useless HasPalette and NumberOfColors members, + and added TellNumberOfColors() function. + + Updated EasyBMP_VariousBMPutilities.h to respect privacy + of data members. + +*--------------------------------------------------------------------* + +Version: 0.57 + Date: 5-8-2005 + + Removed fclose(fp) lines from EasyBMP_BMP.h and + EasyBMP_VariousBMPutilities.h whenever ( !fp ) occurs, + to avoid a crash when trying to close a non-existant file. + + + Added a line to set bmfh.bfType = 0; to getBMFH() routine + in the case where ( !fp ) occurs, so that a nonexistant file + doesn't falsely show up as a bitmap file. + + Made error messages in BMP::ReadFromFile(char*) more meaningful, + since Argh! doesn't help much. :-) + + Made ReadFromFile operations safer: can deal more effectively + with corrupted and/or truncated files by adding the new + SafeFread() wrapper function. + + Moved all change-log entries to the change log to make the source + file tidier. + + Removed all references to Palettes; renamed them to ColorTables. + +*--------------------------------------------------------------------* + +Version: 0.58 + Date: 5-13-2005 + + Rewrote ReadFromFile() to fix program crashes on reading 4-bit + files. (*grumble* I can't believe there was such a bug in such + a late version! */grumble*) + + Added support to ReadFromFile() for reading 1-bit files. + + Rewrote ReadFromFile() to avoid trying to read bitmap files of + depths other than 1, 4, 8, 24, and 32 bits. + + Tested reading 4-bit files of width 0,1,2, and 3 (modulo 4), + and 1-bit files of width 0,1,2,3,4,5,6, and 7 (modulo 8) + +*--------------------------------------------------------------------* + +Version: 0.59 + Date: 5-15-2005 + + Made ReadFromFile() more robust. Evidently, reading to the + same temp variable all the time made it unstable when reading + many files. I would never have guessed. I instead declare BMIH + and BMFH objects and read directly to their members. This appears + to be more stable when dealing with many ReadFromFile() calls. + + On a related note, made sure to not call SetSize( Width,Height), + which is a bit recursive, as well as SetBitDepth( BitDepth ). + This appears to help stability, since these two functions were + create precisely for the purpose of setting those variables + values safely. + + Made use of the boolean return value in SafeFread() to detect + when files are obviously corrupted. Used this to have an early + catch in ReadFromFile() and set it to a 1x1 1-bit image and + exit. + + Made ReadFromFile() stricter, in that it only reads recognized + bit depths (1,4,8,24,32). Any other bit depth will prompt the + routine to terminate and set it to a 1x1 1-bit file. + + Added write support for 1-bit files. + + Rewrote WriteToFile() for 4,8-bit files to match methods used + for reading them. + + Revised CreateStandardColorTable() and + CreateGreyscaleColorTable() to add support for 1-bit files. + + Rewrote WriteToFile() to be stricter in only writing known bit + depths (1,4,8,24,32) and ignoring all others. + +*--------------------------------------------------------------------* + +Version: 0.60 + Date: 5-21-2005 + + Deprecated *_legacy.h files. + + Tested library extensivey in linux with good results. + + Made CreateGreyscaleColorTable() stricter, in that it exits + if supplied a bit depth other than 1, 4, or 8. + + Made cosmetic changes in EasyBMP_DataStructures.h to + improve readability. + + Made SetBitDepth() stricter, in that it will never allow a bitmap + to be set to an unsupported bit depth. Only bit depths of 1, 4, + 8, 24, or 32 are accepted. + + Made SetSize() stricter, in that it will not allow negative + widths or heights. + + Made cosmetic changes in EasyBMP_BMP.h to improve readability. + + Added a check in ReadFromFile() to see if the requested width or + height is negative, a good sign of file corruption. In such a + case, the file is set to a blank 1x1 1-bit file. + + Added code to ReadFromFile() to set size to 1x1 and bit depth to + 1-bit if the file was not found. + +*--------------------------------------------------------------------* + +Version: 0.61 + Date: 5-22-2005 + + Fixed awIndex typo in WriteToFile(). + + Replaced double BestDistance comparisons in WriteToFile() + with int BestDistances (so as to do integer operations, + rather than double operations). This gave a roughly 100% + speedup in 8-bit, 4-bit, and 1-bit write operations on + unoptimized (no compiler flags) code and a 30% speedup + on optimized code. + + Removed checks like if( BestDistance < 1 ){ k=256; } .. from + WriteToFile(), as they give more overhead than savings in my + testing. For 8-bit files, there was a slight gain by putting + it back in with another method: + while( k < 256 && BestDistance > 0 ). + + Redefined StepSize in CreateGreyscaleColorTable() to give a + better range of greys in 4-bit mode. As it was, white was not + in the color table. (Colors were spaced by 256/16 = 16). Now, + colors are spaced by (255-1)/(16-1) = 17, which gives the full + range. + +*--------------------------------------------------------------------* + +Version: 0.62 + Date: 5-25-2005 + + Added endianess check function IsBigEndian() to + EasyBMP_DataStructures.h file. + + Added functions to swap bytes in WORD and DWORD multibyte + variables to EasyBMP_DataStructures.h file for future big-endian + support. + + Added functions to switch endianess to BMFH and BMIH objects + to EasyBMP_DataStructures.h file. + + Added endianess checks to ReadFromFile() and WriteToFile() + functions in EasyBMP_BMP.h file, along with endianess conversions + where necessary. + + Added endianess checks and conversions to GetBMFH() and GetBMIH() + functions in EasyBMP_VariousBMPutilities.h file. + + Rewrote GetBitmapInfo() function to use GetBMFH() and GetBMIH() + functions instead. (In EasyBMP_VariousBMPutilities.h.) This + cuts down on the redundancy in the code. + + Renamed GetBitmapInfo() to DisplayBitmapInfo() in the + EasyBMP_VariousBMPutilities.h file. + + With these changes, big-endian architectures should be supported, + including IBM PowerPC, Sun Sparc, Motorola 86k, etc., and + including Mac OSX. + +*--------------------------------------------------------------------* + +Version: 0.63 + Date: 7-20-2005 + + Added IntPow(int,int) function to help compiling with std + namespace. Besides, integer operations are faster and more + accurate. + + Moved Square(double), IntSquare(int), and IntPow(int,int) to + EasyBMP_DataStructures.h + + Simplified and cleaned up code in + Create4bitColorTable( RGBApixel**). + + Changed safety check in BMP.ReadFromFile(char*) to set size to + 1 x 1 if width or height is non-positive, rather than simply + negative. + + Added bounds checking to BMP.operator()(int,int) to automatically + truncate requested pixel if out of bounds. Also added a warning + to cue the user in. :-) + + Made error messages more consistent in format. + + Simplified and cleaned up code in + Create4bitColorTable( RGBApixel**). + + Added #include to EasyBMP.h, since EasyBMP uses + cout, etc. + + Simplified and cleaned up code in + Create1bitColorTable( RGBApixel**). + + Changed BMP.SetSize(int,int) to disallow non-positive widths and + heights, rather than simply negative widths and heights. Such + function calls are now ignored. + +*--------------------------------------------------------------------* + +Version: 0.64 + Date: 8-2-2005 + + Changed "include " to "include " for + ANSI-C++ compliance, as well as for better compatibility with the + std namespace and VC++. (Thanks, Tommy Li!) + + Added some #ifndef pragmas to each header so that it should be + fine to incluce EasyBMP.h in multiple files in larger projects. + + Added "using namespace std" inside any function that used C++ + math or I/O operations. I avoided putting "using namespace std" + anywhere with global scope for maximum compatibility with C++ + software in the wild. + + Added includes for and to EasyBMP.h + + Removed unused temporary variables (TempWORD and TempDWORD) from + EasyBMP_BMP.h for cleaner compiling. If I see any more such + unused variables, I'll remove them, too. + +*--------------------------------------------------------------------* + +Version: 0.65 + Date: 8-13-2005 + + Moved implementations of BMP::BMP(), BMP::~BMP(), and + BMP::operator()(int,int) outside of the class. This should help + for eventually moving everything into a separate cpp file. + + Made RGBApixel** Pixels a private data member of the class + BMP. + + Added function void BMP::SetColor(int,RGBApixel) to BMP class + to allow safe method of changing a color in the color table. + + Added function RGBApixel BMP::GetColor(int) to BMP class + to allow safe method of retrieving a color in the color + table. + + Cleaned up error messages in EasyBMP_BMP.h + + Cleaned up error messages in EasyBMP_VariousBMPutilities.h + +*--------------------------------------------------------------------* + +Version: 0.66 + Date: 8-18-2005 + + EasyBMP_StandardColorTables.h was removed from the library. + + CreateStandardColorTable(RGBApixel**,int) was changed to + CreateStandardColorTable() and made a member function of BMP. + All other CreateStandardColorTable functions are now unnecessary + and have been removed. + + CreateGreyscaleColorTable(RGBApixel**,int) was changed to + CreateStandardColorTable( BMP& ) and moved to + EasyBMP_VariousBMPutilities.h. + + RGBApixel* Colors was made a private data member of the BMP + class. + + CreateGreyscaleColorTable( BMP& ) was renamed to + CreateGrayscaleColorTable( BMP& ). + +*--------------------------------------------------------------------* + +Version: 0.67 + Date: 9-14-2005 + + Made the EasyBMP custom math functions in + EasyBMP_DataStructures.h inline. (Square,IntSquare,IntPow). + This should make those function calls faster while improving + compatibility with compiling DLL's. + + Separated the code from SafeFread() in EasyBMP_BMP.h to + improve compatibility with compiling DLL's. + + Removed #define _WINGDI_H from EasyBMP_DataStructures.h to + improve compatibility with win32 applications. Instead, + there's an extra #ifndef _SELF_DEFINED_BMP_DATA_TYPES + conditional added. + + _SELF_DEFINED_BMP_DATA_TYPES renamed to _SELF_DEFINED_WINGDI + in EasyBMP_DataStructures.h. + + All bit-flipping functions (IsBigEndian, FlipWORD, + FlipDWORD) in EasyBMP_DataStructures.h were made inline + to improve execution speed and improve compatibility with + compiling DLL's. + + All code was separated from function declarations in + EasyBMP_VariousBMPutilities.h to improve compatibility + with compiling DLL's. + + Updated and cleaned up layout of EasyBMP_ChangeLog.txt. + + Updated contact and support information in library files. + + Corrected the LGPL license version. + +*--------------------------------------------------------------------* + +Version: 0.68 + Date: 10-9-2005 + + Changed references to FILE to std::FILE in the SafeFread function + in EasyBMP_BMP.h to improve compatibility with Borland's compiler. + + Removed a few assignments in EasyBMP_BMP.h that weren't used to + improve efficiency and reduce Borland warnings. + + Changed calls like NotCorrupted = SafeFread() to + NotCorrupted &= SafeFread() in BMP::ReadFromFile() in EasyBMP_BMP.h + to improve robustness. Now, if the NotCorrupted bit is ever set + to false, it stays false, meaning that the function won't "forget" + that it encountered file corruption. + +*--------------------------------------------------------------------* + +Version: 0.69 + Date: 10-19-2005 + + Changed BMP::WriteToFile( char* ) to BMP::WriteToFile(const char*) + in EasyBMP_BMP.h to respond to a feature request. + + Changed BMP::ReadFromFile( char* ) to BMP::ReadToFile(const char*) + in EasyBMP_BMP.h to respond to a feature request. + + Made BMP::ReadFromFile() and BMP::WriteToFile() in EasyBMP_BMP.h + return true/false to indicate success/failure in the operations. + These functions previously returned void. + + Made BMP::SetSize() and BMP::SetBitDepth() in EasyBMP_BMP.h + return true/false to indicate success/failure in the operations. + These functions previously returned void. + + Made BMP::SetColor() and BMP::CreateStandardColorTable() in + EasyBMP_BMP.h return true/false to indicate success/failure in the + operations. These functions previously returned void. + + Made CreateGrayscaleColorTable() in EasyBMP_VariousBMPutilities.h + return true/false to indicate success/failure in the operations. + This function previously returned void. + + Changed the char* argument GetBMFH( char* ), GetBMIH( char* ), + DisplayBitmapInfo( char* ), and GetBitmapColorDepth( char* ) in + EasyBMP_VariousBMPutilities.h to const char* for cleaner, safer + programming. + +*--------------------------------------------------------------------* + +Version: 0.70 + Date: 10-19-2005 + + Found and fixed error in BMP::ReadFromFile() in the check for only + reading support bit depths. + + Changed license from LGPL to BSD (revised/modified) to simplify + licensing issues and resolve any lingering licensing questions. + + Fixed compiler error when using MSVC++. + + Improved fix to allow compiling with Borland without breaking + Borland support. + + Added a few lines to EasyBMP.h to make it easier to tailor code + to specific compilers. (For future use as needed.) + + Added a few lines to EasyBMP_BMP.h (in BMP::ReadFromFile(), + BMP::WriteToFile(), and BMP::SetBitDepth()) to eventually add + support for 16-bit files. + +*--------------------------------------------------------------------* + +Version: 0.71 + Date: 11-01-2005 + + Cleaned up comments in BMP::ReadFromFile() in EasyBMP_BMP.h + + Added endian-safe read support for 16-bit files that are in the + standard 5-5-5 format (not specified in bit fields) + + Added endian-safe read support for 16-bit files that use bit + fields, including 5-6-5 files. + + Added endian-safe write support for 16-bit files. Uses the 5-6-5 + encoding scheme to maximize the utility of the bits used. + + Added a check for compression in BMP::ReadFromFile(). Because + file compression is beyond the scope of EasyBMP, such files are + not supported, and EasyBMP now properly detects these situations + and exits with an error. + + Added a check for files that attempt to use bit fields but are not + 16-bit files to BMP::ReadFromFile(). Such files are not supported. + + Added a check to BMP::ReadFromFile() for files that use unknown + values of bmih.biCompression, such as old OS2 bitmaps. Such files + are not supported. + + Removed "switching endianness" messages from EasyBMP_BMP.h + + Added support for indexed (1, 4, and 8-bit) files that don't + specify all the colors. + + Added support for reading files that include extra meta data before + the pixels. This data is skipped. + + Added enclosing #ifndef EasyBMP ... lines to EasyBMP.h as a + further safeguard when EasyBMP is included in multiple cpp + files. + +*--------------------------------------------------------------------* + +Version: 1.00 + Date: 02-06-2006 + + First Production/Stable release. + + Corrected typographical errors in the comment sections of all + files. + + Updated copyright on all files. + + Removed extraneous comment in BMIH::BMIH() function in + EasyBMP_DataStructures.h file. + + Replaced instances of \n with the more modern endl in + EasyBMP_DataStructures.h, EasyBMP_BMP.h, and + EasyBMP_VariousBMPutilities.h. + + Added placeholder MetaData1 and MetaData2 data members to the + BMP class for potential future use. + + Removed extraneous comments from EasyBMP_BMP.h. + + Removed warning messages for switching endianness from + EasyBMP_VariousBMPutilities.h. + + Updated copyright in EasyBMP_ChangeLog.txt file. + + Fixed formatting issues in EasyBMP_ChangeLog.txt file. + + Added DefaultXpelsPerMeter and DefaultYpelsPerMeter in + EasyBMP.h. These will default to 96 dpi. + + Changed BMP::WriteToFile() to use DefaultXpelsPerMeter and + DefaultYpelsPerMeter when writing the BMIH structure. + + Added XpelsPerMeter and YpelsPerMeter data members to BMP + class so that horizontal and vertical resolution are handled + properly. Currently, upon reading a file, the stated resolutions + are preserved, and upon writing, if no resolutions are given, + the defaults (of 96 DPI) are used. + + Added function void BMP::SetDPI(int,int) to set the horizontal + and vertical resolutions. + + Removed some unnecessary code from GetBitmapColorDepth() in + EasyBMP_VariousBMPutilities.h. + + Fixed a bug in RangedPixelToPixelCopyTransparent() and + RangedPixelToPixelCopy() in EasyBMP_VariousBMPutilities.h which + caused copies to be truncated by an extra row or column in + certain circumstances. + + Fixed a bug in RangedPixelToPixelCopyTransparent() and + RangedPixelToPixelCopy() in EasyBMP_VariousBMPutilities.h which + checked the wrong variable (FromT instead of FromB) to see if + it was out of range. + + Added extra checks to RangedPixelToPixelCopyTransparent() and + RangedPixelToPixelCopy() in EasyBMP_VariousBMPutilities.h to + prevent attempted access of out-of-range pixels. + +*--------------------------------------------------------------------* + +Version: 1.01 + Date: 03-31-2006 + + Made only the short functions Square, IntSquare, IsBigEndian, + FlipWORD, and FlipDWORD inline functions in + EasyBMP_DataStructures.h. + + Moved all code (other than inline functions) to EasyBMP.cpp. + + Changed DefaultXPelsPerMeter and DefaultYPelsPerMeter to #define + lines in EasyBMP.h to make the library compatible with + with the header-code split. + + Removed memory hole in ~BMP() where "delete Colors;" was used + instead of "delete [] Colors;". Likewise with MetaData1 and + MetaData2. + + Fixed memory leak in BMP::SetBitDepth() by changing to + delete [] Colors; + + Removed potential memory leak in BMP::WriteToFile() in 24- and + 32-bit writing where szTemp wasn't delete at the end of a row. + + Fixed bug where XPelsPerMeter and YPelsPerMeter weren't + properly initialized in the BMP::BMP() constructor, leading + to strange horizontal and vertical resolutions. + + Fixed memory leak in BMP::ReadFromFile() where TempSkipBYTE + wasn't deleted. + + Fixed memory leak in BMP::ReadFromFile() where szTemp wasn't + deleted. + + Added BMP::TellVerticalDPI() and BMP::TellHorizontalDPI() + functions to give this information. If those values have + not yet been set, then they are first set to the EasyBMP + defaults of 96 dpi. + + Set uninitialized RGBApixel values to white (255,255,255,0) + in a few functions for the BMP class. + + Added a sample cpp application and makefile. + +*--------------------------------------------------------------------* + +Version: 1.02 + Date: 05-29-2006 + + Inserted a line into EasyBMP.h to suppress the Visual Studio + warnings. We'll keep using the C++ standard fopen for now + until fopen_s becomes a real standard. + + Moved the code sample and makefile to a subdirectory, so that + unzipping EasyBMP#_##.zip into a project directory doesn't + overwrite any crucial makefiles. + + Improved SafeFread() to check if the proper amount of data + could be read. + + Dramatically cleaned up ReadFromFile() code for 1 and 4 + bpp files. + + Fixed a typo (draw.o) in the sample makefile. + + Modified ReadFromFile() to use buffering when reading the pixel + data. This should substantially improve disk access performance. + Only 16 bpp files are read in the old, slower way. + + Changed DWORD from unsigned long to unsigned int. This should + fix the issue where 64-bit machines see DWORD as an 8-byte + data type, rather than 4 bytes. (Thank you to Bas Wegh!) + + Renamed BYTE, WORD, and DWORD data types to ebmpBYTE, ebmpWORD, + and ebmpDWORD to eliminate the possibility of conflict with + windows applications, particularly with 64-bit windows, which + likely uses 8 byte DWORDS. + + Modified WriteToFile() to use buffering when reading the pixel + data. This should substantially improve disk access performance. + Only 16 bpp files are read in the old, slower way. + + Added new function, EasyBMPcheckDataSize(), to check that + the ebmpBYTE, ebmpWORD, and ebmpDWORD types have the correct + type. + + Added some new macros of the EasyBMP version number for easier + version checking. New versions include _EasyBMP_Version_ + (a double), _EasyBMP_Version_String_ (a char* version), and + _EasyBMP_Version_Integer_ (an integer version, e.g., 102). + +*--------------------------------------------------------------------* + +Version: 1.03 + Date: 06-20-2006 + + Inserted a line into EasyBMP.h to suppress the Visual Studio + + Added a check to BMP.SetColor() to ensure that the color table + is defined before attempting to set a color entry. + + Added a check to BMP.GetColor() to ensure that the color table + is defined before attempting to retrieve a color entry. + + Simplified the conditional in BMP.WriteToFile() from + if( BitDepth == 1 || BitDepth == 4 || ... ) to the simpler + if( BitDepth != 16 ). + + Removed the old, unused code for writing 1- and 4-bit files + from BMP.WriteToFile(). + + Removed the line Colors = new RGBApixel [NumberOfColors]; in + BMP.ReadFromFile(). This operation is already covered by the + earlier SetBitDepth() call, and may contribute to a memory + leak. Furthermore, for files that had fewer than expected + number of colors (e.g., an 8-bit file with 236 colors), it + lead to memory access errors in BMP.GetColor() and BMP.SetColor(). + (In fact, this is the main motivation for release 1.03.) + + Added a warning when BMP.ReadFromFile() encounters an under- + specified color table, and code to pad the table with white + entries. + + Added screen output on EasyBMP version and project website to + the code sample. + +*--------------------------------------------------------------------* + +Version: 1.04 + Date: 07-22-2006 + + Removed the assignment to the integer i in IntPow() to eliminate a + Borland compiler warning. + + Removed the assignment to the integer i in the Read##bitRow() + functions to eliminate Borland compiler warnings. + + Removed the assignment to ZeroWORD in line 478 of EasyBMP.cpp in + BMP::WriteToFile() to eliminate Borland compiler warnings. + + Removed the assignment to ZeroWORD in line 825 of EasyBMP.cpp in + BMP::ReadFromFile() to eliminate Borland compiler warnings. + + The Borland warnings about conditions always being false are + incorrect. (Lines 1587, 1594, and 1601.) Likewise, the Borland + warnings about unreachable code (lines 1589, 1596, and 1603) are + incorrect. This code serves as a protection on unexpected hardware + where the data types may not be of the correct size, and helps to + future-proof EasyBMP. The first time this type of error was + encountered was on 64-bit CPUs, where the size of the DWORD was + larger than assumed when writing EasyBMP. Therefore, we will not + "correct" these "errors" detected by Borland. If they bother you, + compile with the -w-8008 and -w-8066 options. + + Borland issues warnings about argc and argv being unused in the + sample project. These are silly warnings and will be ignored. If + this warning bothers you, compile with the -w-8057 option. + + Modified the sample makefile so that EasyBMP.o depends upon + EasyBMP.cpp and EasyBMP*.h in the current working directory, rather + than the parent directory. + + Added a global EasyBMPwarnings boolean variable, and functions + SetEasyBMPwarningsOn() and SetEasyBMPwarningsOff() to enable and + disable EasyBMP warnings and errors. Note that this will not + disable error checking or any other EasyBMP behavior, other than + cout output of the warning and error messages. + + Added the function GetEasyBMPwarningState() to query the EasyBMP + warning state. (Either warnings are enabled or disabled.) + + Removed old commented code (Write1bitRow()) from EasyBMP.cpp. + + Replaced the 24-bit EasyBMPbackground.bmp image in the code sample + with a dithered 8-bit version to reduce the download size of the + core library. + +*--------------------------------------------------------------------* + +Version: 1.05 + Date: 11-01-2006 + + Renamed BytesRead to ItemsRead in the SafeFread() function in + EasyBMP.cpp for greater clarity. + + Added a copy constructor to the BMP class. However, note that + passing by value is not recommended practice. (Passing by refer- + ence is much faster, and consumes less memory.) + + Added a new function: + bool Rescale( BMP& InputImage, char mode, int NewDimension ); + to resize an image. The mode variables are as follows: + 'P': resizes the image to a new percentage of the old size, + e.g., 42%, 13%, etc. + example: Rescale( SomeImage, 'p', 42 ); + 'W': resizes the image such that the new width is as specified. + example: Rescale( SomeImage, 'W', 100 ); + 'H': resizes the image such that the new height is as specified. + example: Rescale( SomeImage, 'H', 100 ); + 'F': resizes the image to fit in a square of specified size. + example: Rescale( SomeImage, 'F', 100 ); // fits in 100x100 + // box + All rescaling is done with bilinear interpolation. + +*--------------------------------------------------------------------* + +Version: 1.06 + Date: 12-01-2006 + + Added includes for and to EasyBMP.h. These are + used and should have been included all along. This should help + with Intel icc compiling. + + Fixed the && bug in the copy constructor. (Thank you to user + fcnature!) + + Added image scaling to the supplied code sample. + + Added GetPixle() and SetPixel() functions for future use. These + will be added to enable more careful use of the const keyword. + +*--------------------------------------------------------------------* \ No newline at end of file diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_DataStructures.h b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_DataStructures.h new file mode 100644 index 0000000..41665e5 --- /dev/null +++ b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_DataStructures.h @@ -0,0 +1,104 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMP_DataStructures.h * +* date added: 05-02-2005 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Defines basic data structures for * +* the BMP class * +* * +*************************************************/ + +#ifndef _EasyBMP_Custom_Math_Functions_ +#define _EasyBMP_Custom_Math_Functions_ +inline double Square( double number ) +{ return number*number; } + +inline int IntSquare( int number ) +{ return number*number; } +#endif + +int IntPow( int base, int exponent ); + +#ifndef _EasyBMP_Defined_WINGDI +#define _EasyBMP_Defined_WINGDI + typedef unsigned char ebmpBYTE; + typedef unsigned short ebmpWORD; + typedef unsigned int ebmpDWORD; +#endif + +#ifndef _EasyBMP_DataStructures_h_ +#define _EasyBMP_DataStructures_h_ + +inline bool IsBigEndian() +{ + short word = 0x0001; + if((*(char *)& word) != 0x01 ) + { return true; } + return false; +} + +inline ebmpWORD FlipWORD( ebmpWORD in ) +{ return ( (in >> 8) | (in << 8) ); } + +inline ebmpDWORD FlipDWORD( ebmpDWORD in ) +{ + return ( ((in&0xFF000000)>>24) | ((in&0x000000FF)<<24) | + ((in&0x00FF0000)>>8 ) | ((in&0x0000FF00)<<8 ) ); +} + +// it's easier to use a struct than a class +// because we can read/write all four of the bytes +// at once (as we can count on them being continuous +// in memory + +typedef struct RGBApixel { + ebmpBYTE Blue; + ebmpBYTE Green; + ebmpBYTE Red; + ebmpBYTE Alpha; +} RGBApixel; + +class BMFH{ +public: + ebmpWORD bfType; + ebmpDWORD bfSize; + ebmpWORD bfReserved1; + ebmpWORD bfReserved2; + ebmpDWORD bfOffBits; + + BMFH(); + void display( void ); + void SwitchEndianess( void ); +}; + +class BMIH{ +public: + ebmpDWORD biSize; + ebmpDWORD biWidth; + ebmpDWORD biHeight; + ebmpWORD biPlanes; + ebmpWORD biBitCount; + ebmpDWORD biCompression; + ebmpDWORD biSizeImage; + ebmpDWORD biXPelsPerMeter; + ebmpDWORD biYPelsPerMeter; + ebmpDWORD biClrUsed; + ebmpDWORD biClrImportant; + + BMIH(); + void display( void ); + void SwitchEndianess( void ); +}; + +#endif diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_VariousBMPutilities.h b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_VariousBMPutilities.h new file mode 100644 index 0000000..3a2f464 --- /dev/null +++ b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/EasyBMP_VariousBMPutilities.h @@ -0,0 +1,53 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMP_VariousBMPutilities.h * +* date added: 05-02-2005 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Various utilities. * +* * +*************************************************/ + +#ifndef _EasyBMP_VariousBMPutilities_h_ +#define _EasyBMP_VariousBMPutilities_h_ + +typedef union { + int ratio; + int keepsize; + struct { + short width; + short height; + } dimension; +} ScaleParam; + +BMFH GetBMFH( const char* szFileNameIn ); +BMIH GetBMIH( const char* szFileNameIn ); +void DisplayBitmapInfo( const char* szFileNameIn ); +int GetBitmapColorDepth( const char* szFileNameIn ); +void PixelToPixelCopy( BMP& From, int FromX, int FromY, + BMP& To, int ToX, int ToY); +void PixelToPixelCopyTransparent( BMP& From, int FromX, int FromY, + BMP& To, int ToX, int ToY, + RGBApixel& Transparent ); +void RangedPixelToPixelCopy( BMP& From, int FromL , int FromR, int FromB, int FromT, + BMP& To, int ToX, int ToY ); +void RangedPixelToPixelCopyTransparent( + BMP& From, int FromL , int FromR, int FromB, int FromT, + BMP& To, int ToX, int ToY , + RGBApixel& Transparent ); +bool CreateGrayscaleColorTable( BMP& InputImage ); + +bool Rescale( BMP& InputImage , char mode, ScaleParam scale ); + + +#endif diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPbackground.bmp b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPbackground.bmp new file mode 100644 index 0000000..ae1dfa2 Binary files /dev/null and b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPbackground.bmp differ diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPsample.cpp b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPsample.cpp new file mode 100644 index 0000000..2b25ca2 --- /dev/null +++ b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPsample.cpp @@ -0,0 +1,82 @@ +/************************************************* +* * +* EasyBMP Cross-Platform Windows Bitmap Library * +* * +* Author: Paul Macklin * +* email: macklin01@users.sourceforge.net * +* support: http://easybmp.sourceforge.net * +* * +* file: EasyBMPsample.cpp * +* date added: 03-31-2006 * +* date modified: 12-01-2006 * +* version: 1.06 * +* * +* License: BSD (revised/modified) * +* Copyright: 2005-6 by the EasyBMP Project * +* * +* description: Sample application to demonstrate * +* some functions and capabilities * +* * +*************************************************/ + +#include "EasyBMP.h" +using namespace std; + +int main( int argc, char* argv[] ) +{ + cout << endl + << "Using EasyBMP Version " << _EasyBMP_Version_ << endl << endl + << "Copyright (c) by the EasyBMP Project 2005-6" << endl + << "WWW: http://easybmp.sourceforge.net" << endl << endl; + + BMP Text; + Text.ReadFromFile("EasyBMPtext.bmp"); + + BMP Background; + Background.ReadFromFile("EasyBMPbackground.bmp"); + + BMP Output; + Output.SetSize( Background.TellWidth() , Background.TellHeight() ); + Output.SetBitDepth( 24 ); + + RangedPixelToPixelCopy( Background, 0, Output.TellWidth()-1, + Output.TellHeight()-1 , 0, + Output, 0,0 ); + + RangedPixelToPixelCopyTransparent( Text, 0, 380, + 43, 0, + Output, 110,5, + *Text(0,0) ); + + RangedPixelToPixelCopyTransparent( Text, 0, Text.TellWidth()-1, + Text.TellWidth()-1, 50, + Output, 100,442, + *Text(0,49) ); + + Output.SetBitDepth( 32 ); + cout << "writing 32bpp ... " << endl; + Output.WriteToFile( "EasyBMPoutput32bpp.bmp" ); + + Output.SetBitDepth( 24 ); + cout << "writing 24bpp ... " << endl; + Output.WriteToFile( "EasyBMPoutput24bpp.bmp" ); + + Output.SetBitDepth( 8 ); + cout << "writing 8bpp ... " << endl; + Output.WriteToFile( "EasyBMPoutput8bpp.bmp" ); + + Output.SetBitDepth( 4 ); + cout << "writing 4bpp ... " << endl; + Output.WriteToFile( "EasyBMPoutput4bpp.bmp" ); + + Output.SetBitDepth( 1 ); + cout << "writing 1bpp ... " << endl; + Output.WriteToFile( "EasyBMPoutput1bpp.bmp" ); + + Output.SetBitDepth( 24 ); + Rescale( Output, 'p' , 50 ); + cout << "writing 24bpp scaled image ..." << endl; + Output.WriteToFile( "EasyBMPoutput24bpp_rescaled.bmp" ); + + return 0; +} diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPtext.bmp b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPtext.bmp new file mode 100644 index 0000000..6a9e00c Binary files /dev/null and b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/EasyBMPtext.bmp differ diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/makefile b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/makefile new file mode 100644 index 0000000..591c649 --- /dev/null +++ b/utility/demo-fw/pc-tools/CreateDemoBin/lib/EasyBMP/sample/makefile @@ -0,0 +1,53 @@ +# +# EasyBMP Cross-Platform Windows Bitmap Library +# +# Author: Paul Macklin +# email: macklin01@users.sourceforge.net +# support: http://easybmp.sourceforge.net +# file: makefile +# date added: 04-22-2006 +# date modified: 12-01-2006 +# version: 1.06 +# +# License: BSD (revised/modified) +# Copyright: 2005-6 by the EasyBMP Project +# +# description: Sample makefile for compiling with +# the EasyBMP library. This compiles +# the EasyBMPsample.cpp program. +# + +CC = g++ + +# this line gives compiler optimizations that are geared towards g++ and Pentium4 +# computers. Comment it out if you don't have a Pentium 4 (or Athlon XP) or up + +# CFLAGS = -O3 -Wno-deprecated -mcpu=pentium4 -march=pentium4 \ +# -mfpmath=sse -msse -mmmx -msse2 -pipe -fomit-frame-pointer -s + +# Uncomment these two lines to use with any Pentium with MMX or up. + +# CFLAGS = -Wno-deprecated -mcpu=pentium -march=pentium -pipe \ +# -fomit-frame-pointer -mmmx -funroll-all-loops -s + +# Uncomment these lines for some "safe" optimization flags + +CFLAGS = -O3 -pipe -fomit-frame-pointer -funroll-all-loops -s + +EasyBMPTest: EasyBMP.o EasyBMPsample.o + g++ $(CFLAGS) EasyBMP.o EasyBMPsample.o -o EasyBMPtest + +EasyBMP.o: ../EasyBMP.cpp ../EasyBMP*.h + cp ../EasyBMP*.h . + cp ../EasyBMP.cpp . + g++ $(CFLAGS) -c EasyBMP.cpp + +EasyBMPsample.o: EasyBMPsample.cpp + g++ -c EasyBMPsample.cpp + +clean: + rm EasyBMP*.h + rm EasyBMP.cpp + rm EasyBMPtest* + rm EasyBMPoutput*.bmp + rm -f *.o diff --git a/utility/demo-fw/pc-tools/CreateDemoBin/lib/libregex.a b/utility/demo-fw/pc-tools/CreateDemoBin/lib/libregex.a new file mode 100644 index 0000000..c20b68d Binary files /dev/null and b/utility/demo-fw/pc-tools/CreateDemoBin/lib/libregex.a differ -- cgit v1.2.3