2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <ddk/winddi.h>
21 #include <include/dib.h>
22 #include <include/object.h>
23 #include <include/surface.h>
28 IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
41 if (DestRect->right < DestRect->left)
43 Exchange = DestRect->left;
44 DestRect->left = DestRect->right;
45 DestRect->right = Exchange;
47 if (DestRect->bottom < DestRect->top)
49 Exchange = DestRect->top;
50 DestRect->top = DestRect->bottom;
51 DestRect->bottom = Exchange;
54 if (NULL != DestObj && STYPE_BITMAP != DestObj->iType &&
55 (NULL == DestObj->pvScan0 || 0 == DestObj->lDelta))
57 EnterLeave->DestGDI = (SURFGDI*)AccessInternalObjectFromUserObject(DestObj);
58 /* Driver needs to support DrvCopyBits, else we can't do anything */
59 if (NULL == EnterLeave->DestGDI->CopyBits)
64 /* Allocate a temporary bitmap */
65 BitmapSize.cx = DestRect->right - DestRect->left;
66 BitmapSize.cy = DestRect->bottom - DestRect->top;
67 Width = DIB_GetDIBWidthBytes(BitmapSize.cx, BitsPerFormat(DestObj->iBitmapFormat));
68 EnterLeave->OutputBitmap = EngCreateBitmap(BitmapSize, Width,
69 DestObj->iBitmapFormat,
70 BMF_NOZEROINIT, NULL);
71 *OutputObj = (SURFOBJ *) AccessUserObject((ULONG) EnterLeave->OutputBitmap);
73 EnterLeave->DestRect.left = 0;
74 EnterLeave->DestRect.top = 0;
75 EnterLeave->DestRect.right = BitmapSize.cx;
76 EnterLeave->DestRect.bottom = BitmapSize.cy;
77 SrcPoint.x = DestRect->left;
78 SrcPoint.y = DestRect->top;
79 EnterLeave->TrivialClipObj = EngCreateClip();
80 EnterLeave->TrivialClipObj->iDComplexity = DC_TRIVIAL;
81 if (! EnterLeave->DestGDI->CopyBits(*OutputObj, DestObj,
82 EnterLeave->TrivialClipObj, NULL,
83 &EnterLeave->DestRect, &SrcPoint))
85 EngDeleteClip(EnterLeave->TrivialClipObj);
86 EngFreeMem((*OutputObj)->pvBits);
87 EngDeleteSurface(EnterLeave->OutputBitmap);
90 EnterLeave->DestRect.left = DestRect->left;
91 EnterLeave->DestRect.top = DestRect->top;
92 EnterLeave->DestRect.right = DestRect->right;
93 EnterLeave->DestRect.bottom = DestRect->bottom;
94 Translate->x = - DestRect->left;
95 Translate->y = - DestRect->top;
101 *OutputObj = DestObj;
104 EnterLeave->DestObj = DestObj;
105 EnterLeave->OutputObj = *OutputObj;
106 EnterLeave->ReadOnly = ReadOnly;
112 IntEngLeave(PINTENG_ENTER_LEAVE EnterLeave)
117 if (EnterLeave->OutputObj != EnterLeave->DestObj && NULL != EnterLeave->OutputObj)
119 if (! EnterLeave->ReadOnly)
123 Result = EnterLeave->DestGDI->CopyBits(EnterLeave->DestObj,
124 EnterLeave->OutputObj,
125 EnterLeave->TrivialClipObj, NULL,
126 &EnterLeave->DestRect, &SrcPoint);
128 EngFreeMem(EnterLeave->OutputObj->pvBits);
129 EngDeleteSurface(EnterLeave->OutputBitmap);
130 EngDeleteClip(EnterLeave->TrivialClipObj);