Changeset 2600 for trunk/src


Ignore:
Timestamp:
Feb 3, 2000, 12:45:07 AM (26 years ago)
Author:
sandervl
Message:

RGB 555 conversion in SetDIBitsToDevice + quake 2 BitBlt fix

Location:
trunk/src/gdi32
Files:
7 edited

Legend:

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

    r2592 r2600  
    1 /* $Id: blit.cpp,v 1.1 2000-02-01 12:53:29 sandervl Exp $ */
     1/* $Id: blit.cpp,v 1.2 2000-02-02 23:45:06 sandervl Exp $ */
    22
    33/*
     
    7171                        }
    7272                }
     73                return rc;
    7374        }
    7475    }
     
    8586    INT result, imgsize, palsize, height, width;
    8687    char *ptr;
     88    ULONG compression = 0;
     89    WORD *newbits = 0;
    8790
    8891    SetLastError(0);
     
    126129
    127130    //SvL: Ignore BI_BITFIELDS type (SetDIBitsToDevice fails otherwise)
    128     if(info->bmiHeader.biCompression == BI_BITFIELDS)
     131    if(info->bmiHeader.biCompression == BI_BITFIELDS) {
     132        DWORD *bitfields = (DWORD *)info->bmiColors;
     133
     134        dprintf(("BI_BITFIELDS compression %x %x %x", *bitfields, *(bitfields+1), *(bitfields+2)));
    129135        ((BITMAPINFO *)info)->bmiHeader.biCompression = 0;
     136        compression = BI_BITFIELDS;
     137        if(*(bitfields+1) == 0x3E0) {//RGB 555?
     138          WORD *dstbits, *srcbits;
     139          WORD  pixel;
     140
     141                newbits = dstbits = (WORD *)malloc(imgsize);
     142                srcbits = (WORD *)bits;
     143                for(int i=0;i<imgsize/sizeof(WORD);i++) {
     144                        pixel     = *dstbits = *srcbits++;
     145                        *dstbits &= 0x1F;
     146                        pixel    &= 0x7FE0;
     147                        pixel   <<= 1;
     148                        *dstbits  = *dstbits | pixel;
     149                        dstbits++;
     150                }
     151                bits = newbits;
     152        }
     153    }
     154
    130155    if(info->bmiHeader.biHeight < 0)
    131156        ((BITMAPINFO *)info)->bmiHeader.biHeight = -info->bmiHeader.biHeight;
    132157
    133 //    result = OSLibSetDIBitsToDevice(hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (PVOID) bits, (WINBITMAPINFOHEADER *)info, coloruse);
    134 //    result = 1;
    135158    result = O32_SetDIBitsToDevice(hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (PVOID) bits, (PBITMAPINFO)info, coloruse);
    136159    //SvL: Wrong Open32 return value
     
    141164    dprintf(("GDI32: SetDIBitsToDevice %d %d %d %d %x %d", info->bmiHeader.biWidth, info->bmiHeader.biHeight, info->bmiHeader.biPlanes, info->bmiHeader.biBitCount, info->bmiHeader.biCompression, info->bmiHeader.biSizeImage));
    142165
     166    if(compression == BI_BITFIELDS) {
     167        ((BITMAPINFO *)info)->bmiHeader.biCompression = BI_BITFIELDS;
     168        if(newbits) free(newbits);
     169    }
    143170    return result;
    144171
  • trunk/src/gdi32/dibitmap.cpp

    r2592 r2600  
    1 /* $Id: dibitmap.cpp,v 1.1 2000-02-01 12:53:29 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.2 2000-02-02 23:45:06 sandervl Exp $ */
    22
    33/*
     
    8282 HBITMAP res = 0;
    8383 BOOL    fFlip = 0;
    84  int iHeight, iWidth;
     84 int     iHeight, iWidth;
    8585
    8686  dprintf(("GDI32: CreateDIBSection %x %x %x %x %d", hdc, iUsage, ppvBits, hSection, dwOffset));
     
    110110  if (res)
    111111  {
    112     ULONG Pal[256];
    113112    char PalSize;
    114     LOGPALETTE tmpPal = { 0x300,1,{0,0,0,0}};
    115     HPALETTE hpalCur, hpalTmp;
    116     DIBSection *dsect = new DIBSection((WINBITMAPINFOHEADER *)&pbmi->bmiHeader, iUsage, (DWORD)res, fFlip);
    117 
    118     if(NULL!=dsect)
     113    DIBSection *dsect = new DIBSection((BITMAPINFOHEADER_W *)&pbmi->bmiHeader, (char *)&pbmi->bmiColors, iUsage, (DWORD)res, fFlip);
     114
     115    if(dsect != NULL)
    119116    {
    120117      PalSize = dsect->GetBitCount();
    121       if(PalSize<=8)
     118      if(PalSize <= 8)
    122119      {
     120       ULONG Pal[256];
     121       LOGPALETTE tmpPal = { 0x300,1,{0,0,0,0}};
     122       HPALETTE hpalCur, hpalTmp;
     123
    123124        // Now get the current Palette from the DC
    124125        hpalTmp = CreatePalette(&tmpPal);
     
    170171                                  RGBQUAD *pColors)
    171172{
    172  HPALETTE hpal = O32_GetCurrentObject(hdc, OBJ_PAL);
     173 HPALETTE hpal = GetCurrentObject(hdc, OBJ_PAL);
    173174 UINT rc;
    174175 int i;
     
    208209//******************************************************************************
    209210//******************************************************************************
    210 LONG WIN32API GetBitmapBits( HBITMAP arg1, LONG arg2, PVOID  arg3)
    211 {
    212     dprintf(("GDI32: GetBitmapBits"));
    213     return O32_GetBitmapBits(arg1, arg2, arg3);
    214 }
    215 //******************************************************************************
    216 //******************************************************************************
    217 LONG WIN32API SetBitmapBits( HBITMAP arg1, LONG arg2, const VOID *  arg3)
    218 {
    219     dprintf(("GDI32: SetBitmapBits"));
    220     return O32_SetBitmapBits(arg1, (DWORD)arg2, arg3);
    221 }
    222 //******************************************************************************
    223 //******************************************************************************
    224 BOOL WIN32API GetBitmapDimensionEx( HBITMAP arg1, PSIZE  arg2)
    225 {
    226     dprintf(("GDI32: GetBitmapDimensionEx"));
    227     return O32_GetBitmapDimensionEx(arg1, arg2);
     211LONG WIN32API GetBitmapBits( HBITMAP hBitmap, LONG arg2, PVOID  arg3)
     212{
     213    dprintf(("GDI32: GetBitmapBits %x", hBitmap));
     214    return O32_GetBitmapBits(hBitmap, arg2, arg3);
     215}
     216//******************************************************************************
     217//******************************************************************************
     218LONG WIN32API SetBitmapBits( HBITMAP hBitmap, LONG arg2, const VOID *  arg3)
     219{
     220    dprintf(("GDI32: SetBitmapBits %x", hBitmap));
     221    return O32_SetBitmapBits(hBitmap, (DWORD)arg2, arg3);
     222}
     223//******************************************************************************
     224//******************************************************************************
     225BOOL WIN32API GetBitmapDimensionEx( HBITMAP hBitmap, PSIZE pSize)
     226{
     227    dprintf(("GDI32: GetBitmapDimensionEx %x (%d,%d)", hBitmap, pSize->cx, pSize->cy));
     228    return O32_GetBitmapDimensionEx(hBitmap, pSize);
    228229}
    229230//******************************************************************************
     
    251252    dprintf(("GDI32: SetDIBits %x %x %x %x %x %x %x\n", arg1, arg2, arg3, arg4, arg5, arg6, arg7));
    252253
    253     if(DIBSection::getSection() != NULL) {
     254    if(DIBSection::getSection() != NULL)
     255    {
    254256        DIBSection *dsect;
    255257
    256258        dsect = DIBSection::find((DWORD)arg2);
    257259        if(dsect) {
    258            return dsect->SetDIBits(arg1, arg2, arg3, arg4, arg5, (WINBITMAPINFOHEADER *)&arg6->bmiHeader, arg7);
     260           return dsect->SetDIBits(arg1, arg2, arg3, arg4, arg5, (BITMAPINFOHEADER_W *)&arg6->bmiHeader, arg7);
    259261        }
    260262    }
  • trunk/src/gdi32/dibsect.cpp

    r2592 r2600  
    1 /* $Id: dibsect.cpp,v 1.14 2000-02-01 12:53:29 sandervl Exp $ */
     1/* $Id: dibsect.cpp,v 1.15 2000-02-02 23:45:06 sandervl Exp $ */
    22
    33/*
     
    1515#include <stdlib.h>
    1616#include <string.h>
    17 #include "win32type.h"
    18 #include "misc.h"
     17#include <win32type.h>
     18#include <misc.h>
    1919#define  OS2_ONLY
    2020#include "dibsect.h"
    2121#include <vmutex.h>
     22#include <winconst.h>
    2223
    2324HWND WIN32API WindowFromDC(HDC hdc);
     
    4344//******************************************************************************
    4445//******************************************************************************
    45 DIBSection::DIBSection(WINBITMAPINFOHEADER *pbmi, DWORD iUsage, DWORD handle, int fFlip)
     46DIBSection::DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD handle, int fFlip)
    4647                : bmpBits(NULL), pOS2bmp(NULL), next(NULL)
    4748{
     
    9798   pOS2bmp->ulCompression = pbmi->biCompression;
    9899   //SvL: Ignore BI_BITFIELDS type (GpiDrawBits fails otherwise)
    99    if(pOS2bmp->ulCompression == 3) {
     100   if(pOS2bmp->ulCompression == BI_BITFIELDS) {
    100101        pOS2bmp->ulCompression = 0;
    101102   }
     
    110111   dprintf(("Bits at %x, size %d",bmpBits, bmpsize*pbmi->biHeight));
    111112
     113   // clear DIBSECTION structure
     114   memset(&dibinfo, 0, sizeof(dibinfo));
     115
     116   // copy BITMAPINFOHEADER data into DIBSECTION structure
     117   memcpy(&dibinfo.dsBmih, pbmi, sizeof(*pbmi));
     118   dibinfo.dsBm.bmType      = 0;
     119   dibinfo.dsBm.bmWidth     = pbmi->biWidth;
     120   dibinfo.dsBm.bmHeight    = pbmi->biHeight;
     121   dibinfo.dsBm.bmWidthBytes= bmpsize;
     122   dibinfo.dsBm.bmPlanes    = pbmi->biPlanes;
     123   dibinfo.dsBm.bmBitsPixel = pbmi->biBitCount;
     124   dibinfo.dsBm.bmBits      = bmpBits;
     125
     126   dibinfo.dshSection       = handle;
     127   dibinfo.dsOffset         = 0; // TODO: put the correct value here (if createdibsection with file handle)
     128
     129   if(pbmi->biCompression == BI_BITFIELDS) {
     130        dibinfo.dsBitfields[0] = *((DWORD *)pColors);
     131        dibinfo.dsBitfields[1] = *((DWORD *)pColors+1);
     132        dibinfo.dsBitfields[2] = *((DWORD *)pColors+2);
     133        dprintf(("BI_BITFIELDS %x %x %x", dibinfo.dsBitfields[0], dibinfo.dsBitfields[1], dibinfo.dsBitfields[2]));
     134   }
     135
    112136   this->handle = handle;
    113137   this->iUsage = iUsage;
     
    165189//******************************************************************************
    166190int DIBSection::SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
    167                           lines, const VOID *bits, WINBITMAPINFOHEADER *pbmi,
     191                          lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi,
    168192                          UINT coloruse)
    169193{
     
    383407{
    384408 DIBSECTION *pDIBSection = (DIBSECTION *)lpBuffer;
    385  LPWINBITMAP dsBm        = (LPWINBITMAP)lpBuffer;
     409 LPBITMAP_W  dsBm        = (LPBITMAP_W)lpBuffer;
    386410
    387411  dprintf2(("GetDIBSection %x %d %x", handle, iSize, lpBuffer));
    388412  if(iSize == sizeof(DIBSECTION))
    389413  {
    390     // BITMAP struct
    391     pDIBSection->dsBm.bmType       = 0;  // TODO: put the correct value here
    392     pDIBSection->dsBm.bmWidth      = pOS2bmp->cx;
    393     pDIBSection->dsBm.bmHeight     = pOS2bmp->cy;
    394     pDIBSection->dsBm.bmWidthBytes = bmpsize;
    395     pDIBSection->dsBm.bmPlanes     = pOS2bmp->cPlanes;
    396     pDIBSection->dsBm.bmBitsPixel  = pOS2bmp->cBitCount;
    397     pDIBSection->dsBm.bmBits       = bmpBits;
    398     // BITMAPINFOHEADER data
    399     pDIBSection->dsBmih.biSize = sizeof(BITMAPINFOHEADER);
    400     pDIBSection->dsBmih.biWidth       = pOS2bmp->cx;
    401     pDIBSection->dsBmih.biHeight      = pOS2bmp->cy;
    402     pDIBSection->dsBmih.biPlanes      = pOS2bmp->cPlanes;
    403     pDIBSection->dsBmih.biBitCount    = pOS2bmp->cBitCount;
    404     pDIBSection->dsBmih.biCompression = pOS2bmp->ulCompression;
    405     pDIBSection->dsBmih.biSizeImage   = pOS2bmp->cbImage;
    406     pDIBSection->dsBmih.biXPelsPerMeter = 0; // TODO: put the correct value here
    407     pDIBSection->dsBmih.biYPelsPerMeter = 0;
    408     pDIBSection->dsBmih.biClrUsed       = (1<< pOS2bmp->cBitCount);
    409     pDIBSection->dsBmih.biClrImportant  = 0;
    410 
    411     pDIBSection->dsBitfields[0] = 0; // TODO: put the correct value here
    412     pDIBSection->dsBitfields[1] = 0;
    413     pDIBSection->dsBitfields[2] = 0;
    414 
    415     pDIBSection->dshSection = this->handle;
    416 
    417     pDIBSection->dsOffset = 0; // TODO: put the correct value here
    418 
    419     return sizeof(DIBSECTION);
     414        memcpy(pDIBSection, &dibinfo, sizeof(dibinfo));
     415        return sizeof(DIBSECTION);
    420416  }
    421417  else
    422   if(iSize == sizeof(WINBITMAP))
    423   {
    424         dsBm->bmType       = 0;  // TODO: put the correct value here
    425         dsBm->bmWidth      = pOS2bmp->cx;
    426         dsBm->bmHeight     = pOS2bmp->cy;
    427         dsBm->bmWidthBytes = bmpsize;
    428         dsBm->bmPlanes     = pOS2bmp->cPlanes;
    429         dsBm->bmBitsPixel  = pOS2bmp->cBitCount;
    430         dsBm->bmBits       = bmpBits;
    431         return sizeof(WINBITMAP);
     418  if(iSize == sizeof(BITMAP_W))
     419  {
     420        memcpy(dsBm, &dibinfo.dsBm, sizeof(dibinfo.dsBm));
     421        return sizeof(BITMAP_W);
    432422  }
    433423  return 0;
  • trunk/src/gdi32/dibsect.h

    r2592 r2600  
    1 /* $Id: dibsect.h,v 1.10 2000-02-01 12:53:29 sandervl Exp $ */
     1/* $Id: dibsect.h,v 1.11 2000-02-02 23:45:06 sandervl Exp $ */
    22
    33/*
     
    3636        DWORD    biClrUsed;
    3737        DWORD    biClrImportant;
    38 } WINBITMAPINFOHEADER;
     38} BITMAPINFOHEADER_W;
    3939
    4040typedef struct
     
    4747    WORD   bmBitsPixel;
    4848    LPVOID bmBits;
    49 } WINBITMAP, *LPWINBITMAP;
     49} BITMAP_W, *LPBITMAP_W;
    5050
    5151#ifdef OS2_ONLY
    5252typedef struct
    5353{
    54   WINBITMAP   dsBm;
    55   WINBITMAPINFOHEADER dsBmih;
     54  BITMAP_W   dsBm;
     55  BITMAPINFOHEADER_W dsBmih;
    5656  DWORD     dsBitfields[3];
    5757  HANDLE    dshSection;
     
    6363{
    6464public:
    65               DIBSection(WINBITMAPINFOHEADER *pbmi, DWORD iUsage, DWORD handle, int fFlip);
     65              DIBSection(BITMAPINFOHEADER_W *pbmi, char *pColors, DWORD iUsage, DWORD handle, int fFlip);
    6666             ~DIBSection();
    6767
     
    8383
    8484         int  SetDIBits(HDC hdc, HBITMAP hbitmap, UINT startscan, UINT
    85                               lines, const VOID *bits, WINBITMAPINFOHEADER *pbmi,
     85                              lines, const VOID *bits, BITMAPINFOHEADER_W *pbmi,
    8686                              UINT coloruse);
    8787
     
    101101          BOOL  fFlip;
    102102          int   bmpsize;
     103    DIBSECTION  dibinfo;
     104
    103105    BITMAPINFO2 *pOS2bmp;
    104106                             // Linked list management
  • trunk/src/gdi32/gdi32.cpp

    r2592 r2600  
    1 /* $Id: gdi32.cpp,v 1.37 2000-02-01 12:53:30 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.38 2000-02-02 23:45:06 sandervl Exp $ */
    22
    33/*
     
    777777    if(nIndex == NUMCOLORS && rc > 256)
    778778        return -1;
     779
    779780    return(rc);
    780781}
  • trunk/src/gdi32/oslibgdi.cpp

    r2592 r2600  
    1 /* $Id: oslibgdi.cpp,v 1.4 2000-02-01 12:53:30 sandervl Exp $ */
     1/* $Id: oslibgdi.cpp,v 1.5 2000-02-02 23:45:07 sandervl Exp $ */
    22
    33/*
     
    2424INT OSLibSetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx, DWORD cy,
    2525                           INT xSrc, INT ySrc, UINT startscan, UINT lines,
    26                            LPCVOID bits, WINBITMAPINFOHEADER *info,
     26                           LPCVOID bits, BITMAPINFOHEADER_W *info,
    2727                           UINT coloruse)
    2828{
  • trunk/src/gdi32/oslibgdi.h

    r2049 r2600  
    1 /* $Id: oslibgdi.h,v 1.2 1999-12-09 16:49:45 cbratschi Exp $ */
     1/* $Id: oslibgdi.h,v 1.3 2000-02-02 23:45:07 sandervl Exp $ */
    22
    33/*
     
    1414INT OSLibSetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx, DWORD cy,
    1515                           INT xSrc, INT ySrc, UINT startscan, UINT lines,
    16                            LPCVOID bits, WINBITMAPINFOHEADER *info,
     16                           LPCVOID bits, BITMAPINFOHEADER_W *info,
    1717                           UINT coloruse);
    1818
Note: See TracChangeset for help on using the changeset viewer.