// JP opened flex table

Click to See Complete Forum and Search --> : BUG: Rendering text under Win95/98 (UNBELIEVABLE!!!)


Dan Ut
June 6th, 1999, 12:54 AM
Hello,

My program has to do the following:

Create a bitmap
Render some text on it in large font (48pts.)
Display the bitmap

It is a no-brainer, but with one annoying
exception: large letters look ugly (jagged edges)
if I use standard CBitmap.

Solution: create a 24bit DIB section, and render
text on it. To make text look nice I use
ANTIALIASED_QUALITY when I call CreateFont.

Although it works great under WinNT4.0, it
doesn't work under Win95/98. Font there is
rendered but it is not aniti-aliased despite
ANTIALIASED_QUALITY flag. I read that
antialiasing won't work on Win95 systems with no
service pack or PLUS installed, but I made sure
that computers that I tested it on meet this
requirement.

More detailed description of what I do:

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);

//JP added flex table