中文点阵字库:制做自己的点阵字库的思路方法和程序



fontmaker.h

/////////////////////////////////////////////////////////////////////////////
// ELEMENT GDI/DX Game Engine [Version 2002/3/1]
/////////////////////////////////////////////////////////////////////////////
// Original Author : 邱海峰[Southdy]
// OICQ : 359766
// EMAIL: [email protected]
/////////////////////////////////////////////////////////////////////////////
// DESCRIPTION:
// OTHER: 邱海峰创建于2002/3/1
/////////////////////////////////////////////////////////////////////////////
#pragma _disibledevent=>fontmaker.cpp

/////////////////////////////////////////////////////////////////////////////
// ELEMENT GDI/DX Game Engine [Version 2002/3/1]
/////////////////////////////////////////////////////////////////////////////
// Original Author : 邱海峰[Southdy]
// OICQ : 359766
// EMAIL: [email protected]
/////////////////////////////////////////////////////////////////////////////
// DESCRIPTION:
// OTHER: 邱海峰创建于2002/3/1
/////////////////////////////////////////////////////////////////////////////
#pragma message(\"点阵汉字制作简单演示\")
/////////////////////////////////////////////////////////////////////////////
// 包含文件
/////////////////////////////////////////////////////////////////////////////

# \"fontmaker.h\"
#

# FONTPOINT 12

/////////////////////////////////////////////////////////////////////////////
// FUNCTION:
// PURPOSE: 窗口入口
// ENTRY:
// EXITS:
// SUCCESS :
// FAILURE :
// OTHER:
/////////////////////////////////////////////////////////////////////////////
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, nCmdShow)
{
MyApp mywin(hInstance);
(!mywin.InitMain(NULL,\"ELEMENT\",\"云海孤峰\", WS_VISIBLE|WS_SYSMENU|WS_MINIMIZEBOX|WS_OVERLAPPED,0,0,640,480,NULL,\"EK_MENU\"))
0;
mywin.Excute;
0;
}

/////////////////////////////////////////////////////////////////////////////
// FUNCTION:
// PURPOSE: 主窗口WM_DESTROY消息处理
// ENTRY:
// EXITS:
// SUCCESS :
// FAILURE :
// OTHER:
/////////////////////////////////////////////////////////////////////////////
LRESULT MyApp::OnDestroy(WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
PostQuitMessage(0);
bHandled = 1;
0;
}

/////////////////////////////////////////////////////////////////////////////
// FUNCTION:
// PURPOSE: 主窗口WM_COMMAND消息处理
// ENTRY:
// EXITS:
// SUCCESS :
// FAILURE :
// OTHER:
/////////////////////////////////////////////////////////////////////////////
LRESULT MyApp::OnCommand(WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
switch(LOWORD(wParam))
{
10:
;
11:
DestroyWindow(GetWnd);
;
}



bHandled = 0;
0;
}

/////////////////////////////////////////////////////////////////////////////
// FUNCTION: void MyApp::AfterCreate
// PURPOSE: 运行前期准备
// ENTRY:
// EXITS:
// SUCCESS :
// FAILURE :
// OTHER:
/////////////////////////////////////////////////////////////////////////////
void MyApp::AfterCreate
{
MsgDestroy.SetMsgHandler(this,&MyApp::OnDestroy);
MsgCommand.SetMsgHandler(this,&MyApp::OnCommand);
RegMsgHandler(WM_DESTROY,&MsgDestroy);
RegMsgHandler(WM_COMMAND,&MsgCommand);
m_surface= BufferDesc(640,480);
InitFont;
DrawChar(\'家\');
}

/////////////////////////////////////////////////////////////////////////////
// FUNCTION: void MyApp::Idle
// PURPOSE: 循环工作
// ENTRY:
// EXITS:
// SUCCESS :
// FAILURE :
// OTHER:
/////////////////////////////////////////////////////////////////////////////
GDIbmpinfo16[13]={(BITMAPINFOHEADER),0,0,0x100001,BI_BITFIELDS,0,0,0,0,0,0xf800,0x7e0,0x1f};
/////////////////////////////////////////////////////////////////////////////
void MyApp::Idle
{
HDC myhdc=GetDC(GetWnd);
(!myhdc)
;
GDIbmpinfo16[1]=m_surface->pitch>>1,GDIbmpinfo16[2]=-m_surface->h;
SetDIBitsToDevice(myhdc,0,0,m_surface->w,m_surface->h,0,0,0,m_surface->h,m_surface->data,(BITMAPINFO*)&(GDIbmpinfo16[0]),0);
ReleaseDC(GetWnd,myhdc);
}

/////////////////////////////////////////////////////////////////////////////
// FUNCTION: void MyApp::BeforeExit
// PURPOSE: 退出前期准备
// ENTRY:
// EXITS:
// SUCCESS :
// FAILURE :
// OTHER:
/////////////////////////////////////////////////////////////////////////////
void MyApp::BeforeExit
{
DestroyFont;
delete m_surface;
}

/////////////////////////////////////////////////////////////////////////////
void MyApp::InitFont
{
GDIbmpinfo16[1]=FONTPOINT,GDIbmpinfo16[2]=-FONTPOINT;
HDC myhdc=GetDC(GetWnd);
(!myhdc)
;
m_FontBMP = CreateDIBSection(myhdc,(BITMAPINFO*)&(GDIbmpinfo16[0]),DIB_RGB_COLORS,(void**)&m_FontMap,0,0);
ReleaseDC(GetWnd,myhdc);
for( i=0;im_FontMap=0x1f;
m_FontDC=CreateCompatibleDC(NULL);
SelectObject(m_FontDC,m_FontBMP);
m_Font=CreateFont( FONTPOINT,0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,DEFAULT_QUALITY,\"宋体\");
SelectObject(m_FontDC,m_Font);
}

/////////////////////////////////////////////////////////////////////////////
void MyApp::DestroyFont
{
DeleteDC(m_FontDC);
DeleteObject(m_FontBMP);
DeleteObject(m_Font);
}

/////////////////////////////////////////////////////////////////////////////
RECT rect={0,0,FONTPOINT,FONTPOINT};
///////////////////////////////////////////////////////////////////////////////
void MyApp::DrawChar(unsigned c)
{
char str[3]={(c&0xff00)>>8,c&0xff,0};
(c<0x80)
{
str[0]=str[1];
str[1]=0;
}

DrawText(m_FontDC,str,1,&rect,DT_CENTER);
i=0,j=0;
ofstream myoutput(\"test.txt\");
(!myoutput.is_open)
;

for(i=0;i{
for(j=0;j(m_FontMap[i*FONTPOINT+j]0)
myoutput<<\"*\";
myoutput<<\" \";
myoutput<}
myoutput.close;
}
/////////////////////////////////////////////////////////////////////////////


Tags:  2424点阵字库 点阵字库 16点阵字库 中文点阵字库

延伸阅读

最新评论

发表评论