freetype应用范例
来源:互联网 发布:淘宝白菜群怎么挣钱 编辑:程序博客网 时间:2024/04/29 06:47
//-------------------------------------------------------------------------------------void LoadTextBitmap(RGN_HANDLE Handle, BITMAP_S *pstBitmap, int size, unsigned short* incode, int len){FT_LibrarypFTLib =NULL;FT_Face pFTFace = NULL;FT_Glyphglyph;FT_UIntglyph_index;FT_Errorerror = 0;int i = 0;len /= 2;if (len < 1)return;error = FT_Init_FreeType(&pFTLib);if(error){return;}error = FT_New_Face(pFTLib, "./simsun.ttf", 0, &pFTFace);if(error){return;}if(0 !=FT_Set_Char_Size(pFTFace, 0, size<<6, 300, 300)){return;}FT_Bitmap *bitmap = malloc(sizeof(FT_Bitmap)*len);FT_BitmapGlyph bitmap_glyph;int totalSize = 0;int totalWidth = 0;for (i=0; i<len; i++){glyph_index =FT_Get_Char_Index(pFTFace, incode[i]);FT_Load_Glyph(pFTFace, glyph_index, FT_LOAD_DEFAULT);error =FT_Get_Glyph(pFTFace->glyph, &glyph);if (error){return;}FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 0);bitmap_glyph = (FT_BitmapGlyph)glyph;bitmap[i] = bitmap_glyph->bitmap;totalSize += bitmap[i].width * bitmap[i].rows;totalWidth += (bitmap[i].width);int w = bitmap[i].width;int h = bitmap[i].rows;int j,k;for (k=0; k<h; k++){ for (j=0; j<w; j++){if((bitmap[i].buffer[k * w + j]) == 0 ){printf("0");}else{printf("1");}}printf("\n");}}pstBitmap->pData = calloc(1, totalSize*2);if (NULL == pstBitmap->pData){return;}pstBitmap->enPixelFormat = PIXEL_FORMAT_RGB_1555;pstBitmap->u32Width = totalWidth;pstBitmap->u32Height = bitmap[0].rows;int j,k;unsigned short *pDst = pstBitmap->pData;char *pSrc;int h = bitmap[0].rows;int off_j = 0;for (k=0; k<h; k++){off_j=0;for (i=0; i<len; i++){int w = bitmap[i].width; for (j=0; j<w; j++){if((bitmap[i].buffer[k * w+ j]) == 0 ){printf("0");pDst[k*totalWidth+off_j+j] = 0;}else{pDst[k*totalWidth+off_j+j] = 0xEFFF;printf("1");}}off_j += w;}printf("\n");}free(pstBitmap->pData);free(bitmap);}
0 0
- freetype应用范例
- freetype渲染字体范例
- Freetype的基本应用
- FreeType基本应用(转)
- freetype
- freetype
- freetype
- FreeType
- FREETYPE
- freetype
- freetype
- JAXB应用范例
- CIFS应用范例
- addJavaScriptInterface应用范例
- 矢量文字渲染引擎FreeType快速入门,附字体文件解析范例
- C#正则表达式应用范例
- C#正则表达式应用范例
- Smarty程序应用范例:留言簿
- 控制台执行Junit
- poj1515Street Directions【无向图->有向图 链式前向星版tarjan求桥】
- LeetCode(200) Number of Islands
- 注入框架RoboGuice使用:(A brief example of what RoboGuice does)
- Objective-C加强-内存管理
- freetype应用范例
- Xcode编译过程中 的部分警告处理(后续更新)
- iOS动画效果和实现
- 关于两个表更新数据的问题(update)
- git cherry pick
- Redis和Memcache性能测试对比
- 第十周练习 1007 悼念512汶川大地震遇难同胞——老人是真饿了
- 在Linux 上,编写一个每秒接收 100万UDP数据包的程序究竟有多难?
- 基于HTML5的可预览多图片Ajax上传