Changeset 549 for trunk/dll/loadbmp.c
- Timestamp:
- Feb 4, 2007, 4:14:36 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/loadbmp.c
r351 r549 7 7 8 8 Copyright (c) 1993-98 M. Kimes 9 Copyright (c) 2006 Steven H.Levine9 Copyright (c) 2006, 2007 Steven H.Levine 10 10 11 11 22 Jul 06 SHL Check more run time errors 12 16 Jan 07 SHL Check more run time errors 13 16 Jan 07 SHL Sync variable names for sanity 14 16 Jan 07 SHL Open bitmap file binary - no wonder the code does not work 15 16 Jan 07 SHL Beautify with indent -i2 12 16 13 17 ***********************************************************************/ … … 29 33 #pragma alloc_text(LOADBITMAP,LoadBitmapFromFile,LoadBitmapFromFileNum) 30 34 31 32 HBITMAP LoadBitmapFromFileNum (USHORT id) 35 HBITMAP LoadBitmapFromFileNum(USHORT id) 33 36 { 34 37 char s[CCHMAXPATH]; 35 38 36 39 save_dir2(s); 37 sprintf(s + strlen(s), "\\%u.BMP",id);40 sprintf(s + strlen(s), "\\%u.BMP", id); 38 41 return LoadBitmapFromFile(s); 39 42 } 40 43 41 42 HBITMAP LoadBitmapFromFile (CHAR *pszFileName) 44 HBITMAP LoadBitmapFromFile(CHAR * pszFileName) 43 45 { 44 HBITMAP hBmp = (HBITMAP)0; 45 FILE *File; 46 ULONG rc; 47 USHORT usType = 0; // #@!!! compiler warnings 48 PBITMAPARRAYFILEHEADER2 pbafh2 = NULL; // (MAM) chng init values to NULL instead of ptr to 0 49 PBITMAPFILEHEADER2 pbfh2 = NULL; 50 PBITMAPINFOHEADER2 pbih2 = NULL; 51 PBITMAPINFO2 pbmi2 = NULL; 52 PBITMAPARRAYFILEHEADER pbafh = NULL; 53 PBITMAPFILEHEADER pbfh = NULL; 54 PBITMAPINFOHEADER pbih = NULL; 55 BOOL f2; // format 1.x or 2.x 56 ULONG ulOffset; 57 PBYTE pData = NULL; 58 ULONG ulDataSize; 59 SIZEL sizel; 60 HPS hPS = WinGetPS(HWND_DESKTOP); 61 62 //--- open the file 63 File = _fsopen(pszFileName,"r",SH_DENYWR); 64 if(!File) 65 goto ExitLoadBMP; 66 67 /* Read image type, and reset the stream...................................*/ 68 /* The image type is a USHORT, so we only read that........................*/ 69 rc = fread(&usType,1,sizeof(usType),File); 70 if(rc != sizeof(usType)) 71 goto ExitLoadBMP; 72 73 /* Next read the bitmap info header........................................*/ 74 // we allocate enough to hold a complete bitmap array file header 75 pbafh2 = xmalloc(sizeof(*pbafh2) + 256 * sizeof(RGB2),pszSrcFile,__LINE__); 76 if(!pbafh2) 77 goto ExitLoadBMP; 78 /* Next we assign pointers to the file header and bitmap info header...*/ 79 /* Both the 1.x and 2.x structures are assigned just in case...........*/ 80 pbfh2 = &pbafh2->bfh2; 81 pbih2 = &pbfh2->bmp2; 82 pbmi2 = (PBITMAPINFO2)pbih2; 83 pbafh = (PBITMAPARRAYFILEHEADER)pbafh2; 84 pbfh = &pbafh->bfh; 85 pbih = &pbfh->bmp; 46 HBITMAP hBmp = (HBITMAP) 0; 47 FILE *pf; 48 ULONG rc; 49 USHORT usType; 50 PBITMAPARRAYFILEHEADER2 pbmafh2 = NULL; // Must init for xfree 51 PBITMAPFILEHEADER2 pbmfh2; // No color table 52 PBITMAPINFOHEADER2 pbmih2; // No color table 53 PBITMAPINFO2 pbmi2; // Includes color table 54 BOOL is2x; // Format 1.x or 2.x 55 ULONG ulColors; 56 ULONG ulRGBOffset; 57 PBYTE pData = NULL; // Must init for xfree 58 ULONG ulDataSize; 59 SIZEL sizel; 60 HPS hPS = WinGetPS(HWND_DESKTOP); 61 62 if (!hPS) { 63 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 64 "WinGetPS"); 65 goto ExitLoadBMP; 66 } 67 68 pf = _fsopen(pszFileName, "rb", SH_DENYWR); 69 if (!pf) { 70 // OK for file to not exist - enable following for debug as needed 71 // Runtime_Error(pszSrcFile, __LINE__, "_fsopen %s", pszFileName); 72 goto ExitLoadBMP; 73 } 74 75 // Read image type 76 // fixme to just read type2 header - this is silly and wastes time 77 rc = fread(&usType, 1, sizeof(usType), pf); 78 if (rc != sizeof(usType)) { 79 Runtime_Error(pszSrcFile, __LINE__, "fread"); 80 goto ExitLoadBMP; 81 } 82 83 /* Read bitmap info header 84 Allocate enough to hold a complete 2.x bitmap array file header 85 fixme to support > 256 colors? 86 */ 87 pbmafh2 = 88 xmalloc(sizeof(*pbmafh2) + 256 * sizeof(RGB2), pszSrcFile, __LINE__); 89 if (!pbmafh2) 90 goto ExitLoadBMP; 91 /* Assign pointers to the file header and bitmap info header etc. 92 Both the 1.x and 2.x structures are assigned to simplify code 93 fixme to clean this up - aliased pointers are evil 94 */ 95 pbmfh2 = &pbmafh2->bfh2; 96 pbmih2 = &pbmfh2->bmp2; 97 pbmi2 = (PBITMAPINFO2)pbmih2; 98 86 99 switch (usType) { 87 case BFT_BMAP: 88 case BFT_ICON: 89 case BFT_POINTER: 90 case BFT_COLORICON: 91 case BFT_COLORPOINTER: 92 { 93 /* Now we assume the image is a 2.0 image and so we read a bitmap-file-*/ 94 /* Now we reset the stream, next we'll read the bitmap info header. To do .*/ 95 /* this we need to reset the stream to 0...................................*/ 96 fseek(File,0,SEEK_SET); 97 /*-header-2 structure..................................................*/ 98 rc = fread(pbfh2,1,sizeof(*pbfh2),File); 99 if(rc != sizeof(*pbfh2)) 100 goto ExitLoadBMP; 101 102 f2 = pbih2->cbFix > sizeof(*pbih); // 1.x or 2.x bitmap 103 /* We will need to read the color table. Thus we position the stream...*/ 104 /* so that the next read will read IT. This, of course, depends on the.*/ 105 /* type of the bitmap (old vs new), note that in the NEW case, we can..*/ 106 /* not be certain of the size of the bitmap header.....................*/ 107 ulOffset = (f2) ? sizeof(*pbfh2) + pbih->cbFix - sizeof(*pbih2) : 108 sizeof(*pbfh); 109 } 110 break; 111 112 case BFT_BITMAPARRAY: 113 { 114 /* Now we are dealing with a bitmap array. This is a collection of ....*/ 115 /* bitmap files and each has its own file header.......................*/ 116 117 BOOL bBest = FALSE; 118 ULONG ulCurOffset, ulOffsetTemp = 0; 119 LONG lScreenWidth; 120 LONG lScreenHeight; 121 LONG lClrsDev, lClrsTemp = 0; 122 LONG lClrs; 123 ULONG ulSizeDiff, ulSizeDiffTemp = 0xffffffff; 124 HDC hdc; 125 126 // -- We will browse through the array and chose the bitmap best suited 127 // -- for the current display size and color capacities. 128 hdc = GpiQueryDevice( hPS ); 129 DevQueryCaps(hdc,CAPS_COLORS,1,&lClrsDev); 130 DevQueryCaps(hdc,CAPS_WIDTH, 1,&lScreenWidth); 131 DevQueryCaps(hdc,CAPS_HEIGHT,1,&lScreenHeight); 132 pbafh2->offNext = 0; 133 do { 134 ulCurOffset = pbafh2->offNext; 135 rc = fseek(File,pbafh2->offNext,SEEK_SET); 136 if(rc) 137 goto ExitLoadBMP; 138 rc = fread(pbafh2,1,sizeof(*pbafh2),File); 139 if(rc != sizeof(*pbafh2)) 140 goto ExitLoadBMP; 141 f2 = pbih2->cbFix > sizeof(*pbih); 142 if(f2) 143 lClrs = 1 << (pbafh2->bfh2.bmp2.cBitCount * 144 pbafh2->bfh2.bmp2.cPlanes); 145 else 146 lClrs = 1 << (pbafh->bfh.bmp.cBitCount * 147 pbafh->bfh.bmp.cPlanes); 148 if((pbafh2->cxDisplay == 0) && (pbafh2->cyDisplay == 0)) { 149 // This is a device independant bitmap 150 // Process it as a VGA 151 pbafh2->cxDisplay = 640; 152 pbafh2->cyDisplay = 480; 153 } // endif 154 ulSizeDiff = abs(pbafh2->cxDisplay - lScreenWidth) + 155 abs(pbafh2->cyDisplay - lScreenHeight); 156 if((lClrsDev == lClrs) && 157 (ulSizeDiff == 0)) { 158 // We found the perfect match 159 bBest = TRUE; 160 ulOffsetTemp = ulCurOffset; 161 } 162 else { 163 if((ulOffsetTemp == 0) || // First time thru 164 (ulSizeDiff < ulSizeDiffTemp) || // Better fit than any previous 165 ((lClrs > lClrsTemp) && (lClrs < lClrsDev)) || // More colors than prev & less than device 166 ((lClrs < lClrsTemp) && (lClrs > lClrsDev))) { 167 ulOffsetTemp = ulCurOffset; // Make this our current pick 168 lClrsTemp = lClrs; 169 ulSizeDiffTemp = ulSizeDiff; 170 } // endif 171 } // endif 172 } while((pbafh2->offNext != 0) && !bBest); // enddo 173 174 // Now retrieve the best bitmap 175 rc = fseek(File,ulOffsetTemp,SEEK_SET); 176 if(rc) 177 goto ExitLoadBMP; 178 rc = fread(pbafh2,1,sizeof(*pbafh2),File); 179 if(rc != sizeof(*pbafh2)) 180 goto ExitLoadBMP; 181 182 f2 = pbih2->cbFix > sizeof(*pbih); 183 /* as before, we calculate where to position the stream in order to ...*/ 184 /* read the color table information....................................*/ 185 ulOffset = ulOffsetTemp; 186 ulOffset += (f2) ? sizeof(*pbafh2) + pbih2->cbFix - sizeof(*pbih2): 187 sizeof(*pbafh); 188 } 189 break; 190 191 default: 192 goto ExitLoadBMP; 193 } /* endswitch */ 194 195 /* We now position the stream on the color table information...............*/ 196 rc = fseek(File,ulOffset,SEEK_SET); 197 if(rc) 198 goto ExitLoadBMP; 199 200 /* Read the color table....................................................*/ 201 if(f2) { 202 /* For a 2.0 bitmap, all we need to do is read the color table...........*/ 203 /* The bitmap info structure is just the header + color table............*/ 204 // If we have 24 bits per pel, there is usually no color table, unless 205 // pbih2->cclrUsed or pbih2->cclrImportant are non zero, we should 206 // test that ! 207 if(pbih2->cBitCount < 24) { 208 209 ULONG ul = (1 << pbih2->cBitCount) * sizeof(RGB2); 210 211 rc = fread(&pbmi2->argbColor[0],1,ul,File); 212 if(rc != ul) 213 goto ExitLoadBMP; 214 } // endif 215 /* remember the bitmap info we mentioned just above?.....................*/ 216 pbmi2 = (PBITMAPINFO2)pbih2; 100 case BFT_BMAP: 101 case BFT_ICON: 102 case BFT_POINTER: 103 case BFT_COLORICON: 104 case BFT_COLORPOINTER: 105 { 106 /* Assume image is a 2.0 image and read as a 2.x header 107 OK for 1.x file - read will not fail unless file is corrupted 108 */ 109 rc = fseek(pf, 0, SEEK_SET); 110 if (rc) { 111 Runtime_Error(pszSrcFile, __LINE__, "fseek 0"); 112 goto ExitLoadBMP; 113 } 114 115 rc = fread(pbmfh2, 1, sizeof(*pbmfh2), pf); 116 if (rc != sizeof(*pbmfh2)) { 117 Runtime_Error(pszSrcFile, __LINE__, "fread"); 118 goto ExitLoadBMP; 119 } 120 121 is2x = pbmih2->cbFix > sizeof(BITMAPINFOHEADER); // 1.x or 2.x bitmap 122 /* We will read the color table later 123 Color table follows header but 124 location depends on the type of the bitmap (old vs new) 125 1.x header is fixed size 126 2.x header is variable sized, so offset must be calculated 127 cbFix contains actual size of BITMAPINFOHEADER2 in file 128 */ 129 ulRGBOffset = is2x ? sizeof(*pbmfh2) - sizeof(*pbmih2) + pbmih2->cbFix : 130 sizeof(BITMAPFILEHEADER); 131 } 132 break; 133 134 case BFT_BITMAPARRAY: 135 { 136 /* Now we are dealing with a bitmap array which is a collection of bitmaps 137 Each bitmap has its own file header 138 */ 139 140 ULONG ulCurOffset; 141 ULONG clScreenWidth; 142 ULONG clScreenHeight; 143 ULONG ulDeviceColors; 144 ULONG ulSizeDiff; 145 ULONG ulOffsetPicked = 0; 146 ULONG ulColorsPicked; 147 ULONG ulSizeDiffPicked; 148 HDC hdc; 149 150 /* Scan the array and chose the bitmap best suited 151 for the current display size and color capacities 152 */ 153 hdc = GpiQueryDevice(hPS); 154 if (!hdc) { 155 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 156 "GpiQueryDevice"); 157 goto ExitLoadBMP; 158 } 159 DevQueryCaps(hdc, CAPS_COLORS, 1, (PLONG)&ulDeviceColors); 160 DevQueryCaps(hdc, CAPS_WIDTH, 1, (PLONG)&clScreenWidth); 161 DevQueryCaps(hdc, CAPS_HEIGHT, 1, (PLONG)&clScreenHeight); 162 pbmafh2->offNext = 0; 163 do { 164 ulCurOffset = pbmafh2->offNext; 165 rc = fseek(pf, pbmafh2->offNext, SEEK_SET); 166 if (rc) { 167 Runtime_Error(pszSrcFile, __LINE__, "fseek %ld", pbmafh2->offNext); 168 goto ExitLoadBMP; 169 } 170 rc = fread(pbmafh2, 1, sizeof(*pbmafh2), pf); 171 if (rc != sizeof(*pbmafh2)) { 172 Runtime_Error(pszSrcFile, __LINE__, "fread"); 173 goto ExitLoadBMP; 174 } 175 is2x = pbmih2->cbFix > sizeof(BITMAPINFOHEADER); 176 if (is2x) { 177 ulColors = 1 << (pbmafh2->bfh2.bmp2.cBitCount * 178 pbmafh2->bfh2.bmp2.cPlanes); 179 } 180 else { 181 ulColors = 1 << (((PBITMAPARRAYFILEHEADER)pbmafh2)->bfh.bmp.cBitCount * 182 ((PBITMAPARRAYFILEHEADER)pbmafh2)->bfh.bmp.cPlanes); 183 } 184 if (pbmafh2->cxDisplay == 0 && pbmafh2->cyDisplay == 0) { 185 // This is a device independant bitmap - process it as a VGA 186 pbmafh2->cxDisplay = 640; 187 pbmafh2->cyDisplay = 480; 188 } 189 ulSizeDiff = abs(pbmafh2->cxDisplay - clScreenWidth) + 190 abs(pbmafh2->cyDisplay - clScreenHeight); 191 if (ulDeviceColors == ulColors && ulSizeDiff == 0) { 192 // We found the perfect match 193 ulOffsetPicked = ulCurOffset; 194 break; // Stop scan 195 } 196 if (ulOffsetPicked == 0 || // First time thru 197 ulSizeDiff < ulSizeDiffPicked || // Better fit than any previous 198 (ulColors > ulColorsPicked && ulColors < ulDeviceColors) || // More colors than prev & less than device 199 (ulColors < ulColorsPicked && ulColors > ulDeviceColors)) 200 { 201 ulOffsetPicked = ulCurOffset; // Make this our current pick 202 ulColorsPicked = ulColors; 203 ulSizeDiffPicked = ulSizeDiff; 204 } 205 } while (pbmafh2->offNext != 0); 206 207 // Retrieve the selected bitmap 208 rc = fseek(pf, ulOffsetPicked, SEEK_SET); 209 if (rc) { 210 Runtime_Error(pszSrcFile, __LINE__, "fseek %ld", ulOffsetPicked); 211 goto ExitLoadBMP; 212 } 213 rc = fread(pbmafh2, 1, sizeof(*pbmafh2), pf); 214 if (rc != sizeof(*pbmafh2)) { 215 Runtime_Error(pszSrcFile, __LINE__, "fread"); 216 goto ExitLoadBMP; 217 } 218 219 is2x = pbmih2->cbFix > sizeof(BITMAPINFOHEADER); 220 /* As before, we calculate offset in file stream to color table 221 This code must match single bitmap logic 222 */ 223 ulRGBOffset = ulOffsetPicked; 224 ulRGBOffset += is2x ? sizeof(*pbmafh2) - sizeof(*pbmih2) + pbmih2->cbFix : 225 sizeof(BITMAPARRAYFILEHEADER); 226 } 227 break; 228 229 default: 230 Runtime_Error(pszSrcFile, __LINE__, "Bad type %u", usType); 231 goto ExitLoadBMP; 232 } // endswitch 233 234 // Position to color table 235 rc = fseek(pf, ulRGBOffset, SEEK_SET); 236 if (rc) { 237 Runtime_Error(pszSrcFile, __LINE__, "fseek %ld", ulRGBOffset); 238 goto ExitLoadBMP; 239 } 240 241 // Read color table 242 if (is2x) { 243 /* For a 2.0 bitmap, read the color table as is 244 The bitmap info structure is header + color table 245 If we have 24 bits per pel, there is usually no color table, unless 246 pbmih2->cclrUsed or pbmih2->cclrImportant are non zero 247 fixme to test this 248 */ 249 if (pbmih2->cBitCount < 24) { 250 ULONG ulRGBBytes; 251 ulColors = 1L << pbmih2->cBitCount; 252 253 if (ulColors > 256) { 254 Runtime_Error(pszSrcFile, __LINE__, "RGB exceeds 256 colors: %lu", ulColors); 255 goto ExitLoadBMP; 256 } 257 ulRGBBytes = ulColors * sizeof(RGB2); 258 rc = fread(&pbmi2->argbColor[0], 1, ulRGBBytes, pf); 259 if (rc != ulRGBBytes) { 260 Runtime_Error(pszSrcFile, __LINE__, "fread"); 261 goto ExitLoadBMP; 262 } 263 } // endif 264 // Get pointer to bitmap info (header and color table) 265 pbmi2 = (PBITMAPINFO2)pbmih2; 217 266 } 218 267 else { 219 /* This is an old format bitmap. Since the common format is the 2.0......*/ 220 /* We have to convert all the RGB entries to RGB2........................*/ 221 222 ULONG ul, cColors; 223 RGB rgb; 224 225 if(pbih->cBitCount <24) 226 cColors = 1 << pbih->cBitCount; 227 else 228 // If there are 24 bits per pel, the 24 bits are assumed to be a RGB value 229 cColors = 0; 230 /* Loop over the original table and create the new table, the extra byte.*/ 231 /* has to be 0...........................................................*/ 232 for(ul = 0; ul < cColors; ul++) { 233 fread(&rgb,1,sizeof(rgb),File); 234 pbmi2->argbColor[ul].bRed = rgb.bRed; 235 pbmi2->argbColor[ul].bGreen = rgb.bGreen; 236 pbmi2->argbColor[ul].bBlue = rgb.bBlue; 237 pbmi2->argbColor[ul].fcOptions = 0; 238 } /* endfor */ 239 240 // we have to convert the old to the new version header 241 pbmi2->cbFix = sizeof(*pbih2); 242 pbmi2->cBitCount = pbih->cBitCount; 243 pbmi2->cPlanes = pbih->cPlanes; 244 pbmi2->cy = pbih->cy; 245 pbmi2->cx = pbih->cx; 268 /* This is a 1.x format bitmap 269 Since the current standard format is the 2.0 270 convert the header and color table to 2.x format 271 */ 272 ULONG ul; 273 RGB rgb; 274 PBITMAPINFOHEADER pbmih = &((PBITMAPARRAYFILEHEADER)pbmafh2)->bfh.bmp; 275 276 if (pbmih->cBitCount < 24) { 277 ulColors = 1 << pbmih->cBitCount; 278 if (ulColors > 256) { 279 Runtime_Error(pszSrcFile, __LINE__, "RGB exceeds 256 colors: %lu", ulColors); 280 goto ExitLoadBMP; 281 } 282 // Read in 1.x color table and reformat for 2.x 283 for (ul = 0; ul < ulColors; ul++) { 284 fread(&rgb, 1, sizeof(rgb), pf); 285 pbmi2->argbColor[ul].bRed = rgb.bRed; 286 pbmi2->argbColor[ul].bGreen = rgb.bGreen; 287 pbmi2->argbColor[ul].bBlue = rgb.bBlue; 288 pbmi2->argbColor[ul].fcOptions = 0; // initialize 2.x extra byte to 0 289 } // for 290 } 291 292 // Convert the old style to the new header format 293 pbmi2->cbFix = sizeof(BITMAPINFOHEADER2); 294 pbmi2->cBitCount = pbmih->cBitCount; 295 pbmi2->cPlanes = pbmih->cPlanes; 296 pbmi2->cy = pbmih->cy; 297 pbmi2->cx = pbmih->cx; 246 298 // set rest to zero 247 memset((PCHAR)pbmi2 + 16,0,sizeof(*pbih2) - 16); 248 } /* endif */ 249 250 /* We have the 2.0 bitmap info structure set...............................*/ 251 /* move to the stream to the start of the bitmap data......................*/ 252 rc = fseek(File,pbfh2->offBits,SEEK_SET); 253 if(rc) 254 goto ExitLoadBMP; 255 256 /* Read the bitmap data, the read size is derived using the magic formula..*/ 257 /* The bitmap scan line is aligned on a doubleword boundary................*/ 258 /* The size of the scan line is the number of pels times the bpp...........*/ 259 /* After aligning it, we divide by 4 to get the number of bytes, and.......*/ 260 /* multiply by the number of scan lines and the number of pel planes.......*/ 261 if(pbmi2->ulCompression) 299 memset((PCHAR)pbmi2 + 16, 0, sizeof(BITMAPINFOHEADER2) - 16); 300 } // if 1.x 301 302 /* The 2.0 bitmap info structure set up 303 Position to start of the bitmap data 304 */ 305 rc = fseek(pf, pbmfh2->offBits, SEEK_SET); 306 if (rc) { 307 Runtime_Error(pszSrcFile, __LINE__, "fseek %ld", pbmfh2->offBits); 308 goto ExitLoadBMP; 309 } 310 311 /* Read the bitmap data 312 The read size is derived using the magic formula 313 Each bitmap scan line is aligned on a doubleword boundary 314 The size of the scan line is the number of pels times the bpp 315 After aligning it, we divide by 4 to get the number of bytes, and 316 multiply by the number of scan lines and the number of pel planes 317 */ 318 if (pbmi2->ulCompression) 262 319 ulDataSize = pbmi2->cbImage; 263 320 else 264 321 ulDataSize = (((pbmi2->cBitCount * pbmi2->cx) + 31) / 32) * 4 * 265 pbmi2->cy * pbmi2->cPlanes; 266 pData = xmalloc(ulDataSize,pszSrcFile,__LINE__); 267 if(!pData) 268 goto ExitLoadBMP; 269 rc = fread(pData, 1, ulDataSize, File); 270 if(rc != ulDataSize) 271 goto ExitLoadBMP; 272 273 /* Now, we create the bitmap...............................................*/ 322 pbmi2->cy * pbmi2->cPlanes; 323 pData = xmalloc(ulDataSize, pszSrcFile, __LINE__); 324 if (!pData) 325 goto ExitLoadBMP; 326 rc = fread(pData, 1, ulDataSize, pf); 327 if (rc != ulDataSize) { 328 Runtime_Error(pszSrcFile, __LINE__, "fread"); 329 goto ExitLoadBMP; 330 } 331 332 // Create the GPI bitmap image 274 333 sizel.cx = pbmi2->cx; 275 334 sizel.cy = pbmi2->cy; 276 335 277 hBmp = GpiCreateBitmap(hPS,(PBITMAPINFOHEADER2)pbmi2,CBM_INIT, 278 pData,pbmi2); 336 hBmp = GpiCreateBitmap(hPS, (PBITMAPINFOHEADER2) pbmi2, CBM_INIT, 337 pData, pbmi2); 338 if (!hBmp) 339 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, 340 "GpiCreateBitmap"); 279 341 280 342 ExitLoadBMP: 281 343 282 344 xfree(pData); 283 xfree(pbafh2); 284 fclose(File); 285 WinReleasePS(hPS); 345 xfree(pbmafh2); 346 if (pf) 347 fclose(pf); 348 if (hPS) 349 WinReleasePS(hPS); 286 350 return hBmp; 287 351 } 288
Note:
See TracChangeset
for help on using the changeset viewer.