Ignore:
Timestamp:
Aug 18, 2000, 8:14:59 PM (25 years ago)
Author:
sandervl
Message:

lots of small changes; CreateHalftonePalette + rgb 565 -> rgb 555 conversion

File:
1 edited

Legend:

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

    r3594 r4034  
    1 /* $Id: palette.cpp,v 1.5 2000-05-23 18:46:21 sandervl Exp $ */
     1/* $Id: palette.cpp,v 1.6 2000-08-18 18:14:58 sandervl Exp $ */
    22
    33/*
     
    7171   }
    7272   rc = O32_CreatePalette(arg1);
    73    dprintf(("GDI32: CreatePalette returns 0x%08X\n",rc));
     73   dprintf(("GDI32: CreatePalette %x %d returns 0x%08X\n", arg1, arg1->palNumEntries, rc));
    7474
    7575   return rc;
     
    7777//******************************************************************************
    7878//******************************************************************************
    79 HPALETTE WIN32API SelectPalette(HDC arg1, HPALETTE arg2, BOOL arg3)
     79HPALETTE WIN32API SelectPalette(HDC hdc, HPALETTE hPalette, BOOL bForceBackground)
    8080{
    81   dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)\n", arg1, arg2, arg3));
     81  dprintf(("GDI32: SelectPalette (0x%08X, 0x%08X, 0x%08X)", hdc, hPalette, bForceBackground));
    8282  if(DIBSection::getSection() != NULL)
    8383  {
    84     DIBSection *dsect = DIBSection::findHDC(arg1);
     84    DIBSection *dsect = DIBSection::findHDC(hdc);
    8585    if(dsect)
    8686    {
     87      int nrcolors;
    8788      PALETTEENTRY Pal[256];
    8889      char PalSize = dsect->GetBitCount();
     
    9091      if(PalSize<=8)
    9192      {
    92         GetPaletteEntries( arg2, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
    93         dsect->SetDIBColorTable(0, 1<< PalSize, (RGBQUAD*)&Pal);
     93        nrcolors = GetPaletteEntries( hPalette, 0, 1<<PalSize, (LPPALETTEENTRY)&Pal);
     94        dsect->SetDIBColorTable(0, nrcolors, (RGBQUAD*)&Pal);
    9495      }
    9596
    9697    }
    9798  }
    98   return O32_SelectPalette(arg1, arg2, arg3);
     99  return O32_SelectPalette(hdc, hPalette, bForceBackground);
    99100}
    100101//******************************************************************************
     
    117118//******************************************************************************
    118119//******************************************************************************
    119 UINT WIN32API GetPaletteEntries( HPALETTE hPalette, UINT arg2, UINT arg3, PPALETTEENTRY  arg4)
     120UINT WIN32API GetPaletteEntries(HPALETTE hPalette, UINT iStart, UINT count, PPALETTEENTRY entries)
    120121{
    121     dprintf(("GDI32: GetPaletteEntries %x %d-%d %x", hPalette, arg2, arg3, arg4));
    122     return O32_GetPaletteEntries(hPalette, arg2, arg3, arg4);
     122 UINT rc;
     123
     124    rc = O32_GetPaletteEntries(hPalette, iStart, count, entries);
     125    dprintf(("GDI32: GetPaletteEntries %x %d-%d %x returned %d", hPalette, iStart, count, entries, rc));
     126    return rc;
    123127}
    124128//******************************************************************************
     
    151155HPALETTE WIN32API CreateHalftonePalette(HDC hdc)
    152156{
    153     dprintf(("GDI32: CreateHalftonePalette, not implemented\n"));
    154     return(NULL);
     157    int i, r, g, b;
     158    struct {
     159        WORD Version;
     160        WORD NumberOfEntries;
     161        PALETTEENTRY aEntries[256];
     162    } Palette = {
     163        0x300, 256
     164    };
     165
     166    dprintf(("GDI32: CreateHalftonePalette %x", hdc));
     167    GetSystemPaletteEntries(hdc, 0, 256, Palette.aEntries);
     168    return CreatePalette((LOGPALETTE *)&Palette);
     169
     170    for (r = 0; r < 6; r++) {
     171        for (g = 0; g < 6; g++) {
     172            for (b = 0; b < 6; b++) {
     173                i = r + g*6 + b*36 + 10;
     174                Palette.aEntries[i].peRed = r * 51;
     175                Palette.aEntries[i].peGreen = g * 51;
     176                Palette.aEntries[i].peBlue = b * 51;
     177            }   
     178          }
     179        }
     180       
     181    for (i = 216; i < 246; i++) {
     182        int v = (i - 216) * 8;
     183        Palette.aEntries[i].peRed = v;
     184        Palette.aEntries[i].peGreen = v;
     185        Palette.aEntries[i].peBlue = v;
     186        }
     187       
     188    return CreatePalette((LOGPALETTE *)&Palette);
    155189}
    156190//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.