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

Set/GetDIBColorTable fixes + SelectPalette hack

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.