Changeset 2551 for trunk/src


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

Wrong return values for GetDIBits & SetDIBitsToDevice

Location:
trunk/src/gdi32
Files:
2 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//******************************************************************************
  • trunk/src/gdi32/oslibgdi.cpp

    r2049 r2551  
    1 /* $Id: oslibgdi.cpp,v 1.2 1999-12-09 16:49:45 cbratschi Exp $ */
     1/* $Id: oslibgdi.cpp,v 1.3 2000-01-28 22:24:58 sandervl Exp $ */
    22
    33/*
     
    2727                           UINT coloruse)
    2828{
    29   INT result;
     29  INT result, rc;
    3030  POINTL  points[4];
     31  BITMAPINFO2 os2bmpinfo;
    3132
    3233  // This is a quick hack. Only tested with winmine. Need much more testing.
    3334  // TODO: check parameter and info structure
    3435  lines = (int)lines >= 0 ? (int)lines : (int)-lines;
    35 
    36 #if 0     // WINE990508
    37     tmpheight = height = info->bmiHeader.biHeight;
    38     width = info->bmiHeader.biWidth;
    39     if (height < 0) height = -height;
    40     if (!lines || (startscan >= height)) return 0;
    41     if (startscan + lines > height) lines = height - startscan;
    42     if (ySrc < startscan) ySrc = startscan;
    43     else if (ySrc >= startscan + lines) return 0;
    44     if (xSrc >= width) return 0;
    45     if (ySrc + cy >= startscan + lines) cy = startscan + lines - ySrc;
    46     if (xSrc + cx >= width) cx = width - xSrc;
    47     if (!cx || !cy) return 0;
    48 
    49     descr.dc        = dc;
    50     descr.bits      = bits;
    51     descr.image     = NULL;
    52     descr.lines     = tmpheight >= 0 ? lines : -lines;
    53     descr.infoWidth = width;
    54     descr.depth     = dc->w.bitsPerPixel;
    55     descr.drawable  = physDev->drawable;
    56     descr.gc        = physDev->gc;
    57     descr.xSrc      = xSrc;
    58     descr.ySrc      = tmpheight >= 0 ? lines-(ySrc-startscan)-cy+(oldcy-cy)
    59                                      : ySrc - startscan;
    60     descr.xDest     = dc->w.DCOrgX + XLPTODP( dc, xDest );
    61     descr.yDest     = dc->w.DCOrgY + YLPTODP( dc, yDest ) +
    62                                      (tmpheight >= 0 ? oldcy-cy : 0);
    63     descr.width     = cx;
    64     descr.height    = cy;
    65 #endif
    6636
    6737  points[0].x = xDest;
     
    7444  points[3].y = ySrc + lines;
    7545
    76   // WINBITMAPINFOHEADER and BITMAPINFO2 are identical
    77   GpiDrawBits((HPS)hdc, (VOID *)bits, (BITMAPINFO2 *)info, 4,
    78               points, ROP_SRCCOPY, BBO_IGNORE);
     46  memset(&os2bmpinfo, 0, sizeof(os2bmpinfo)); 
     47  os2bmpinfo.cbFix         = sizeof(BITMAPINFO2) - sizeof(RGB2);
     48  os2bmpinfo.cx            = info->biWidth;
     49  os2bmpinfo.cy            = info->biHeight;
     50  os2bmpinfo.cPlanes       = info->biPlanes;
     51  os2bmpinfo.cBitCount     = info->biBitCount;
     52  os2bmpinfo.ulCompression = info->biCompression;
     53  os2bmpinfo.cbImage       = info->biSizeImage;
     54  os2bmpinfo.cxResolution  = info->biXPelsPerMeter;
     55  os2bmpinfo.cyResolution  = info->biYPelsPerMeter;
     56  os2bmpinfo.cclrUsed      = info->biClrUsed;
     57  os2bmpinfo.cclrImportant = info->biClrImportant;
    7958
     59//  rc = GpiDrawBits((HPS)hdc, (VOID *)bits, &os2bmpinfo, 4,
     60//                   points, ROP_SRCCOPY, BBO_IGNORE);
     61
     62//  if(rc != GPI_OK) {
     63//      dprintf(("GpiDrawBits returned %d", rc));
     64//  }
    8065  return lines;
    8166}
    8267//******************************************************************************
    8368//******************************************************************************
    84 
Note: See TracChangeset for help on using the changeset viewer.