Ignore:
Timestamp:
Aug 30, 2000, 8:05:25 PM (25 years ago)
Author:
sandervl
Message:

workaround for palette problems in PowerDVD

File:
1 edited

Legend:

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

    r4034 r4127  
    1 /* $Id: dibsect.cpp,v 1.37 2000-08-18 18:14:57 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.38 2000-08-30 18:05:24 sandervl Exp $ */
    22
    33/*
     
    4141                : bmpBits(NULL), pOS2bmp(NULL), next(NULL), bmpBitsDblBuffer(NULL)
    4242{
     43 int  palsize=0;
     44
    4345  bmpsize = pbmi->biWidth;
    4446  /* @@@PH 98/06/07 -- high-color bitmaps don't have palette */
     
    5052  {
    5153        case 1:
    52                 bmpsize = ((bmpsize + 31) & ~31) / 8;
    53                 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
     54                bmpsize = ((bmpsize + 31) & ~31) / 8;
     55                palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
     56                os2bmphdrsize += palsize;
    5457                break;
    5558        case 4:
    5659                bmpsize = ((bmpsize + 7) & ~7) / 2;
    57                 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
     60                palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
     61                os2bmphdrsize += palsize;
    5862                break;
    5963        case 8:
    60                 os2bmphdrsize += ((1 << pbmi->biBitCount)-1)*sizeof(RGB2);
     64                palsize = ((1 << pbmi->biBitCount))*sizeof(RGB2);
     65                os2bmphdrsize += palsize;
    6166                bmpsize = (bmpsize + 3) & ~3;
    6267                break;
     
    7984
    8085   this->hSection = hSection;
     86   this->dwOffset = dwOffset;
    8187   if(hSection) {
    8288        bmpBits = (char *)MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS_W, 0, dwOffset, bmpsize*pbmi->biHeight);
     
    130136   dibinfo.dsBm.bmBits      = bmpBits;
    131137
    132    dibinfo.dshSection       = handle;
     138   dibinfo.dshSection       = hSection;
    133139   dibinfo.dsOffset         = dwOffset;
    134140
     
    136142   {
    137143        dibinfo.dsBitfields[0] = dibinfo.dsBitfields[1] = dibinfo.dsBitfields[2] = 0;
     144        if(palsize) {
     145                SetDIBColorTable(0, (1 << pbmi->biBitCount), (RGBQUAD *)(pbmi+1));
     146        }
    138147   }
    139148   else {
     
    305314
    306315   dibinfo.dshSection       = hSection;
    307    dibinfo.dsOffset         = 0; // TODO: put the correct value here (if createdibsection with file handle)
     316   dibinfo.dsOffset         = dwOffset;
    308317
    309318   if(coloruse == DIB_PAL_COLORS || pbmi->biBitCount <= 8)
     
    377386  {
    378387    pOS2bmp->argbColor[i].fcOptions = 0;
     388#ifdef DEBUG_PALETTE
    379389    dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&pOS2bmp->argbColor[i])) ));
     390#endif
    380391  }
    381392
     
    547558}
    548559//******************************************************************************
     560int WIN32API GetDIBits(HDC hdc, HBITMAP hBitmap, UINT uStartScan, UINT cScanLines,
     561                       void *lpvBits, BITMAPINFO_W * lpbi, UINT uUsage);
     562
    549563//******************************************************************************
    550564void DIBSection::sync(HDC hdc, DWORD nYdest, DWORD nDestHeight)
     
    555569  dprintf(("Sync destination dibsection %x (%x)", handle, hdc));
    556570
     571#if 0
     572  BITMAPINFO_W *tmphdr = (BITMAPINFO_W *)malloc(os2bmphdrsize + sizeof(BITMAPINFO_W));
     573  tmphdr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER_W);
     574  GetDIBits(hdc, handle, nYdest, nDestHeight, NULL, tmphdr, 0);
     575  destBuf = GetDIBObject() + nYdest*dibinfo.dsBm.bmWidthBytes;
     576  rc = GetDIBits(hdc, handle, nYdest, nDestHeight, destBuf, tmphdr, 0);
     577#ifdef DEBUG_PALETTE
     578  if(rc && tmphdr->bmiHeader.biBitCount <= 8) {
     579        for(int i=0;i<(1<<tmphdr->bmiHeader.biBitCount);i++)
     580        {
     581                dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&tmphdr->bmiColors[i])) ));
     582        }
     583  }
     584#endif
     585
     586#else
    557587  BITMAPINFO2 *tmphdr = (BITMAPINFO2 *)malloc(os2bmphdrsize);
    558588  memcpy(tmphdr, pOS2bmp, os2bmphdrsize);
     
    576606        rc = GpiQueryBitmapBits(hdc, nYdest, nDestHeight, destBuf,
    577607                          tmphdr);
    578   }
     608#ifdef DEBUG_PALETTE
     609        if(rc != GPI_ALTERROR && tmphdr->cBitCount <= 8) {
     610                for(int i=0;i<(1<<tmphdr->cBitCount);i++)
     611                {
     612                        dprintf2(("Index %d : 0x%08X\n",i, *((ULONG*)(&tmphdr->argbColor[i])) ));
     613                }
     614        }
     615#endif
     616  }
     617#endif
     618#if 0
    579619  if(dibinfo.dsBitfields[1] == 0x3E0) {//RGB 555?
    580620        dprintf(("DIBSection::sync: convert RGB 565 to RGB 555"));
     
    587627        else    RGB565to555((WORD *)destBuf, (WORD *)destBuf, (nDestHeight*dibinfo.dsBm.bmWidthBytes)/sizeof(WORD));
    588628  }
     629#endif
    589630  free(tmphdr);
    590631  if(rc != nDestHeight) {
    591632        DebugInt3();
    592633  }
     634}
     635//******************************************************************************
     636//manual sync if no stretching and bpp is the same
     637//WARNING: this also assumes the colortables are the same
     638//******************************************************************************
     639void DIBSection::sync(DWORD xDst, DWORD yDst, DWORD widthDst, DWORD heightDst, PVOID bits)
     640{
     641 char *srcbuf, *destbuf;
     642 int  linesize;
     643
     644   srcbuf  = (char *)bits + dibinfo.dsBm.bmWidthBytes*yDst +
     645                    (xDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx;
     646   destbuf = (char *)GetDIBObject() + dibinfo.dsBm.bmWidthBytes*yDst +
     647                    (xDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx;
     648   linesize = (widthDst*dibinfo.dsBm.bmWidthBytes)/pOS2bmp->cx;
     649   for(int i=0;i<heightDst;i++) {
     650        memcpy(destbuf, srcbuf, linesize);
     651        destbuf += dibinfo.dsBm.bmWidthBytes;
     652        srcbuf  += linesize;
     653   }
    593654}
    594655//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.