Changeset 2845 for trunk/src/gdi32/dibsect.cpp
- Timestamp:
- Feb 21, 2000, 11:34:46 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gdi32/dibsect.cpp
r2802 r2845 1 /* $Id: dibsect.cpp,v 1.1 8 2000-02-16 14:18:09sandervl Exp $ */1 /* $Id: dibsect.cpp,v 1.19 2000-02-21 10:34:46 sandervl Exp $ */ 2 2 3 3 /* … … 63 63 case 8: 64 64 os2bmpsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2); 65 bmpsize = (bmpsize + 3) & ~3; 65 66 break; 66 67 case 16: 67 68 bmpsize *= 2; 69 bmpsize = (bmpsize + 3) & ~3; 68 70 break; 69 71 case 24: 70 72 bmpsize *= 3; 73 bmpsize = (bmpsize + 3) & ~3; 71 74 break; 72 75 case 32: 73 76 bmpsize *= 4; 74 77 break; 75 }76 if(bmpsize & 3) {77 bmpsize = (bmpsize + 3) & ~3;78 78 } 79 79 … … 226 226 palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2); 227 227 os2bmpsize += palsize; 228 bmpsize = (bmpsize + 3) & ~3; 228 229 break; 229 230 case 16: 230 231 bmpsize *= 2; 232 bmpsize = (bmpsize + 3) & ~3; 231 233 break; 232 234 case 24: 233 235 bmpsize *= 3; 236 bmpsize = (bmpsize + 3) & ~3; 234 237 break; 235 238 case 32: … … 238 241 } 239 242 240 if(bmpsize & 3) 241 { 242 bmpsize = (bmpsize + 3) & ~3; 243 } 244 245 bmpBits = (char *)realloc(bmpBits, bmpsize*pbmi->biHeight); 243 //SvL: TODO: Correct?? 244 if(!hSection && pOS2bmp->cx != pbmi->biWidth && pOS2bmp->cy != pbmi->biHeight && 245 pOS2bmp->cBitCount != pbmi->biBitCount) 246 { 247 char *oldbits = bmpBits; 248 249 DosAllocMem((PPVOID)&bmpBits, bmpsize*pbmi->biHeight, PAG_READ|PAG_WRITE|PAG_COMMIT); 250 memcpy(bmpBits, oldbits, bmpsize*pbmi->biHeight); 251 DosFreeMem(oldbits); 252 } 246 253 pOS2bmp = (BITMAPINFO2 *)realloc(pOS2bmp, os2bmpsize); 247 248 254 pOS2bmp->cbFix = sizeof(BITMAPINFO2) - sizeof(RGB2); 249 255 pOS2bmp->cx = pbmi->biWidth; … … 254 260 pOS2bmp->cbImage = pbmi->biSizeImage; 255 261 262 // clear DIBSECTION structure 263 memset(&dibinfo, 0, sizeof(dibinfo)); 264 265 // copy BITMAPINFOHEADER data into DIBSECTION structure 266 memcpy(&dibinfo.dsBmih, pbmi, sizeof(*pbmi)); 267 dibinfo.dsBm.bmType = 0; 268 dibinfo.dsBm.bmWidth = pbmi->biWidth; 269 dibinfo.dsBm.bmHeight = pbmi->biHeight; 270 dibinfo.dsBm.bmWidthBytes= bmpsize; 271 dibinfo.dsBm.bmPlanes = pbmi->biPlanes; 272 dibinfo.dsBm.bmBitsPixel = pbmi->biBitCount; 273 dibinfo.dsBm.bmBits = bmpBits; 274 275 dibinfo.dshSection = hSection; 276 dibinfo.dsOffset = 0; // TODO: put the correct value here (if createdibsection with file handle) 277 278 if(pbmi->biCompression == BI_BITFIELDS) 279 { 280 char *pColors = (char *)pbmi + 1; 281 282 dibinfo.dsBitfields[0] = *((DWORD *)pColors); 283 dibinfo.dsBitfields[1] = *((DWORD *)pColors+1); 284 dibinfo.dsBitfields[2] = *((DWORD *)pColors+2); 285 dprintf(("BI_BITFIELDS %x %x %x", dibinfo.dsBitfields[0], dibinfo.dsBitfields[1], dibinfo.dsBitfields[2])); 286 } 287 256 288 dprintf(("DIBSection::SetDIBits (%d,%d), %d %d", pbmi->biWidth, pbmi->biHeight, pbmi->biBitCount, pbmi->biCompression)); 257 258 289 if(palsize) 259 290 memcpy(pOS2bmp->argbColor, (char *)pbmi + 1 , palsize); 260 291 261 292 if(bits) 262 293 { 263 int size = bmpsize*lines;264 memcpy(bmpBits+bmpsize*startscan, bits, size);294 int size = bmpsize*lines; 295 memcpy(bmpBits+bmpsize*startscan, bits, size); 265 296 } 266 297 return(lines);
Note:
See TracChangeset
for help on using the changeset viewer.