Getting scaled images to look better than just a StretchBlt
Posted on 1998-06-02
I have been using StretchBlt to scale images in my Windows app, but they look really bad. They seem to be suffering both from aliasing artifacts and color palette problems (even though I'm running in 16-bit mode).
Can you suggest a scaling algorithm which will scale and filter an image?
I would like a function that has a prototype like:
HBITMAP FilteredScale (HBITMAP hbm, HDC hdc);
Here's my current algorithm:
HBITMAP ImageManager::GetBitmap (CString filename, int width, int height, CDC *dc)
HBITMAP bitmap = GetBitmap (filename, dc);
HDC hdc = dc->GetSafeHdc();
HDC memDC = CreateCompatibleDC (hdc);
HBITMAP newBitmap = CreateCompatibleBitmap (hdc, width, height);
SelectObject (memDC, newBitmap);
success = StretchBitmap (memDC, 0,0, width, height, bitmap, SRCCOPY);
SelectObject (memDC, bitmap);
Thanks for your help,