Skip to content

Commit

Permalink
add chinese string to image
Browse files Browse the repository at this point in the history
  • Loading branch information
licaibiao committed Mar 22, 2020
1 parent 0fb5f6f commit 5d6ccdf
Show file tree
Hide file tree
Showing 7 changed files with 1,710 additions and 1,602 deletions.
1,615 changes: 1,615 additions & 0 deletions freetype_SDL_Dl_ttf_debug/GBK_To_Unicode.c

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions freetype_SDL_Dl_ttf_debug/GBK_To_Unicode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/************************************************************
*Copyright (C),lcb0281at163.com lcb0281atgmail.com
*BlogAddr: caibiao-lee.blog.csdn.net
*FileName: GBK_To_Unicode.h
*Description:×ÖÌå¸ñʽת»»
*Date: 2020-02-03
*Author: Caibiao Lee
*Version: V1.0
*Others:
*History:
***********************************************************/
#ifndef _GBK_TO_UNICODE_H_
#define _GBK_TO_UNICODE_H_
#include <unistd.h>
#include <dirent.h>
#include <sys/file.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/msg.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <signal.h>

#include <sys/types.h>
#include <termios.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>

extern unsigned short zz_gbk2uni(unsigned char ch, unsigned char cl);
extern int enc_unicode_to_utf8_one(unsigned long unic, unsigned char *pOutput,
int outSize);
#endif

Binary file removed freetype_SDL_Dl_ttf_debug/bin/objs/debug_font_osd.o
Binary file not shown.
47 changes: 46 additions & 1 deletion freetype_SDL_Dl_ttf_debug/debug_font_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include <string.h>
#include "SDL/SDL.h"
#include "SDL/SDL_ttf.h"
#include "debug_font_osd.h"

#define CHINESET_STRING "阿标在学习中"

#define FONT_PATH "./font/hisi_osd.ttf"

Expand Down Expand Up @@ -73,10 +76,52 @@ int CreateTimeBmpPicture(void)
string_to_bmp(s8Contenx);
}

int CreateChinesePicture(void)
{
int i = 0;
char l_s32Len = 0;
char l_arrs8Str[64] = {0};
char l_arrs8UTFBuf[64] = {0};
char l_arrss8Contenx[64] = {0};
unsigned short usUnicode=0;

unsigned int usUtfLen=0;
unsigned int u32ContenxOffest=0;

snprintf(l_arrs8Str,sizeof(l_arrs8Str),"%s",CHINESET_STRING);

l_s32Len = strlen(l_arrs8Str);

printf(" len = %d \n",l_s32Len);

for(i=0;i<l_s32Len;)
{
usUnicode=zz_gbk2uni((unsigned char)l_arrs8Str[i++],(unsigned char)l_arrs8Str[i++]);
usUtfLen= enc_unicode_to_utf8_one(usUnicode,l_arrs8UTFBuf,64);
if(usUtfLen<0)
{
printf("%s %d out len error \n",__FUNCTION__,__LINE__);
break;
};

memcpy(&l_arrss8Contenx[u32ContenxOffest],l_arrs8UTFBuf,usUtfLen);

u32ContenxOffest+=usUtfLen;
}

string_to_bmp(l_arrss8Contenx);

return 0;

}


int main(void)
{
printf("hello world \n");
CreateTimeBmpPicture();
//CreateTimeBmpPicture();

CreateChinesePicture();
return 0;
}

Expand Down
1,613 changes: 12 additions & 1,601 deletions freetype_SDL_Dl_ttf_debug/debug_font_osd.h

Large diffs are not rendered by default.

Binary file modified freetype_SDL_Dl_ttf_debug/save.bmp
Binary file not shown.
Binary file modified freetype_SDL_Dl_ttf_debug/test
Binary file not shown.

0 comments on commit 5d6ccdf

Please sign in to comment.