mirror of
https://github.com/reactos/reactos.git
synced 2024-08-27 13:48:42 +00:00
[WIN32K]
In NtGdiGetPixel check if the requested pixel is inside the boundaries of the surface, and return CLR_INVALID if not. svn path=/trunk/; revision=56437
This commit is contained in:
parent
e33dcea4d4
commit
dfa925989c
|
@ -1109,8 +1109,7 @@ NtGdiGetPixel(
|
||||||
_In_ INT y)
|
_In_ INT y)
|
||||||
{
|
{
|
||||||
PDC pdc;
|
PDC pdc;
|
||||||
ULONG ulRGBColor;
|
ULONG ulRGBColor = CLR_INVALID;
|
||||||
BOOL bResult = FALSE;
|
|
||||||
POINTL ptlSrc;
|
POINTL ptlSrc;
|
||||||
PSURFACE psurfSrc, psurfDest;
|
PSURFACE psurfSrc, psurfDest;
|
||||||
|
|
||||||
|
@ -1119,7 +1118,7 @@ NtGdiGetPixel(
|
||||||
if (!pdc)
|
if (!pdc)
|
||||||
{
|
{
|
||||||
EngSetLastError(ERROR_INVALID_HANDLE);
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
||||||
return -1;
|
return CLR_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the DC has no surface (empty mem or info DC) */
|
/* Check if the DC has no surface (empty mem or info DC) */
|
||||||
|
@ -1127,8 +1126,7 @@ NtGdiGetPixel(
|
||||||
if (psurfSrc == NULL)
|
if (psurfSrc == NULL)
|
||||||
{
|
{
|
||||||
/* Fail! */
|
/* Fail! */
|
||||||
DC_UnlockDc(pdc);
|
goto leave;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the logical coordinates */
|
/* Get the logical coordinates */
|
||||||
|
@ -1140,6 +1138,14 @@ NtGdiGetPixel(
|
||||||
ptlSrc.x += pdc->ptlDCOrig.x;
|
ptlSrc.x += pdc->ptlDCOrig.x;
|
||||||
ptlSrc.y += pdc->ptlDCOrig.y;
|
ptlSrc.y += pdc->ptlDCOrig.y;
|
||||||
|
|
||||||
|
/* Check if the pixel is outside the surface */
|
||||||
|
if ((ptlSrc.x >= psurfSrc->SurfObj.sizlBitmap.cx) ||
|
||||||
|
(ptlSrc.y >= psurfSrc->SurfObj.sizlBitmap.cy))
|
||||||
|
{
|
||||||
|
/* Fail! */
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate a surface */
|
/* Allocate a surface */
|
||||||
psurfDest = SURFACE_AllocSurface(STYPE_BITMAP, 1, 1, BMF_32BPP);
|
psurfDest = SURFACE_AllocSurface(STYPE_BITMAP, 1, 1, BMF_32BPP);
|
||||||
if (psurfDest)
|
if (psurfDest)
|
||||||
|
@ -1159,7 +1165,7 @@ NtGdiGetPixel(
|
||||||
RGB(0,0,0));
|
RGB(0,0,0));
|
||||||
|
|
||||||
/* Call the copy bits function */
|
/* Call the copy bits function */
|
||||||
bResult = IntEngCopyBits(&psurfDest->SurfObj,
|
EngCopyBits(&psurfDest->SurfObj,
|
||||||
&psurfSrc->SurfObj,
|
&psurfSrc->SurfObj,
|
||||||
NULL,
|
NULL,
|
||||||
&exlo.xlo,
|
&exlo.xlo,
|
||||||
|
@ -1174,10 +1180,11 @@ NtGdiGetPixel(
|
||||||
GDIOBJ_vDeleteObject(&psurfDest->BaseObject);
|
GDIOBJ_vDeleteObject(&psurfDest->BaseObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leave:
|
||||||
/* Unlock the DC */
|
/* Unlock the DC */
|
||||||
DC_UnlockDc(pdc);
|
DC_UnlockDc(pdc);
|
||||||
|
|
||||||
/* Return the new RGB color or -1 on failure */
|
/* Return the new RGB color or -1 on failure */
|
||||||
return bResult ? ulRGBColor : -1;
|
return ulRGBColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue