Click to See Complete Forum and Search --> : Anti-aliased font on DibSection. Broken under Win98?!?!?!


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

eviral
November 27th, 2002, 01:58 AM
Hello,

I have tried your piece of code but i don't know where to place it...

I have tried in onInitDialog, OnDraw, OnCreate...

But it doesn't work (compilation error or nothing appear when the app is launched).

Where do you put your piece of code ?

Did you solve your problem with win98 ?

Thanks a lot

Eviral

It's very very hard to find help about font smoothing (anti aliased font) in vc++6 !

Dreamzdoll
May 22nd, 2012, 04:16 AM
Hi,

May be this is too late to post on this thread now.
I am actually working on these things now, thought this information may be useful to others as well,
Actually ANTIALIASED_QUALITY is applicable only for Windows Version 4.0 and Above.

I have used this property while creating a font, but I see no difference in the output MetaFile.

Can anyone help?

Thanks,
DOLL