void RescaleRect(const std::vector<cv::Rect>& rects, std::vector<cv::Rect>& dst_rects, double scale)
	{
		int num_rect = rects.size();
		dst_rects.resize(num_rect);
		for (int i = 0; i < num_rect; i++){
			cv::Rect dst;
			RescaleRect(rects[i], dst, scale);
			dst_rects[i] = dst;
		}
	}
예제 #2
0
void AVisionDeviceReceiver::RemoveTower(FRect2D PhysicalCoords)
{
	TowerData OldTower;
	int32 OwnerID = ZoneOwnerID(PhysicalCoords);
	if (OwnerID == -1) return;
	OldTower.GameCoords = RescaleRect(
		PlayerZones[OwnerID].Real, PlayerZones[OwnerID].Game, PhysicalCoords);
	for (auto Tower : TowerList[OwnerID]){
		if (FVector2D::Distance(Tower.GameCoords.Centre, OldTower.GameCoords.Centre)
			<= (Tower.GameCoords.Size.X / 4)){
			Tower.Status = TS_Removed;
			return;
		}
	}
}
예제 #3
0
void AVisionDeviceReceiver::AddNewTower(FRect2D PhysicalCoords)
{
    TowerData NewTower;
    int32 OwnerID = ZoneOwnerID(PhysicalCoords);
    if (OwnerID == -1) return;
    NewTower.GameCoords = RescaleRect(
        PlayerZones[OwnerID].Real, PlayerZones[OwnerID].Game, PhysicalCoords);
	for (auto Tower : TowerList[OwnerID]){
		if ((Tower.Status == TS_Gone || Tower.Status == TS_Removed) &&
			FVector2D::Distance(Tower.GameCoords.Centre, NewTower.GameCoords.Centre)
			<= (Tower.GameCoords.Size.X / 4)){
			Tower.Status = TS_Restored;
			return;
		}
	}
    NewTower.ID = TowerCounter++;
    NewTower.Status = TS_New;
    TowerList[OwnerID].Add(NewTower);
}
예제 #4
0
파일: layout.c 프로젝트: Moteesh/reactos
static VOID
WinPrev_OnDraw(
    IN HDC hDC,
    IN PWINPREV_DATA pData)
{
    PCONSOLE_STATE_INFO pConInfo = (PCONSOLE_STATE_INFO)pData->pData;
    HBRUSH hBrush;
    RECT rcWin, fRect;
    SIZE /*siBorder,*/ siFrame, siButton, siScroll;
    SIZE resize;

    RECT rcItem;

    GetClientRect(pData->hWnd, &rcItem);

    /*
     * Retrieve some system metrics and rescale them.
     * They will be added separately, so that to always round the sizes up.
     */

    /* Don't care about border as it is almost always 1 and <= frame size */
    /* Example: Frame = 4, or 13 ... while Border = 1 */
    // siBorder.cx = GetSystemMetrics(SM_CXBORDER);
    // siBorder.cy = GetSystemMetrics(SM_CYBORDER);

    /* Window frame size */
    siFrame.cx = GetSystemMetrics(SM_CXFRAME);
    if (siFrame.cx > 0)
    {
        siFrame.cx = RescaleCX(pData, siFrame.cx);
        siFrame.cx = max(1, siFrame.cx);
    }
    siFrame.cy = GetSystemMetrics(SM_CYFRAME);
    if (siFrame.cy > 0)
    {
        siFrame.cy = RescaleCY(pData, siFrame.cy);
        siFrame.cy = max(1, siFrame.cy);
    }

    /* Window caption buttons */
    siButton.cx = GetSystemMetrics(SM_CXSIZE);
    siButton.cx = RescaleCX(pData, siButton.cx);
    siButton.cx = max(1, siButton.cx);

    siButton.cy = GetSystemMetrics(SM_CYSIZE);
    siButton.cy = RescaleCY(pData, siButton.cy);
    siButton.cy = max(1, siButton.cy);

    /* Enlarge them for improving their appearance */
    // siButton.cx *= 2;
    siButton.cy *= 2;

    /* Dimensions of the scrollbars */
    siScroll.cx = GetSystemMetrics(SM_CXVSCROLL);
    siScroll.cx = RescaleCX(pData, siScroll.cx);
    siScroll.cx = max(1, siScroll.cx);

    siScroll.cy = GetSystemMetrics(SM_CYHSCROLL);
    siScroll.cy = RescaleCY(pData, siScroll.cy);
    siScroll.cy = max(1, siScroll.cy);


    // FIXME: Use SM_CXMIN, SM_CYMIN ??


    /*
     * Compute the console window layout
     */

    /* We start with the console client area, rescaled for the preview */
    SetRect(&rcWin, 0, 0,
            pConInfo->WindowSize.X * pConInfo->FontSize.X,
            pConInfo->WindowSize.Y * pConInfo->FontSize.Y);
    RescaleRect(pData, rcWin);

    /* Add the scrollbars if needed (does not account for any frame) */
    if (pConInfo->WindowSize.X < pConInfo->ScreenBufferSize.X)
    {
        /* Horizontal scrollbar */
        rcWin.bottom += siScroll.cy;
        // NOTE: If an additional exterior frame is needed, add +1
    }
    else
    {
        /* No scrollbar */
        siScroll.cy = 0;
    }
    if (pConInfo->WindowSize.Y < pConInfo->ScreenBufferSize.Y)
    {
        /* Vertical scrollbar */
        rcWin.right += siScroll.cx;
        // NOTE: If an additional exterior frame is needed, add +1
    }
    else
    {
        /* No scrollbar */
        siScroll.cx = 0;
    }

    /* Add the title bar, taking into account the frames */
    rcWin.top -= siButton.cy - 1;

    /* If we have a non-zero window frame size, add an interior border and the frame */
    resize.cx = (siFrame.cx > 0 ? 1 + siFrame.cx : 0);
    resize.cy = (siFrame.cy > 0 ? 1 + siFrame.cy : 0);

    /* Add the outer border */
    ++resize.cx, ++resize.cy;

    InflateRect(&rcWin, resize.cx, resize.cy);

    /* Finally, move the window rectangle back to its correct origin */
    OffsetRect(&rcWin, -rcWin.left, -rcWin.top);

    if ( pConInfo->WindowPosition.x == MAXDWORD &&
         pConInfo->WindowPosition.y == MAXDWORD )
    {
        // OffsetRect(&rcWin, (rcItem.right - rcItem.left) / 3, (rcItem.bottom - rcItem.top) / 3);
        OffsetRect(&rcWin, 0, 0);
    }
    else
    {
        OffsetRect(&rcWin,
                   RescaleCX(pData, pConInfo->WindowPosition.x),
                   RescaleCY(pData, pConInfo->WindowPosition.y));
    }


    /*
     * Paint the preview window
     */

    /* Fill the background with desktop colour */
    FillRect(hDC, &rcItem, GetSysColorBrush(COLOR_BACKGROUND));

    /*
     * Draw the exterior frame. Use 'FillRect' instead of 'FrameRect'
     * so that, when we want to draw frames around other elements,
     * we can just instead separate them with space instead of redrawing
     * a frame with 'FrameRect'.
     */
    FillRect(hDC, &rcWin, GetSysColorBrush(COLOR_WINDOWFRAME));
    InflateRect(&rcWin, -1, -1);

    /* Draw the border */
    hBrush = GetSysColorBrush(COLOR_ACTIVEBORDER);
    if (siFrame.cx > 0)
    {
        SetRect(&fRect, rcWin.left, rcWin.top, rcWin.left + siFrame.cx, rcWin.bottom);
        FillRect(hDC, &fRect, hBrush);
        SetRect(&fRect, rcWin.right - siFrame.cx, rcWin.top, rcWin.right, rcWin.bottom);
        FillRect(hDC, &fRect, hBrush);

        InflateRect(&rcWin, -siFrame.cx, 0);
    }
    if (siFrame.cy > 0)
    {
        SetRect(&fRect, rcWin.left, rcWin.top, rcWin.right, rcWin.top + siFrame.cy);
        FillRect(hDC, &fRect, hBrush);
        SetRect(&fRect, rcWin.left, rcWin.bottom - siFrame.cy, rcWin.right, rcWin.bottom);
        FillRect(hDC, &fRect, hBrush);

        InflateRect(&rcWin, 0, -siFrame.cy);
    }

    /* Draw the interior frame if we had a border */
    if (siFrame.cx > 0 || siFrame.cy > 0)
    {
#if 0 // See the remark above
        SetRect(&fRect, rcWin.left, rcWin.top, rcWin.right, rcWin.bottom);
        FrameRect(hDC, &fRect, GetSysColorBrush(COLOR_WINDOWFRAME));
#endif
        InflateRect(&rcWin, (siFrame.cx > 0 ? -1 : 0), (siFrame.cy > 0 ? -1 : 0));
    }

    /* Draw the console window title bar */
    hBrush = GetSysColorBrush(COLOR_BTNFACE);

    /* Draw the system menu (left button) */
    SetRect(&fRect, rcWin.left, rcWin.top, rcWin.left + siButton.cx, rcWin.top + siButton.cy - 2);
    // DrawFrameControl(hDC, &fRect, DFC_CAPTION, DFCS_CAPTIONCLOSE);
    FillRect(hDC, &fRect, hBrush);
    fRect.right++; // Separation

    /* Draw the caption bar */
    SetRect(&fRect, fRect.right, fRect.top, rcWin.right - 2 * (siButton.cx + 1), fRect.bottom);
    FillRect(hDC, &fRect, GetSysColorBrush(COLOR_ACTIVECAPTION));
    fRect.right++; // Separation

    /* Draw the minimize menu (first right button) */
    SetRect(&fRect, fRect.right, fRect.top, fRect.right + siButton.cx, fRect.bottom);
    // DrawFrameControl(hDC, &fRect, DFC_CAPTION, DFCS_CAPTIONMIN);
    FillRect(hDC, &fRect, hBrush);
    fRect.right++; // Separation

    /* Draw the maximize menu (second right button) */
    SetRect(&fRect, fRect.right, fRect.top, fRect.right + siButton.cx, fRect.bottom);
    // DrawFrameControl(hDC, &fRect, DFC_CAPTION, DFCS_CAPTIONMAX);
    FillRect(hDC, &fRect, hBrush);

    rcWin.top += siButton.cy - 1;

    /* Add the scrollbars if needed */
    if (siScroll.cy > 0 || siScroll.cx > 0)
    {
        LONG right, bottom;

        right  = rcWin.right;
        bottom = rcWin.bottom;

        /*
         * If both the horizontal and vertical scrollbars are present,
         * reserve some space for the "dead square" at the bottom right.
         */
        if (siScroll.cy > 0 && siScroll.cx > 0)
        {
            right  -= (1 + siScroll.cx);
            bottom -= (1 + siScroll.cy);
        }

        hBrush = GetSysColorBrush(COLOR_SCROLLBAR);

        /* Horizontal scrollbar */
        if (siScroll.cy > 0)
        {
            SetRect(&fRect, rcWin.left, rcWin.bottom - siScroll.cy, right, rcWin.bottom);
            FillRect(hDC, &fRect, hBrush);
        }

        /* Vertical scrollbar */
        if (siScroll.cx > 0)
        {
            SetRect(&fRect, rcWin.right - siScroll.cx, rcWin.top, rcWin.right, bottom);
            FillRect(hDC, &fRect, hBrush);
        }

        /*
         * If both the horizontal and vertical scrollbars are present,
         * draw the "dead square" at the bottom right.
         */
        if (siScroll.cy > 0 && siScroll.cx > 0)
        {
            SetRect(&fRect, rcWin.right - siScroll.cx, rcWin.bottom - siScroll.cy, rcWin.right, rcWin.bottom);
            FillRect(hDC, &fRect, hBrush);
        }

        // NOTE: If an additional exterior frame is needed, remove +1 for each direction
        rcWin.right  -= siScroll.cx;
        rcWin.bottom -= siScroll.cy;
    }

    /* Draw the console background */
    hBrush = CreateSolidBrush(pConInfo->ColorTable[BkgdAttribFromAttrib(pConInfo->ScreenAttributes)]);
    FillRect(hDC, &rcWin, hBrush);
    DeleteObject(hBrush);
}
예제 #5
0
    HOOKFUNC BOOL WINAPI MyBitBlt(HDC hdcDest,
            int nXDest, int nYDest,
            int nWidth, int nHeight,
            HDC hdcSrc,
            int nXSrc, int nYSrc,
            DWORD dwRop)
    {
        bool isFrameBoundary = false;
        if (!usingSDLOrDD /*&& !inPauseHandler*/ && !redrawingScreen)
        {
            if (dwRop == SRCCOPY)
            {
                HWND hwnd = WindowFromDC(hdcDest);
                if (hwnd /*&& !hwndRespondingToPaintMessage[hwnd]*/)
                {
                    if ((/*s_gdiPhaseDetector.AdvanceAndCheckCycleBoundary(MAKELONG(nXDest,nYDest))
                        ||*/ tls.peekedMessage) && VerifyIsTrustedCaller(!tls.callerisuntrusted))
                    {
                        if ((nWidth >= gdiFrameBigEnoughWidth && nHeight >= gdiFrameBigEnoughHeight)
                            || HDCSizeBigEnoughForFrameBoundary(hdcSrc))
                        {
                            isFrameBoundary = true;
                        }
                    }
                }
            }
        }

        ENTER(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);



        BOOL rv = TRUE;
        if (!ShouldSkipDrawing(false, WindowFromDC(hdcDest) != 0))
        {
            if (s_gdiPendingRefresh && !redrawingScreen)
            {
                redrawingScreen = true;
                RedrawScreenGDI();
                redrawingScreen = false;
            }
            if (!fakeDisplayValid)
            {
                rv = BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
            }
            else
            {
                HWND hwnd = WindowFromDC(hdcDest);
                RECT realRect;
                if (!GetClientRect(hwnd, &realRect) || (realRect.right == fakeDisplayWidth && realRect.bottom == fakeDisplayHeight))
                {
                    rv = BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, dwRop);
                }
                else
                {
                    // support resized fake-fullscreen windows in games like Lyle in Cube Sector
                    // a little iffy: sprites leave pixels behind occasionally at non-integral scales
                    HDC hdcTemp = 0;
                    HDC hdc = hdcDest;
                    if (realRect.right > fakeDisplayWidth || realRect.bottom > fakeDisplayHeight)
                    {
                        // sidestep clip region (it can't be expanded without switching HDCs)
                        hdcTemp = GetDC(hwnd);
                        hdc = hdcTemp;
                    }
                    // FIXME this feature actually broke, it's drawing at 100% size again no matter the window size,
                    // it probably broke because of extra hooking of functions like GetClientRect.
                    RECT dstRect = { nXDest, nYDest, nXDest + nWidth, nYDest + nHeight };
                    RECT fakeRect = { 0, 0, fakeDisplayWidth, fakeDisplayHeight };
                    RescaleRect(dstRect, fakeRect, realRect);
                    rv = StretchBlt(hdc, dstRect.left, dstRect.top, dstRect.right - dstRect.left, dstRect.bottom - dstRect.top, hdcSrc, nXSrc, nYSrc, nWidth, nHeight, dwRop);
                    if (hdcTemp)
                        ReleaseDC(hwnd, hdcTemp);
                }
            }
        }
        else
            s_gdiPendingRefresh = true;

        if (isFrameBoundary)
        {
            tls.peekedMessage = FALSE;
            if (!(tasflags.aviMode & 1))
                FrameBoundary(NULL, CAPTUREINFO_TYPE_NONE);
            else
                FrameBoundaryHDCtoAVI(hdcSrc, nXSrc, nYSrc, nWidth, nHeight);
            s_hdcSrcSaved = hdcSrc;
            s_hdcDstSaved = hdcDest;
        }

        return rv;
    }