I am using GDI+ to draw png image with transparency.
after sometime I want to draw same image with some rotation. but I am not able to remove The previous image date. So my rendered window is a series of old images.
void CBusyWnd::drawImage ( )
{
if (mImage)
{
Gdiplus::Graphics gdip(mWnd);
gdip.ResetTransform();
gdip.TranslateTransform((Gdiplus::REAL)(mImage->GetWidth())/2.0f,(Gdiplus::REAL)(mImage->GetHeight())/2.0f);
gdip.RotateTransform(mAngle=mAngle>360?0:mAngle+1);
gdip.TranslateTransform(-1.0f*(Gdiplus::REAL)(mImage->GetWidth())/2.0f,-1.0f*(Gdiplus::REAL)(mImage->GetHeight())/2.0f);
gdip.DrawImage(mImage, 0, 0, mImage->GetWidth(), mImage->GetHeight());
gdip.Flush();
}
InvalidateRect(mWnd, NULL, FALSE);
}
please find image at
http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/825a5243-9441-4abc-be30-e5598ccc9872[
^]
my registered window class is:-
outWndClass.style = CS_HREDRAW | CS_VREDRAW;
outWndClass.lpfnWndProc = wndProc;
outWndClass.hInstance = GetModuleHandle(NULL);
outWndClass.hCursor = LoadCursor(NULL, IDC_APPSTARTING);
outWndClass.hbrBackground = (HBRUSH)GetStockObject(HOLLOW_BRUSH);outWndClass.lpszClassName = L"BusyWnd";
outWndClass.hIcon = LoadIcon(outWndClass.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
if (!RegisterClass(&outWndClass))
{
if (GetLastError() != 0x00000582) {
OutputDebugString(L"Unable to register class BusyWnd\n");
return false;
}
}
Can anyone help give me some pointer.
I tried following code for clearing the window before each draw. but Code is too slow and the is no way to set transparency.
HDC hdc = GetDC(mWnd); for( UINT i = 0 ; i < mImage->GetWidth() ; i++ )
for( UINT j = 0 ; j < mImage->GetHeight() ; j++ )
SetPixel(hdc, i,j, RGB(255,255,255)); ReleaseDC(mWnd, hdc); DeleteDC(hdc);