|
From: Nicolas B. <ar...@us...> - 2005-10-19 21:52:01
|
Update of /cvsroot/nbftools/TyphoonNbfTool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1351 Modified Files: DlgMain.cpp Splash.cpp Splash.h Log Message: Fix Tornado splash screen image extraction (now 240x320) Index: Splash.cpp =================================================================== RCS file: /cvsroot/nbftools/TyphoonNbfTool/Splash.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Splash.cpp 7 May 2005 14:06:42 -0000 1.1 +++ Splash.cpp 19 Oct 2005 21:51:53 -0000 1.2 @@ -7,17 +7,27 @@ #define GREEN_FROM_565(x) ((((x)>>5)&0x3F) << 2) #define BLUE_FROM_565(x) (((x)&0x1F) << 3) -bool CSplash::convertDumpToReadableBitmap(HANDLE bitmapFile, unsigned char *dump) { +bool CSplash::convertDumpToReadableBitmap(HANDLE bitmapFile, unsigned char *dump, bool large) { BITMAPFILEHEADER fileHeader = {0}; BITMAPINFO bitmapinfo; unsigned char *new_dump; int i; int j = 0; DWORD bytesWritten; + int x, y; + + if (!large) { + x = 176; + y = 220; + } + else { + x = 240; + y = 320; + } bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bitmapinfo.bmiHeader.biWidth = 176; - bitmapinfo.bmiHeader.biHeight = 220; + bitmapinfo.bmiHeader.biWidth = x; + bitmapinfo.bmiHeader.biHeight = y; bitmapinfo.bmiHeader.biPlanes = 1; bitmapinfo.bmiHeader.biBitCount = 24; bitmapinfo.bmiHeader.biCompression = BI_RGB; @@ -26,12 +36,12 @@ return false; fileHeader.bfType = 0x4d42; - fileHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + (176 * 220 * 3); + fileHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + (x * y * 3); fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); WriteFile(bitmapFile, &fileHeader, sizeof(BITMAPFILEHEADER), &bytesWritten, NULL); WriteFile(bitmapFile, &bitmapinfo.bmiHeader, sizeof(BITMAPINFOHEADER), &bytesWritten, NULL); - new_dump = (unsigned char*)malloc(176 * 220 * 3); - for (i=0; i<176*220*2; i+=2) { + new_dump = (unsigned char*)malloc(x * y * 3); + for (i=0; i<x*y*2; i+=2) { WORD work = (dump[i + 1] << 8) + dump[i]; unsigned char red = RED_FROM_565(work); unsigned char green = GREEN_FROM_565(work); @@ -42,10 +52,10 @@ } // Swap lines to return a non-inverted bitmap - unsigned char *offset_line = new_dump + (176 * 220 * 3) - (176 * 3); - for (i = 0; i<220; i++) { - WriteFile(bitmapFile, offset_line, 176 * 3, &bytesWritten, NULL); - offset_line -= (176 * 3); + unsigned char *offset_line = new_dump + (x * y * 3) - (x * 3); + for (i = 0; i<y; i++) { + WriteFile(bitmapFile, offset_line, x * 3, &bytesWritten, NULL); + offset_line -= (x * 3); } free(new_dump); @@ -152,8 +162,8 @@ char *SMARTPHONE_SIG = "This is smartphone signature.\0"; -bool CSplash::bin2bmp(unsigned char *dump, HANDLE bitmapFile) { - return convertDumpToReadableBitmap(bitmapFile, dump + SIGNATURE_SIZE); +bool CSplash::bin2bmp(unsigned char *dump, HANDLE bitmapFile, bool large) { + return convertDumpToReadableBitmap(bitmapFile, dump + SIGNATURE_SIZE, large); } bool CSplash::bmp2bin(HANDLE bitmapFile, unsigned char *dump) { Index: Splash.h =================================================================== RCS file: /cvsroot/nbftools/TyphoonNbfTool/Splash.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Splash.h 7 May 2005 14:06:42 -0000 1.1 +++ Splash.h 19 Oct 2005 21:51:53 -0000 1.2 @@ -11,12 +11,12 @@ class CSplash { public: - static bool bin2bmp(unsigned char *dump, HANDLE bitmapFile); + static bool bin2bmp(unsigned char *dump, HANDLE bitmapFile, bool large = false); static bool bmp2bin(HANDLE bitmapFile, unsigned char *dump); private: - static bool convertDumpToReadableBitmap(HANDLE bitmapFile, unsigned char *dump); + static bool convertDumpToReadableBitmap(HANDLE bitmapFile, unsigned char *dump, bool large); static bool convertBitmapToDump(HANDLE bitmapFile, unsigned char *dump); static bool load24BitsBitmap(HANDLE bitmapFile, unsigned char *dump, bool inverted); static bool load16BitsBitmap(HANDLE bitmapFile, unsigned char *dump, bool inverted); Index: DlgMain.cpp =================================================================== RCS file: /cvsroot/nbftools/TyphoonNbfTool/DlgMain.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- DlgMain.cpp 19 Oct 2005 21:00:36 -0000 1.17 +++ DlgMain.cpp 19 Oct 2005 21:51:53 -0000 1.18 @@ -407,7 +407,7 @@ free(splash); return TRUE; } - if (!CSplash::bin2bmp(splash, handle)) { + if (!CSplash::bin2bmp(splash, handle, CGlobals::pLoadedNbfFile->header()->isTornado())) { MessageBox(hwndDlg, TEXT("Error saving splash zone"), TEXT("I/O error"), MB_OK | MB_ICONERROR); free(splash); return TRUE; |