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

RGB 555 conversion in SetDIBitsToDevice + quake 2 BitBlt fix

File:
1 edited

Legend:

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