Changeset 7327 for trunk/src/gdi32/blit.cpp
- Timestamp:
- Nov 13, 2001, 2:18:22 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/blit.cpp
r6692 r7327 1 /* $Id: blit.cpp,v 1.3 4 2001-09-10 11:02:40sandervl Exp $ */1 /* $Id: blit.cpp,v 1.35 2001-11-13 13:18:22 sandervl Exp $ */ 2 2 3 3 /* … … 147 147 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : 0x001f; 148 148 break; 149 150 case 24: 149 151 case 32: 150 152 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000; … … 226 228 const BITMAPINFO *info, UINT coloruse) 227 229 { 230 static BOOL fMatrox32BppBug = FALSE; 231 INT rc = 0; 232 char *newBits = NULL; 233 234 //If upside down, reverse scanlines and call SetDIBitsToDevice again 228 235 if(info->bmiHeader.biHeight < 0 && info->bmiHeader.biBitCount != 8 && info->bmiHeader.biCompression == 0) { 229 236 // upside down 230 INT rc = 0;237 INT rc = -1; 231 238 BITMAPINFO newInfo; 232 239 newInfo.bmiHeader = info->bmiHeader; … … 244 251 pbSrc -= lLineByte; 245 252 } 246 rc = SetDIBitsToDevice _( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (void *)newBits, &newInfo, DIB_RGB_COLORS);253 rc = SetDIBitsToDevice( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (void *)newBits, &newInfo, coloruse ); 247 254 free( newBits ); 248 255 } 256 else DebugInt3(); 257 249 258 return rc; 250 259 } 260 261 //We must convert 32 bpp bitmap data to 24 bpp on systems with the Matrox 262 //display driver. (GpiDrawBits for 32 bpp fails with insufficient memory error) 263 if(info->bmiHeader.biBitCount == 32 && fMatrox32BppBug) 264 { 265 BITMAPINFO newInfo; 266 newInfo.bmiHeader = info->bmiHeader; 267 268 long lLineWidth; 269 long lHeight = (newInfo.bmiHeader.biHeight > 0) ? newInfo.bmiHeader.biHeight : -newInfo.bmiHeader.biHeight; 270 long lWidth = newInfo.bmiHeader.biWidth; 271 272 newInfo.bmiHeader.biBitCount = 24; 273 newInfo.bmiHeader.biSizeImage = CalcBitmapSize(24, newInfo.bmiHeader.biWidth, 274 newInfo.bmiHeader.biHeight); 275 276 lLineWidth = newInfo.bmiHeader.biSizeImage / lHeight; 277 278 //convert 32 bits bitmap data to 24 bits 279 newBits = (char *)malloc(newInfo.bmiHeader.biSizeImage+16); //extra room needed for copying (too much) 280 if(!newBits) { 281 DebugInt3(); 282 return -1; 283 } 284 unsigned char *pbSrc = (unsigned char *)bits; 285 unsigned char *pbDst = (unsigned char *)newBits; 286 //not very efficient 287 for(int i = 0; i < lHeight; i++) { 288 for(int j=0;j<lWidth;j++) { 289 *(DWORD *)pbDst = *(DWORD *)pbSrc; 290 pbSrc += 4; 291 pbDst += 3; 292 } 293 //24 bpp scanline must be aligned at 4 byte boundary 294 pbDst += (lLineWidth - 3*lWidth); 295 } 296 rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, newBits, &newInfo, coloruse ); 297 free(newBits); 298 return rc; 299 } 300 rc = SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse ); 301 302 if(rc == -1 && info->bmiHeader.biBitCount == 32 && !fMatrox32BppBug) 303 { 304 //The Matrox driver seems to have some difficulty blitting 32bpp 305 //data. (out of memory error) The same operation works fine with SDD. 306 fMatrox32BppBug = TRUE; 307 return SetDIBitsToDevice(hdc, xDest, yDest, cx, 308 cy, xSrc, ySrc, 309 startscan, lines, bits, 310 info, coloruse); 311 } 312 return rc; 313 251 314 //SvL: Breaks startup bitmap of Acrobat Reader 4.05 252 315 #if 0 … … 319 382 } 320 383 #endif 321 else {322 return SetDIBitsToDevice_( hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, bits, info, coloruse );323 }324 384 } 325 385 //****************************************************************************** … … 441 501 bitfields[2] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *((DWORD *)info->bmiColors + 2) : 0x001f; 442 502 break; 503 case 24: 443 504 case 32: 444 505 bitfields[0] = (info->bmiHeader.biCompression == BI_BITFIELDS) ? *(DWORD *)info->bmiColors : 0xff0000; … … 470 531 ((BITMAPINFO *)info)->bmiHeader.biCompression = 0; 471 532 compression = BI_BITFIELDS; 472 473 533 } 474 534 … … 629 689 630 690 case 32: 631 return cx*cy ;691 return cx*cy*4; 632 692 633 693 default:
Note:
See TracChangeset
for help on using the changeset viewer.