Esempio n. 1
0
void ApplyFilter(IFilterProcessor& filter)
{
	LARGE_INTEGER start, end;
	QueryPerformanceCounter(&start);

	BitmapPtr inBitmap = bitmap;

	BitmapPtr outBitmap = BitmapPtr(
		inBitmap->Clone(0, 0, inBitmap->GetWidth(), inBitmap->GetHeight(),
		PixelFormat32bppARGB));

	Gdiplus::Rect rect(0, 0, inBitmap->GetWidth(), inBitmap->GetHeight());
	Gdiplus::BitmapData originalImage;
	inBitmap->LockBits(&rect, Gdiplus::ImageLockModeWrite,
		PixelFormat32bppARGB, &originalImage);

	Gdiplus::BitmapData processedImage;
	outBitmap->LockBits(&rect, Gdiplus::ImageLockModeWrite,
		PixelFormat32bppARGB, &processedImage);

	filter.ProcessImage(originalImage, processedImage);

	bitmap = outBitmap;

	inBitmap->UnlockBits(&originalImage);
	outBitmap->UnlockBits(&processedImage);

	QueryPerformanceCounter(&end);
	elapsedTime = ComputeElapsedTime(start, end);
}
Esempio n. 2
0
Sprite::Sprite(BitmapPtr pBitmap)
{
	m_pBitmap = pBitmap;
	SetRect(&m_rcPosition, 0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
	m_ptVelocity.x = m_ptVelocity.y = 0;
	m_iZOrder = 0;
	SetRect(&m_rcBounds, 0, 0, 640, 480);
	m_baBoundsAction = BA_STOP;
	m_bHidden = FALSE;
	CalcCollisionRec();
}
Esempio n. 3
0
    static Color Sample(const BitmapPtr bitmap, float u, float v)
    {
        u32 width = bitmap->GetWidth();
        u32 height = bitmap->GetHeight();

        float fx = XAddresserType::CalcAddress(u, width);
        int x = XAddresserType::FixAddress(Mathf::RoundToInt(fx), width);
        float fy = YAddresserType::CalcAddress(v, height);
        int y = YAddresserType::FixAddress(Mathf::RoundToInt(fy), height);

        return bitmap->GetColor(x, y);
    }
Esempio n. 4
0
Sprite::Sprite(BitmapPtr pBitmap, POINT ptPosition, POINT ptVelocity, int iZOrder,
			   RECT& rcBounds, BOUNDSACTION baBoundsAction)
{
	m_pBitmap = pBitmap;
	SetRect(&m_rcPosition, ptPosition.x, ptPosition.y,
		ptPosition.x + pBitmap->GetWidth(), ptPosition.y + pBitmap->GetHeight());
	m_ptVelocity = ptVelocity;
	m_iZOrder = iZOrder;
	CopyRect(&m_rcBounds, &rcBounds);
	m_baBoundsAction = baBoundsAction;
	m_bHidden = FALSE;
	CalcCollisionRec();
}
Esempio n. 5
0
Sprite::Sprite(BitmapPtr pBitmap, RECT& rcBounds, BOUNDSACTION baBoundsAction)
{
	int iXPos = rand() % (rcBounds.right - rcBounds.left);
	int iYPos = rand() % (rcBounds.bottom - rcBounds.top);

	m_pBitmap = pBitmap;
	SetRect(&m_rcPosition, iXPos, iYPos, iXPos + pBitmap->GetWidth(),
		iYPos + pBitmap->GetHeight());
	m_ptVelocity.x = m_ptVelocity.y = 0;
	m_iZOrder = 0;
	CopyRect(&m_rcBounds, &rcBounds);
	m_baBoundsAction = baBoundsAction;
	m_bHidden = FALSE;
	CalcCollisionRec();
}
Esempio n. 6
0
    static Color Sample(const BitmapPtr bitmap, float u, float v)
    {
        u32 width = bitmap->GetWidth();
        u32 height = bitmap->GetHeight();

        float fx = XAddresserType::CalcAddress(u, width);
        int x0 = Mathf::FloorToInt(fx);
        float fy = YAddresserType::CalcAddress(v, height);
        int y0 = Mathf::FloorToInt(fy);
        float xFrac = fx - x0;
        float yFrac = fy - y0;
        x0 = XAddresserType::FixAddress(x0, width);
        y0 = YAddresserType::FixAddress(y0, height);
        int x1 = XAddresserType::FixAddress(x0 + 1, width);
        int y1 = YAddresserType::FixAddress(y0 + 1, height);

        Color c0 = bitmap->GetColor(x0, y0);
        Color c1 = bitmap->GetColor(x1, y0);
        Color c2 = bitmap->GetColor(x0, y1);
        Color c3 = bitmap->GetColor(x1, y1);

        return Color::Lerp(c0, c1, c2, c3, xFrac, yFrac);
    }