|
From: | Sebastien Gamel |
Subject: | [ft-devel] i can't view correctly my bitmap |
Date: | Tue, 22 Jan 2008 10:48:41 +0100 |
HI I search how view my bitmap //========================================================================================================================= error =
FT_Init_FreeType(&ftlib);
if(error) { printf("FT_init error.\n"); exit(1); } fontname
= "\\storage card\\arial.ttf"; error
= FT_New_Face(ftlib, fontname, 0, &face); if(error == FT_Err_Unknown_File_Format) { printf("FT_face error.\n"); exit(1); } error
= FT_Set_Char_Size(face, 0, 20*64/*20pt*/, 72,
72); glyph_index
= FT_Get_Char_Index(face, keysym); /* retrieve
kerning distance
and move pen position */
error
= FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT); error
= FT_Get_Glyph(face->glyph, &glyph); // must
be manually destroyed with FT_Done_Glyph(glyph) if(error) { printf("Error loading glyph.\n"); exit(1); }
if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) if ( FT_Render_Glyph( face->glyph,
FT_RENDER_MODE_NORMAL ) ) exit(
1 );
// This fails if the character was a space: ascii 0x32 error
= FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1); // destroy old previous glyph
BitmapGlyph=
(FT_BitmapGlyph)glyph; MyPaint(hwnd,
message, wParam, lParam, &BitmapGlyph->bitmap); //========================================================================================================================= void MyPaint(HWND
hWnd, UINT message, WPARAM wParam, LPARAM lParam, FT_Bitmap *bitmap) { HDC hdc, hdcMemory; PAINTSTRUCT ps; HBITMAP hBmp, hOldBmp; BITMAP bmp; BITMAPINFO format; char *ptr,*ptr1; int
i, x, y, iCaptionHeight,ii; hdc = GetWindowDC(hWnd); hdcMemory =
CreateCompatibleDC( hdc ); format.bmiHeader.biSize=sizeof(BITMAPINFOHEADER); format.bmiHeader.biWidth=bitmap->width; format.bmiHeader.biHeight=bitmap->rows; format.bmiHeader.biPlanes=1; format.bmiHeader.biBitCount=8; format.bmiHeader.biCompression=BI_RGB; hBmp=CreateDIBSection(hdc,&format,DIB_RGB_COLORS,(void**)&ptr1,NULL,NULL); memcpy(ptr1,bitmap->buffer,(
format.bmiHeader.biWidth*(format.bmiHeader.biBitCount/8)
)*format.bmiHeader.biHeight); hOldBmp =
SelectObject( hdcMemory, hBmp ); GetObject( hBmp, sizeof(BITMAP), &bmp ); BitBlt(hdc, 50, 50, bmp.bmWidth,
bmp.bmHeight, hdcMemory, 0,
0, SRCCOPY ); DeleteObject(
SelectObject( hdcMemory, hOldBmp ) ); DeleteDC( hdcMemory ); ReleaseDC(hWnd,hdc); } //========================================================================================================================= I work on visual 2005 for WINCE if you can
help please Regards Seb |
[Prev in Thread] | Current Thread | [Next in Thread] |