在SDL中顯示GBK點陣漢字_第1頁
在SDL中顯示GBK點陣漢字_第2頁
在SDL中顯示GBK點陣漢字_第3頁
在SDL中顯示GBK點陣漢字_第4頁
在SDL中顯示GBK點陣漢字_第5頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、在SDL中顯示GBK點陣漢字    大家注意到?jīng)]有,RA2的中文版本使用的是GBK點陣字庫,這樣做有一個好處:不管玩家是用的簡體還是繁體都能識別顯示的文字。 GBK的意思大概是“國家標(biāo)準(zhǔn)漢字?jǐn)U展字符集”吧,記不清了。但它的確是個好東東,比GB2312、BIG5什么的強多了。因為它包括GB2312、GBK的所有字符而且還補充了很多字,另外,還包括日文、朝鮮文以及大量的符號字符。 我在UCDOS for win版本里面找到了GBK的點陣字庫(HZK12.GBK、HZK14.GBK、HZK16.GBK)。分析了一下,知道了結(jié)構(gòu)。這里是我寫的一個演示程序,程序編

2、譯需要有sdl庫。遵循“慣例”,按F4切換全屏/窗口狀態(tài),Esc退出。程序把標(biāo)準(zhǔn)輸出和標(biāo)準(zhǔn)錯誤重定向到"stdout.txt"和"stderr.txt"中。 #include time.h> #include stdio.h> #include stdlib.h> #include string.h>#include "SDL.h" #include "SDL_image.h" /- #define STDOUT_FILE "stdout.txt" #define STD

3、ERR_FILE "stderr.txt" SDL_Surface *screen; Uint32 fps; Uint32 AppStartTime = 0; Uint32 frame_count = 0; static Uint32 frames; SDL_Event event; SDL_Surface * SetMode( int Width, int Height, int BPP, int Flags ); SDL_Surface * LoadBMP( char * filename ); void MainLoops( int ( * EventFunc)( )

4、, void ( * DrawFunc )( ), int DelayTime ); void Blt( SDL_Surface * image, int x, int y ); void TileBlt( SDL_Surface * image, int x, int y ); void SetTransparentColor( SDL_Surface * sprite, int R, int G, int B ); void IoRedirect( ); void cleanup_output( ); void initfps(); /- Uint8 HZK12574560; Uint8

5、HZK16766080; bool HZ_Init(); bool HZ_TextOut( SDL_Surface * image, int x, int y, int width, int space, const char * str ); /- int ProcessEvent( ); void DrawFrame( ); SDL_Surface * bg, * font; int ix, iy, jx, jy; int Width = 640; int Height = 480; int bpp = 16; int ScreenMode = 0; int main() char Tim

6、eString256; time_t timer; struct tm *tblock; HZ_Init(); frames = 0; timer = time(NULL); tblock = localtime(&timer); strftime( TimeString, 256, "Time=%Z: %Y-%m-%d %a %H:%M:%S", tblock ); printf( "%sn", TimeString ); SetMode( Width, Height, bpp, SDL_SWSURFACE|ScreenMode ); SDL_

7、ShowCursor(0); SDL_WM_SetCaption( "demo", "demo" ); bg = IMG_Load( "2k_bg.jpg" ); ix=iy=0; jx=jy= Height>>1; srand( (Uint32)timer ); MainLoops( ProcessEvent, DrawFrame, 0 ); printf( "ScreenMode=%d*%d*%dnFPS=%u", Width, Height, bpp, fps ); return 0; int P

8、rocessEvent( ) Uint8 *keystate; keystate = SDL_GetKeyState( NULL ); if ( ( keystateSDLK_ESCAPE ) | ( keystateSDLK_q ) ) return 0; return 1; void DrawFrame( ) char tmp256; int step = 4; / sprintf( tmp, "TotalFrame=%u", frames ); TileBlt( bg, 0, 0 ); if ( rand( ) % 400 < 2 ) jx = rand( )

9、% ( Width - 10 ); jy = rand( ) % ( Height - 10 ); sprintf( tmp, "FPS=%d", fps ); HZ_TextOut( screen, 10, 300, 12, 0, "正面面板"); HZ_TextOut( screen, 10, 318, 12, 0, "電子對抗顯示" ); HZ_TextOut( screen, 10, 334, 12, 0, "陳青山" ); HZ_TextOut( screen , 10, 380, 12, 0, &quo

10、t;高度表 ");ix += step; iy += step; /- /- SDL_Surface * SetMode( int Width, int Height, int BPP, int Flags ) /* Initialize the SDL library */ if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) fprintf(stderr, "Couldn't initialize SDL: %sn", SDL_GetError( ) ); return NULL; /* Clean up on exit *

11、/ atexit(SDL_Quit); /* Initialize the display in a 640x480 8-bit palettized mode */ screen = SDL_SetVideoMode( Width, Height, BPP, Flags ); if ( screen = NULL ) fprintf( stderr, "Couldn't set %dx%dx%d video mode: %sn", Width, Height, BPP, SDL_GetError( ) ); return screen; /- void initfps( ) AppStartTime = SDL_GetTicks(); frame_count = 0; /- void MainLoops( int ( * EventFunc)( ), void ( * DrawFunc)( ), int DelayTime

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論