I have created the following funtions that gets called when the window is first shown & hide:
VOID SimpleZoomComicStripWindow(HWND hWnd, Gdiplus::Bitmap *bitmap, int numSteps)
{
// center the dialog
CenterWindow(hWnd, TRUE);
// Show it _first_
::ShowWindow(hWnd, SW_SHOW);
// Zoom the window
if (numSteps > 0)
{
for (int i = 1; i < numSteps; i++)
{
Gdiplus::Bitmap *modifiedBitmap = GetZoomedBitmap(bitmap, numSteps, i);
UpdateComicStripWindow(hWnd, modifiedBitmap, i*(255/numSteps));
delete modifiedBitmap;
}
UpdateComicStripWindow(hWnd, bitmap, 255);
}
else if (numSteps < 0)
{
numSteps = -numSteps;
for (int i = numSteps; i > 1; i--)
{
Gdiplus::Bitmap *modifiedBitmap = GetZoomedBitmap(bitmap, numSteps, i);
UpdateComicStripWindow(hWnd, modifiedBitmap, i*(255/numSteps));
delete modifiedBitmap;
}
UpdateComicStripWindow(hWnd, bitmap, 0);
}
}
Gdiplus::Bitmap *GetZoomedBitmap(Gdiplus::Bitmap *originalBitmap, int numSteps, int curStep)
{
if (!originalBitmap)
return NULL;
UINT width = originalBitmap->GetWidth();
UINT height = originalBitmap->GetHeight();
numSteps = (numSteps > height) ? height : numSteps;
UINT sliceHeight = height/numSteps;
FLOAT scaleFactorX = (numSteps) ? (FLOAT)width/(FLOAT)numSteps : 1;
FLOAT scaleFactorY = (numSteps) ? (FLOAT)height/(FLOAT)numSteps : 1;
// Create a new bitmap to hold the modified image
Gdiplus::Bitmap *modifiedBitmap = new Gdiplus::Bitmap(width, height, PixelFormat32bppPARGB);
// Create a graphics object to draw the modified image
Gdiplus::Graphics modifiedGraphics(modifiedBitmap);
modifiedGraphics.SetInterpolationMode(Gdiplus::InterpolationModeHighQuality);
modifiedGraphics.SetSmoothingMode(SmoothingModeAntiAlias);
modifiedGraphics.SetCompositingMode(Gdiplus::CompositingModeSourceCopy); // Used to preserve alpha-channel data
// Create a Rect object that specifies the destination of the image.
Rect destRect((width - (scaleFactorX * curStep))/2, 0, scaleFactorX * curStep, scaleFactorY * curStep);
modifiedGraphics.DrawImage(originalBitmap, destRect, 0, 0, width, height, UnitPixel, NULL, NULL, NULL);
return modifiedBitmap;
}As you can see, I am creating a scaled version of the composited bitmap so the effect of the window being zoomed & coming from tranaparent to opaque will be shown.
The problem I am experimenting is:
1- I have seen that when the wiidow is shown/hide each time the system takes about 10MB of memory that is not being freed until I close the dock (ObjectDock in my case). Although I am calling delete modifiedBitmap; it seems it is not being really freed... am I doing something wrong here?
2- If I add code to cal SetWindowPos at each step increment (to animate the zoom so it will come from the docklet to the center of the screen) I get quite an ungly animation... it looks too steppy & flickers a lot... what strategy should I use to get a better transition effect from minized to zoomed?
Thanks for your help.








Sign In »
Register Now!
Help

MultiQuote