// Character.cpp : implementation file // #include "stdafx.h" #include "ttf2pcx.h" #include "ttf2pcxdlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CCharacter::CCharacter() { w = h = bw = 0; p = NULL; } CCharacter::~CCharacter() { Destroy(); } void CCharacter::Destroy() { w = h = bw = 0; if (p) { free(p); p = NULL; } } void CCharacter::Get(CFont *font, int c) { Destroy(); CDC cdc; cdc.CreateCompatibleDC(NULL); CFont *oldfont = cdc.SelectObject(font); //wchar_t s[2] = { c, 0 }; char s[2] = { c, 0 }; CSize size = cdc.GetTextExtent( s, 1 ) ; //GetTextExtentPoint32W(cdc.m_hDC, s, 1, &size); //GetTextExtentPoint32(cdc.m_hDC, s, 1, &size); CBitmap *bmp = new CBitmap; bmp->CreateCompatibleBitmap(&cdc, size.cx*2, size.cy); CBitmap *oldbmp = cdc.SelectObject(bmp); cdc.FillSolidRect(0, 0, size.cx*2, size.cy, 0); cdc.SetTextColor(0x00FFFFFF); //TextOutW(cdc.m_hDC, 0, 0, s, 1); //TextOut(cdc.m_hDC, 0, 0, s, 1); cdc.TextOut(0, 0, s, 1); cdc.SelectObject(oldbmp); cdc.SelectObject(oldfont); BITMAP b; bmp->GetBitmap(&b); w = b.bmWidth; h = b.bmHeight; bw = b.bmWidthBytes; p = (unsigned char *)malloc(bw*h); bmp->GetBitmapBits(bw*h, p); delete bmp; if (c > ' ') { while (w > 1) { for (int y=0; y