Ignore:
Timestamp:
Jan 28, 2000, 11:24:58 PM (26 years ago)
Author:
sandervl
Message:

Wrong return values for GetDIBits & SetDIBitsToDevice

File:
1 edited

Legend:

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

    r2527 r2551  
    1 /* $Id: gdi32.cpp,v 1.33 2000-01-26 23:48:02 sandervl Exp $ */
     1/* $Id: gdi32.cpp,v 1.34 2000-01-28 22:24:57 sandervl Exp $ */
    22
    33/*
     
    2020#include <codepage.h>
    2121#include "oslibgpi.h"
     22#include "oslibgdi.h"
    2223
    2324static ULONG QueryPaletteSize(BITMAPINFOHEADER *pBHdr)
     
    689690//******************************************************************************
    690691//******************************************************************************
    691 HDC WIN32API CreateDCA( LPCSTR arg1, LPCSTR arg2, LPCSTR arg3, const DEVMODEA * arg4)
    692 {
    693     dprintf(("GDI32: CreateDCA"));
    694     return O32_CreateDC(arg1, arg2, arg3, arg4);
     692HDC WIN32API CreateDCA(LPCSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszOutput, const DEVMODEA *lpInitData)
     693{
     694 HDC hdc;
     695
     696    hdc = O32_CreateDC(lpszDriver, lpszDevice, lpszOutput, lpInitData);
     697    dprintf(("GDI32: CreateDCA %s %s %s %x returned %x", lpszDriver, lpszDevice, lpszOutput, lpInitData, hdc));
     698    return hdc;
    695699}
    696700//******************************************************************************
     
    10291033//******************************************************************************
    10301034//******************************************************************************
    1031 int WIN32API SetROP2( HDC arg1, int  arg2)
    1032 {
    1033     dprintf(("GDI32: SetROP2"));
    1034     return O32_SetROP2(arg1, arg2);
     1035int WIN32API SetROP2( HDC hdc, int rop2)
     1036{
     1037    dprintf(("GDI32: SetROP2 %x %x", hdc, rop2));
     1038    return O32_SetROP2(hdc, rop2);
    10351039}
    10361040//******************************************************************************
     
    12561260//******************************************************************************
    12571261//******************************************************************************
    1258 int WIN32API GetDIBits( HDC arg1, HBITMAP arg2, UINT arg3, UINT arg4, void * arg5, PBITMAPINFO arg6, UINT  arg7)
    1259 {
    1260     dprintf(("GDI32: GetDIBits"));
    1261     return O32_GetDIBits(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
     1262int WIN32API GetDIBits(HDC hdc, HBITMAP hBitmap, UINT uStartScan, UINT cScanLines,
     1263                       void *lpvBits, PBITMAPINFO lpbi, UINT uUsage)
     1264{
     1265 int rc;
     1266
     1267    rc = O32_GetDIBits(hdc, hBitmap, uStartScan, cScanLines, lpvBits, lpbi, uUsage);
     1268    dprintf(("GDI32: GetDIBits %x %x %d %d %x %x %d returned %d", hdc, hBitmap, uStartScan, cScanLines, lpvBits, lpbi, uUsage, rc));
     1269    //SvL: Wrong Open32 return value
     1270    return (rc == TRUE) ? cScanLines : 0;
    12621271}
    12631272//******************************************************************************
     
    19431952//******************************************************************************
    19441953//******************************************************************************
    1945 INT WIN32API SetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx, DWORD cy, INT xSrc, INT ySrc, UINT startscan, UINT lines, LPCVOID bits, const BITMAPINFO *info, UINT coloruse)
    1946 {
    1947     INT result, imgsize, palsize;
     1954INT WIN32API SetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx,
     1955                               DWORD cy, INT xSrc, INT ySrc,
     1956                               UINT startscan, UINT lines, LPCVOID bits,
     1957                               const BITMAPINFO *info, UINT coloruse)
     1958{
     1959    INT result, imgsize, palsize, height, width;
    19481960    char *ptr;
    19491961
    1950     dprintf(("GDI32: SetDIBitsToDevice hdc:%X xDest:%d yDest:%d, cx:%d, cy:%d, xSrc:%d, ySrc:%d, startscan:%d, lines:%d, bits:%X, info%X, coloruse:%d",
    1951                  hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (LPVOID) bits, (PBITMAPINFO)info, coloruse));
     1962    SetLastError(0);
     1963    if(info == NULL) {
     1964        goto invalid_parameter;
     1965    }
     1966    height = info->bmiHeader.biHeight;
     1967    width  = info->bmiHeader.biWidth;
     1968
     1969    if (height < 0) height = -height;
     1970    if (!lines || (startscan >= height)) {
     1971        goto invalid_parameter;
     1972    }
     1973    if (startscan + lines > height) lines = height - startscan;
     1974
     1975    if (ySrc < startscan) ySrc = startscan;
     1976    else if (ySrc >= startscan + lines) goto invalid_parameter;
     1977
     1978    if (xSrc >= width) goto invalid_parameter;
     1979
     1980    if (ySrc + cy >= startscan + lines) cy = startscan + lines - ySrc;
     1981
     1982    if (xSrc + cx >= width) cx = width - xSrc;
     1983
     1984    if (!cx || !cy) goto invalid_parameter;
    19521985
    19531986    // EB: ->>> Crazy. Nobody seen this Open32 bug ?
     
    19661999    // EB: <<<-
    19672000
    1968     result = O32_SetDIBitsToDevice(hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (PVOID) bits, (PBITMAPINFO)info, coloruse);
     2001//    if(xDest == 0 && yDest == 0 && xSrc == 0 && ySrc == 0 && cx == width && cy == height) {
     2002//      result = OSLibSetDIBitsToDevice(hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (PVOID) bits, (WINBITMAPINFOHEADER*)info, coloruse);
     2003//    }
     2004//    else {
     2005        result = O32_SetDIBitsToDevice(hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (PVOID) bits, (PBITMAPINFO)info, coloruse);
     2006        //SvL: Wrong Open32 return value
     2007        result = (result == TRUE) ? lines : 0;
     2008//    }
     2009
     2010    dprintf(("GDI32: SetDIBitsToDevice hdc:%X xDest:%d yDest:%d, cx:%d, cy:%d, xSrc:%d, ySrc:%d, startscan:%d, lines:%d, bits:%X, info%X, coloruse:%d returned %d",
     2011                 hdc, xDest, yDest, cx, cy, xSrc, ySrc, startscan, lines, (LPVOID) bits, (PBITMAPINFO)info, coloruse, result));
    19692012    return result;
     2013
     2014invalid_parameter:
     2015    SetLastError(ERROR_INVALID_PARAMETER);
     2016    return 0;
    19702017}
    19712018//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.