| 1 | /* $Id: oslibgdi.cpp,v 1.2 1999-12-09 16:49:45 cbratschi Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * GDI32 support code
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1999 Edgar Buerkle (Edgar.Buerkle@gmx.net)
|
|---|
| 7 | *
|
|---|
| 8 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 9 | *
|
|---|
| 10 | */
|
|---|
| 11 | #define INCL_GPI
|
|---|
| 12 | #define INCL_WIN
|
|---|
| 13 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
|---|
| 14 | #include <stdlib.h>
|
|---|
| 15 | #include <string.h>
|
|---|
| 16 | #include <win32type.h>
|
|---|
| 17 | #include <misc.h>
|
|---|
| 18 | #define OS2_ONLY
|
|---|
| 19 | #include "dibsect.h"
|
|---|
| 20 | #include "oslibgdi.h"
|
|---|
| 21 |
|
|---|
| 22 | //******************************************************************************
|
|---|
| 23 | //******************************************************************************
|
|---|
| 24 | INT OSLibSetDIBitsToDevice(HDC hdc, INT xDest, INT yDest, DWORD cx, DWORD cy,
|
|---|
| 25 | INT xSrc, INT ySrc, UINT startscan, UINT lines,
|
|---|
| 26 | LPCVOID bits, WINBITMAPINFOHEADER *info,
|
|---|
| 27 | UINT coloruse)
|
|---|
| 28 | {
|
|---|
| 29 | INT result;
|
|---|
| 30 | POINTL points[4];
|
|---|
| 31 |
|
|---|
| 32 | // This is a quick hack. Only tested with winmine. Need much more testing.
|
|---|
| 33 | // TODO: check parameter and info structure
|
|---|
| 34 | 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
|
|---|
| 66 |
|
|---|
| 67 | points[0].x = xDest;
|
|---|
| 68 | points[0].y = yDest + cy - 1; // Y-inverted
|
|---|
| 69 | points[1].x = xDest + cx - 1;
|
|---|
| 70 | points[1].y = yDest; // Y-inverted
|
|---|
| 71 | points[2].x = xSrc;
|
|---|
| 72 | points[2].y = ySrc + startscan;
|
|---|
| 73 | points[3].x = xSrc + cx;
|
|---|
| 74 | points[3].y = ySrc + lines;
|
|---|
| 75 |
|
|---|
| 76 | // WINBITMAPINFOHEADER and BITMAPINFO2 are identical
|
|---|
| 77 | GpiDrawBits((HPS)hdc, (VOID *)bits, (BITMAPINFO2 *)info, 4,
|
|---|
| 78 | points, ROP_SRCCOPY, BBO_IGNORE);
|
|---|
| 79 |
|
|---|
| 80 | return lines;
|
|---|
| 81 | }
|
|---|
| 82 | //******************************************************************************
|
|---|
| 83 | //******************************************************************************
|
|---|
| 84 |
|
|---|