Dan Ut
May 25th, 1999, 12:00 PM
Hi,
I am having a strange problem when I try to render
anti-aliased font under Win98 on 24 bit bitmap
created with DibSection. It works fine under NT 4.0,
but anti-aliasing doesn't work under Win98: fonts edges appear
rough and jagged. It looks to me like Win98 bug.
This is the way I do it:
a. Create font with ANTIALIASED_QUALITY
b. I create a 24-bit bitmap using CreateDIBSection
c. Create memory DC and select that bitmap and font into it.
d. Use TextOut to draw some text.
e. BitBlt from memory DC onto screen DC.
This produces nice smooth text on NT under any color depth,
but rough text with jagged edges in Win98 under any color depth.
Please help. I am getting desperate here :(
Here is the code that I use:
CFont fntFont;
LPBYTE lpImage;
fntFont.CreateFont(30, 0, 0, 0, FW_BOLD, 0, 0, 0,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
DEFAULT_PITCH, "Arial" );
// Load 24-bit bitmap IDB_BITMAP from resources to draw text on
HRSRC rcBitmap = ::FindResource(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_BITMAP),
RT_BITMAP);
LPVOID lpvResource =(LPVOID)::LoadResource(AfxGetResourceHandle(),
rcBitmap);
// Create dib section
HBITMAP hBitmap=::CreateDIBSection(NULL,
(LPBITMAPINFO)lpvResource,
DIB_RGB_COLORS,
(LPVOID*) &lpImage, NULL, 0);
// Don't even bother copying bitmap image data to new dib
// section, it doesn't matter.
// Create mem. DC and draw text on it.
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
dcMem.SelectObject(hBitmap);
dcMem.SelectObject(fntFont);
dcMem.TextOut(0, 0, "Hello Work!!!");
// Blit bitmap on the screen (forget palettes for now,
// I use 24-bit display color depth)
pDC->BitBlt(0, 0, 100, 100, &dcMem, 0, 0, SRCCOPY);
// Clean up
dcMem.~dcMem();
DeleteObject(hBitmap);
I am having a strange problem when I try to render
anti-aliased font under Win98 on 24 bit bitmap
created with DibSection. It works fine under NT 4.0,
but anti-aliasing doesn't work under Win98: fonts edges appear
rough and jagged. It looks to me like Win98 bug.
This is the way I do it:
a. Create font with ANTIALIASED_QUALITY
b. I create a 24-bit bitmap using CreateDIBSection
c. Create memory DC and select that bitmap and font into it.
d. Use TextOut to draw some text.
e. BitBlt from memory DC onto screen DC.
This produces nice smooth text on NT under any color depth,
but rough text with jagged edges in Win98 under any color depth.
Please help. I am getting desperate here :(
Here is the code that I use:
CFont fntFont;
LPBYTE lpImage;
fntFont.CreateFont(30, 0, 0, 0, FW_BOLD, 0, 0, 0,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
DEFAULT_PITCH, "Arial" );
// Load 24-bit bitmap IDB_BITMAP from resources to draw text on
HRSRC rcBitmap = ::FindResource(AfxGetResourceHandle(),
MAKEINTRESOURCE(IDB_BITMAP),
RT_BITMAP);
LPVOID lpvResource =(LPVOID)::LoadResource(AfxGetResourceHandle(),
rcBitmap);
// Create dib section
HBITMAP hBitmap=::CreateDIBSection(NULL,
(LPBITMAPINFO)lpvResource,
DIB_RGB_COLORS,
(LPVOID*) &lpImage, NULL, 0);
// Don't even bother copying bitmap image data to new dib
// section, it doesn't matter.
// Create mem. DC and draw text on it.
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
dcMem.SelectObject(hBitmap);
dcMem.SelectObject(fntFont);
dcMem.TextOut(0, 0, "Hello Work!!!");
// Blit bitmap on the screen (forget palettes for now,
// I use 24-bit display color depth)
pDC->BitBlt(0, 0, 100, 100, &dcMem, 0, 0, SRCCOPY);
// Clean up
dcMem.~dcMem();
DeleteObject(hBitmap);