Changeset 5825 for trunk/src


Ignore:
Timestamp:
May 29, 2001, 11:45:21 AM (24 years ago)
Author:
sandervl
Message:

Set/GetDIBColorTable fixes + SelectPalette hack

Location:
trunk/src/gdi32
Files:
5 edited

Legend:

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

    r5790 r5825  
    1 /* $Id: blit.cpp,v 1.28 2001-05-24 08:18:45 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.29 2001-05-29 09:45:20 sandervl Exp $ */
    22
    33/*
     
    329329  BOOL rc;
    330330
     331  dprintf(("PatBlt %x (%d,%d)(%d,%d) %x", hdc, nXLeft,nYLeft,nWidth,nHeight, dwRop));
    331332  //CB: Open32 bug: negative width/height not supported!
    332333  if (nWidth < 0)
  • trunk/src/gdi32/dibitmap.cpp

    r5799 r5825  
    1 /* $Id: dibitmap.cpp,v 1.16 2001-05-25 10:05:28 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.17 2001-05-29 09:45:21 sandervl Exp $ */
    22
    33/*
     
    203203//******************************************************************************
    204204//******************************************************************************
    205 UINT WIN32API GetDIBColorTable( HDC hdc, UINT uStartIndex, UINT cEntries,
    206                                   RGBQUAD *pColors)
    207 {
    208  HPALETTE hpal = GetCurrentObject(hdc, OBJ_PAL);
     205UINT WIN32API GetDIBColorTable(HDC hdc, UINT uStartIndex, UINT cEntries,
     206                               RGBQUAD *pColors)
     207{
     208 DIBSection *dsect = DIBSection::findHDC(hdc);
    209209 UINT rc;
    210210 int i;
    211211
    212   rc = O32_GetPaletteEntries(hpal,
    213                          uStartIndex,
    214                          cEntries,
    215                          (PALETTEENTRY *)pColors);
     212  dprintf(("GetDIBColorTable %x %d->%d %x", hdc, uStartIndex, cEntries, pColors));
     213
     214  if(dsect)
     215  {
     216       return(dsect->GetDIBColorTable(uStartIndex, cEntries, pColors));
     217  }
     218  //TODO: Is this correct?????
     219  //      Wine returns 0 if bitmap selected into dc with bpp > 8
     220  HPALETTE hpal = GetCurrentObject(hdc, OBJ_PAL);
     221  rc = O32_GetPaletteEntries(hpal, uStartIndex,
     222                             cEntries, (PALETTEENTRY *)pColors);
    216223  for(i=0;
    217224      i<cEntries;
     
    230237//******************************************************************************
    231238UINT WIN32API SetDIBColorTable(HDC hdc, UINT uStartIndex, UINT cEntries,
    232                                   RGBQUAD *pColors)
     239                               RGBQUAD *pColors)
    233240{
    234241 DIBSection *dsect = DIBSection::findHDC(hdc);
    235242
    236   dprintf(("GDI32: SetDIBColorTable\n"));
     243  dprintf(("GDI32: SetDIBColorTable %x %d,%d %x", hdc, uStartIndex, cEntries, pColors));
    237244  if(dsect)
    238245  {
  • trunk/src/gdi32/dibsect.cpp

    r5799 r5825  
    1 /* $Id: dibsect.cpp,v 1.51 2001-05-25 10:05:29 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.52 2001-05-29 09:45:21 sandervl Exp $ */
    22
    33/*
     
    387387int DIBSection::SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb)
    388388{
    389  int i;
     389 int i, end;
    390390
    391391  dprintf(("SetDIBColorTable %d %d %x", startIdx, cEntries, rgb));
    392   if(startIdx + cEntries > (1 << pOS2bmp->cBitCount))
    393   {
    394     dprintf(("DIBSection::SetDIBColorTable, invalid nr of entries %d %d\n", startIdx, cEntries));
    395     return(0);
     392
     393  if(pOS2bmp->cBitCount > 8) {
     394      dprintf(("DIBSection::SetDIBColorTable: bpp > 8; ignore"));
     395      return 0;
     396  }
     397
     398  end = startIdx + cEntries;
     399  if(end > (1 << pOS2bmp->cBitCount)) {
     400      end = (1 << pOS2bmp->cBitCount);
    396401  }
    397402
    398403  memcpy(&pOS2bmp->argbColor[startIdx], rgb, cEntries*sizeof(RGB2));
    399404
    400   for(i=startIdx;i<cEntries;i++)
     405  for(i=startIdx;i<end;i++)
    401406  {
    402407    pOS2bmp->argbColor[i].fcOptions = 0;
     
    412417int DIBSection::SetDIBColorTable(int startIdx, int cEntries, PALETTEENTRY *palentry)
    413418{
    414  int i;
    415 
    416   if(startIdx + cEntries > (1 << pOS2bmp->cBitCount))
    417   {
    418     dprintf(("DIBSection::SetDIBColorTable, invalid nr of entries %d %d\n", startIdx, cEntries));
    419     return(0);
    420   }
    421 
    422   for(i=startIdx;i<cEntries;i++)
     419 int i, end;
     420
     421  if(pOS2bmp->cBitCount > 8) {
     422      dprintf(("DIBSection::SetDIBColorTable: bpp > 8; ignore"));
     423      return 0;
     424  }
     425
     426  end = startIdx + cEntries;
     427  if(end > (1 << pOS2bmp->cBitCount)) {
     428      end = (1 << pOS2bmp->cBitCount);
     429  }
     430  for(i=startIdx;i<end;i++)
    423431  {
    424432    pOS2bmp->argbColor[i].fcOptions = 0;
     
    428436  }
    429437
    430   return(cEntries);
     438  return end - startIdx;
     439}
     440//******************************************************************************
     441//******************************************************************************
     442int DIBSection::GetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb)
     443{
     444  int i, end = startIdx + cEntries;
     445
     446  if(pOS2bmp->cBitCount > 8) {
     447      dprintf(("DIBSection::GetDIBColorTable: bpp > 8 -> return 0"));
     448      return 0;
     449  }
     450  if(end > (1 << pOS2bmp->cBitCount)) {
     451      end = (1 << pOS2bmp->cBitCount);
     452      dprintf(("DIBSection::GetDIBColorTable: %d->%d", startIdx, end));
     453  }
     454  memcpy(rgb, &pOS2bmp->argbColor[startIdx], cEntries*sizeof(RGBQUAD));
     455
     456  for(i=0;i<cEntries;i++) {
     457    rgb[i].rgbReserved = 0;
     458  }
     459
     460  return end - startIdx;
    431461}
    432462//******************************************************************************
  • trunk/src/gdi32/dibsect.h

    r5390 r5825  
    1 /* $Id: dibsect.h,v 1.24 2001-03-27 20:47:52 sandervl Exp $ */
     1/* $Id: dibsect.h,v 1.25 2001-05-29 09:45:21 sandervl Exp $ */
    22
    33/*
     
    100100              void  sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits);
    101101               int  SetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
     102               int  GetDIBColorTable(int startIdx, int cEntries, RGBQUAD *rgb);
    102103               int  SetDIBColorTable(int startIdx, int cEntries, PALETTEENTRY *rgb);
    103104
  • trunk/src/gdi32/palette.cpp

    r5799 r5825  
    1 /* $Id: palette.cpp,v 1.8 2001-05-25 10:05:29 sandervl Exp $ */
     1/* $Id: palette.cpp,v 1.9 2001-05-29 09:45:21 sandervl Exp $ */
    22
    33/*
     
    8585  dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)", hdc, hPalette, bForceBackground));
    8686  hPal = O32_SelectPalette(hdc, hPalette, bForceBackground);
    87   if(DIBSection::getSection() != NULL)
     87
     88  //hack for beyond compare buttons (+ other apps)
     89  //seems to select old palette into dc before unselecting dib section
     90  if(bForceBackground != -1 && DIBSection::getSection() != NULL)
    8891  {
    8992    DIBSection *dsect = DIBSection::findHDC(hdc);
Note: See TracChangeset for help on using the changeset viewer.