Changeset 4590 for trunk/src


Ignore:
Timestamp:
Nov 14, 2000, 3:28:22 PM (25 years ago)
Author:
sandervl
Message:

SetDIBits fix for monochrome bitmaps

Location:
trunk/src/gdi32
Files:
2 edited

Legend:

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

    r4574 r4590  
    1 /* $Id: dibitmap.cpp,v 1.11 2000-11-09 18:16:56 sandervl Exp $ */
     1/* $Id: dibitmap.cpp,v 1.12 2000-11-14 14:28:22 sandervl Exp $ */
    22
    33/*
     
    1414#include <stdarg.h>
    1515#include <string.h>
    16 #include "misc.h"
     16#include <misc.h>
     17#include <winuser32.h>
    1718#include "dibsect.h"
    1819
    19 #define DBG_LOCALLOG    DBG_dibitmap
     20#define DBG_LOCALLOG    DBG_dibitmap
    2021#include "dbglocal.h"
    2122
    2223//******************************************************************************
    2324//******************************************************************************
    24 HBITMAP WIN32API CreateDIBitmap(HDC hdc, const BITMAPINFOHEADER *lpbmih, 
    25                                 DWORD fdwInit, const void *lpbInit, 
     25HBITMAP WIN32API CreateDIBitmap(HDC hdc, const BITMAPINFOHEADER *lpbmih,
     26                                DWORD fdwInit, const void *lpbInit,
    2627                                const BITMAPINFO *lpbmi, UINT fuUsage)
    2728{
     
    3233  //     to 8bpp by Open32)
    3334  if(lpbmih->biBitCount == 1) {
    34         dprintf(("WARNING: CreateDIBitmap doesn't handle 1bpp bitmaps very well!!!!!"));
    35   }
    36  
     35    dprintf(("WARNING: CreateDIBitmap doesn't handle 1bpp bitmaps very well!!!!!"));
     36  }
     37
    3738  //TEMPORARY HACK TO PREVENT CRASH IN OPEN32 (WSeB GA)
    3839
     
    4950  // however wants to copy it later on ...
    5051  int biBitCount = lpbmih->biBitCount;
    51  
     52
    5253  if (lpbmih->biBitCount != lpbmi->bmiHeader.biBitCount)
    5354  {
     
    5556             lpbmih->biBitCount,
    5657             lpbmi->bmiHeader.biBitCount));
    57              
     58
    5859    ((BITMAPINFOHEADER *)lpbmih)->biBitCount = lpbmi->bmiHeader.biBitCount;
    5960  }
     
    6162  rc = O32_CreateDIBitmap(hdc, lpbmih, fdwInit, lpbInit, lpbmi, fuUsage);
    6263
    63   dprintf(("GDI32: CreateDIBitmap %x %x %x %x returned %x", hdc, fdwInit, lpbInit, fuUsage, rc));
     64  dprintf(("GDI32: CreateDIBitmap %x %x %x %x returned %x (%d,%d, bps %d)", hdc, fdwInit, lpbInit, fuUsage, rc, lpbmih->biWidth, lpbmih->biHeight, lpbmih->biBitCount));
    6465
    6566  ((BITMAPINFOHEADER *)lpbmih)->biHeight   = iHeight;
     
    120121  if(pbmi->bmiHeader.biWidth < 0)
    121122  {
    122         dprintf(("CreateDIBSection: width %d", pbmi->bmiHeader.biWidth));
    123         pbmi->bmiHeader.biWidth = -pbmi->bmiHeader.biWidth;
    124         fFlip = FLIP_HOR;
     123    dprintf(("CreateDIBSection: width %d", pbmi->bmiHeader.biWidth));
     124        pbmi->bmiHeader.biWidth = -pbmi->bmiHeader.biWidth;
     125        fFlip = FLIP_HOR;
    125126  }
    126127  iHeight = pbmi->bmiHeader.biHeight;
    127128  if(pbmi->bmiHeader.biHeight < 0)
    128129  {
    129         dprintf(("CreateDIBSection: height %d", pbmi->bmiHeader.biHeight));
    130         pbmi->bmiHeader.biHeight = -pbmi->bmiHeader.biHeight;
    131         fFlip |= FLIP_VERT;
     130    dprintf(("CreateDIBSection: height %d", pbmi->bmiHeader.biHeight));
     131        pbmi->bmiHeader.biHeight = -pbmi->bmiHeader.biHeight;
     132        fFlip |= FLIP_VERT;
    132133  }
    133134
    134135  //SvL: RP7 (update) calls this api with hdc == 0
    135136  if(hdc == 0) {
    136         hdc = GetWindowDC(GetDesktopWindow());
    137         fCreateDC = TRUE;
     137    hdc = GetWindowDC(GetDesktopWindow());
     138    fCreateDC = TRUE;
    138139  }
    139140  res = O32_CreateDIBitmap(hdc, &pbmi->bmiHeader, 0, NULL, pbmi, iUsage);
     
    181182      pbmi->bmiHeader.biHeight = iHeight;
    182183
    183       if(fCreateDC)     ReleaseDC(GetDesktopWindow(), hdc);
     184      if(fCreateDC) ReleaseDC(GetDesktopWindow(), hdc);
    184185      return(res);
    185186    }
    186187  }
    187   if(fCreateDC) ReleaseDC(GetDesktopWindow(), hdc);
     188  if(fCreateDC) ReleaseDC(GetDesktopWindow(), hdc);
    188189
    189190  /* Error.  */
     
    271272//******************************************************************************
    272273//******************************************************************************
    273 int WIN32API GetDIBits(HDC hdc, HBITMAP hBitmap, UINT uStartScan, UINT cScanLines, 
     274int WIN32API GetDIBits(HDC hdc, HBITMAP hBitmap, UINT uStartScan, UINT cScanLines,
    274275                       void *lpvBits, PBITMAPINFO lpbi, UINT uUsage)
    275276{
     
    289290       ((DWORD*)(lpbi->bmiColors))[1] = 0x00FF00;
    290291       ((DWORD*)(lpbi->bmiColors))[2] = 0xFF0000;
    291        break; 
     292       break;
    292293    }
    293294
     
    297298//******************************************************************************
    298299//******************************************************************************
    299 int WIN32API SetDIBits( HDC arg1, HBITMAP arg2, UINT arg3, UINT arg4, const VOID * arg5, const BITMAPINFO * arg6, UINT  arg7)
    300 {
    301     dprintf(("GDI32: SetDIBits %x %x %x %x %x %x %x\n", arg1, arg2, arg3, arg4, arg5, arg6, arg7));
    302 
    303     if(DIBSection::getSection() != NULL)
     300int WIN32API SetDIBits(HDC hdc, HBITMAP hBitmap, UINT startscan, UINT numlines, const VOID *pBits,
     301                       const BITMAPINFO *pBitmapInfo, UINT usage)
     302{
     303    dprintf(("GDI32: SetDIBits %x %x %x %x %x %x %x", hdc, hBitmap, startscan, numlines, pBits, pBitmapInfo, usage));
     304
     305    if(DIBSection::getSection() != NULL)
    304306    {
    305307        DIBSection *dsect;
    306308
    307         dsect = DIBSection::find((DWORD)arg2);
     309        dsect = DIBSection::find((DWORD)hBitmap);
    308310        if(dsect) {
    309            return dsect->SetDIBits(arg1, arg2, arg3, arg4, arg5, (BITMAPINFOHEADER_W *)&arg6->bmiHeader, arg7);
     311           return dsect->SetDIBits(hdc, hBitmap, startscan, numlines, pBits, (BITMAPINFOHEADER_W *)&pBitmapInfo->bmiHeader, usage);
    310312        }
    311313    }
    312     return O32_SetDIBits(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
    313 }
    314 //******************************************************************************
    315 //******************************************************************************
     314    //SvL: Open32's SetDIBits really messes things up for 1 bpp bitmaps, must use SetBitmapBits
     315    if(pBitmapInfo->bmiHeader.biBitCount == 1 && startscan == 0 && numlines == pBitmapInfo->bmiHeader.biHeight)
     316    {
     317        int   linewidth = DIB_GetDIBWidthBytes(pBitmapInfo->bmiHeader.biWidth, 1);
     318        char *newpix    = (char *)malloc(linewidth*pBitmapInfo->bmiHeader.biHeight);
     319        char *orgpix    = (char *)pBits;
     320        int   ret;
     321
     322        newpix += ((pBitmapInfo->bmiHeader.biHeight-1)*linewidth);
     323
     324        //flip bitmap here; SetDIBits assumes origin is left bottom, SetBitmapBits left top
     325        for(int i=0;i<pBitmapInfo->bmiHeader.biHeight;i++) {
     326            memcpy(newpix, orgpix, linewidth);
     327            newpix -= linewidth;
     328            orgpix += linewidth;
     329        }
     330        newpix += linewidth;
     331        ret = O32_SetBitmapBits(hBitmap, pBitmapInfo->bmiHeader.biSizeImage, newpix);
     332
     333        free(newpix);
     334        return ret;
     335    }
     336#ifdef DEBUG
     337    if(pBitmapInfo->bmiHeader.biBitCount == 1) {
     338        dprintf(("ERROR: SetDIBits does NOT work well for 1 bpp bitmaps!!!!!"));
     339    }
     340#endif
     341    return O32_SetDIBits(hdc, hBitmap, startscan, numlines, pBits, pBitmapInfo, usage);
     342}
     343//******************************************************************************
     344//******************************************************************************
  • trunk/src/gdi32/gdi32.cpp

    r4574 r4590  
    1 /* $Id: gdi32.cpp,v 1.60 2000-11-09 18:16:57 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.61 2000-11-14 14:28:22 sandervl Exp $ */
    22
    33/*
     
    114114//******************************************************************************
    115115//******************************************************************************
    116 HBRUSH WIN32API CreateDIBPatternBrushPt( const VOID * arg1, UINT  arg2)
    117 {
    118     dprintf(("GDI32: CreateDIBPatternBrushPt\n"));
    119     return O32_CreateDIBPatternBrushPt(arg1, arg2);
     116HBRUSH WIN32API CreateDIBPatternBrushPt( const VOID * buffer, UINT usage)
     117{
     118    dprintf(("GDI32: CreateDIBPatternBrushPt %x %x", buffer, usage));
     119    return O32_CreateDIBPatternBrushPt(buffer, usage);
    120120}
    121121//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.