Ignore:
Timestamp:
May 19, 2001, 9:43:54 PM (24 years ago)
Author:
sandervl
Message:

LPtoDP/DPtoLP: check input because GpiConvert doesn't like illegal values

File:
1 edited

Legend:

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

    r5709 r5760  
    1 /* $Id: transform.cpp,v 1.3 2001-05-15 10:34:02 sandervl Exp $ */
     1/* $Id: transform.cpp,v 1.4 2001-05-19 19:43:54 sandervl Exp $ */
    22
    33/*
    4  * GDI32 coordinate & translformation code
     4 * GDI32 coordinate & transformation code
    55 *
    66 * Copyright 2000 Sander van Leeuwen (sandervl@xs4all.nl)
     
    3434static const XFORM_W  XFORMIdentity    = { 1.0, 0.0, 0.0, 1.0, 0, 0 };
    3535
     36//region.cpp (todo; move to header)
     37LONG hdcHeight(HWND hwnd, pDCData pHps);
     38LONG hdcWidth(HWND hwnd, pDCData pHps);
     39
     40//******************************************************************************
     41//******************************************************************************
     42BOOL WIN32API LPtoDP(HDC hdc, PPOINT lpPoints, int nCount)
     43{
     44 BOOL ret;
     45 DWORD hdcwidth, hdcheight;
     46 pDCData pHps;
     47
     48    pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     49    if(!pHps)
     50    {
     51        dprintf(("WARNING: LPtoDP %x invalid handle!!", hdc));
     52        SetLastError(ERROR_INVALID_HANDLE_W);
     53        return FALSE;
     54    }
     55
     56    dprintf(("LPtoDP %x %x %d", hdc, lpPoints, nCount));
     57
     58    //GpiConvert doesn't like illegal values; TODO: check what NT does
     59    if(nCount && lpPoints) {
     60        hdcwidth  = hdcWidth(0, pHps);
     61        hdcheight = hdcHeight(0, pHps);
     62        for(int i=0;i<nCount;i++) {
     63            dprintf(("LPtoDP in (%d,%d)", lpPoints[i].x, lpPoints[i].y));
     64            if(lpPoints[i].x > hdcwidth) {
     65                dprintf(("WARNING: LPtoDP correcting x value; hdcwidth = %d", hdcwidth));
     66                lpPoints[i].x = 0;
     67            }
     68            if(lpPoints[i].y > hdcwidth) {
     69                dprintf(("WARNING: LPtoDP correcting y value; hdcheight = %d", hdcheight));
     70                lpPoints[i].y = 0;
     71            }
     72        }
     73    }
     74    ret = O32_LPtoDP(hdc, lpPoints, nCount);
     75#ifdef DEBUG
     76    if(nCount && lpPoints) {
     77        for(int i=0;i<nCount;i++) {
     78            dprintf(("LPtoDP out (%d,%d)", lpPoints[i].x, lpPoints[i].y));
     79        }
     80    }
     81#endif
     82    return ret;
     83}
     84//******************************************************************************
     85//******************************************************************************
     86BOOL WIN32API DPtoLP(HDC hdc, PPOINT lpPoints, int nCount)
     87{
     88    BOOL ret;
     89    DWORD hdcwidth, hdcheight;
     90    pDCData pHps;
     91
     92    pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
     93    if(!pHps)
     94    {
     95        dprintf(("WARNING: DPtoLP %x invalid handle!!", hdc));
     96        SetLastError(ERROR_INVALID_HANDLE_W);
     97        return FALSE;
     98    }
     99
     100    dprintf(("GDI32: DPtoLP %x %x %d", hdc, lpPoints, nCount));
     101
     102    //GpiConvert doesn't like illegal values; TODO: check what NT does
     103    if(nCount && lpPoints) {
     104        hdcwidth  = hdcWidth(0, pHps);
     105        hdcheight = hdcHeight(0, pHps);
     106        for(int i=0;i<nCount;i++) {
     107            dprintf(("DPtoLP in (%d,%d)", lpPoints[i].x, lpPoints[i].y));
     108            if(lpPoints[i].x > hdcwidth) {
     109                dprintf(("WARNING: DPtoLP correcting x value; hdcwidth = %d", hdcwidth));
     110                lpPoints[i].x = 0;
     111            }
     112            if(lpPoints[i].y > hdcwidth) {
     113                dprintf(("WARNING: DPtoLP correcting y value; hdcheight = %d", hdcheight));
     114                lpPoints[i].y = 0;
     115            }
     116        }
     117    }
     118
     119    ret = O32_DPtoLP(hdc, lpPoints, nCount);
     120#ifdef DEBUG
     121    if(nCount && lpPoints) {
     122        for(int i=0;i<nCount;i++) {
     123            dprintf(("DPtoLP out (%d,%d)", lpPoints[i].x, lpPoints[i].y));
     124        }
     125    }
     126#endif
     127    return ret;
     128}
    36129//******************************************************************************
    37130//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.