Ignore:
Timestamp:
Nov 24, 1999, 8:30:18 PM (26 years ago)
Author:
sandervl
Message:

EB's dibsection updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/dibsect.cpp

    r1710 r1830  
    1 /* $Id: dibsect.cpp,v 1.8 1999-11-12 11:38:38 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.9 1999-11-24 19:30:18 sandervl Exp $ */
    22
    33/*
     
    145145        dsect->next = this->next;
    146146   }
     147}
     148//******************************************************************************
     149//******************************************************************************
     150int DIBSection::SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
     151                          lines, const VOID *bits, WINBITMAPINFOHEADER *pbmi,
     152                          UINT coloruse)
     153{
     154  lines = (int)lines >= 0 ? (int)lines : (int)-lines;
     155  int  os2bmpsize;
     156  int  palsize=0;
     157
     158  bmpsize = pbmi->biWidth;
     159  os2bmpsize = sizeof(BITMAPINFO2);
     160
     161  switch(pbmi->biBitCount)
     162  {
     163        case 1:
     164                bmpsize /= 8;
     165                palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
     166                os2bmpsize += palsize;
     167                break;
     168        case 4:
     169                bmpsize /= 2;
     170                palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
     171                os2bmpsize += palsize;
     172                break;
     173        case 8:
     174                palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
     175                os2bmpsize += palsize;
     176                break;
     177        case 16:
     178                bmpsize *= 2;
     179                break;
     180        case 24:
     181                bmpsize *= 3;
     182                break;
     183        case 32:
     184                bmpsize *= 4;
     185                break;
     186   }
     187   if(bmpsize & 3) {
     188        bmpsize = (bmpsize + 3) & ~3;
     189   }
     190
     191   bmpBits    = (char *)realloc(bmpBits, bmpsize*pbmi->biHeight);
     192   pOS2bmp    = (BITMAPINFO2 *)realloc(pOS2bmp, os2bmpsize);
     193
     194   pOS2bmp->cbFix         = sizeof(BITMAPINFO2) - sizeof(RGB2);
     195   pOS2bmp->cx            = pbmi->biWidth;
     196   pOS2bmp->cy            = pbmi->biHeight;
     197   pOS2bmp->cPlanes       = pbmi->biPlanes;
     198   pOS2bmp->cBitCount     = pbmi->biBitCount;
     199   pOS2bmp->ulCompression = pbmi->biCompression;
     200   pOS2bmp->cbImage       = pbmi->biSizeImage;
     201
     202   if(palsize)
     203     memcpy(pOS2bmp->argbColor, (char *)pbmi + 1 , palsize);
     204
     205   if(bits)
     206   {
     207     int size = bmpsize*lines;
     208     memcpy(bmpBits+bmpsize*startscan, bits, size);
     209   }
     210   return(lines);
    147211}
    148212//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.