[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Freetype] Rendering Fonts to Bitmap
From: |
Dexter |
Subject: |
Re: [Freetype] Rendering Fonts to Bitmap |
Date: |
Mon, 2 Sep 2002 08:46:22 +0200 |
My Code
FT_Glyph glyph;
FT_BitmapGlyph glyph_bitmap;
FT_UInt glyph_index;
int pen_x = 0, pen_y = 0;
// -> Creates a generic bitmap
HDC dc = CreateCompatibleDC(NULL);
BITMAPINFO i;
ZeroMemory( &i.bmiHeader, sizeof(BITMAPINFOHEADER));
i.bmiHeader.biPlanes = 1;
i.bmiHeader.biBitCount = 1;
i.bmiHeader.biSizeImage = 0;
i.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
i.bmiHeader.biClrUsed = 0;
i.bmiHeader.biClrImportant = 0;
i.bmiHeader.biCompression = BI_RGB;
i.bmiHeader.biXPelsPerMeter = i.bmiHeader.biYPelsPerMeter = 2954;
char c = '4';
glyph_index = FT_Get_Char_Index(m_FaceArray[iIndex], (int)c);
m_fntError = FT_Load_Glyph(m_FaceArray[iIndex], glyph_index,
FT_LOAD_RENDER);
m_fntError = FT_Get_Glyph(m_FaceArray[iIndex]->glyph, &glyph);
// convert to a bitmap (default render mode + destroy old)
if(glyph->format != ft_glyph_format_bitmap)
{
m_fntError = FT_Glyph_To_Bitmap(&glyph, ft_render_mode_mono, 0, false);
}
// access bitmap content by typecasting
glyph_bitmap = (FT_BitmapGlyph)glyph;
i.bmiHeader.biWidth = glyph_bitmap->bitmap.width;
i.bmiHeader.biHeight = glyph_bitmap->bitmap.rows;
void *pvBits;
HBITMAP hbmp = CreateDIBSection(dc,&i,DIB_RGB_COLORS,&pvBits,NULL,0);
if(!hbmp)
{
m_fntError = FT_Err_Missing_Bbx_Field + 1;
return NULL;
}
for(int h = 0;h < 2;h++)
{
i.bmiColors[h].rgbBlue = h;
i.bmiColors[h].rgbGreen = 0;
i.bmiColors[h].rgbRed = 0;
}
SetDIBits(dc,hbmp,0,glyph_bitmap->bitmap.rows,&glyph_bitmap->bitmap.buffer,&
i,DIB_RGB_COLORS);
Well i guess i'm not doing what you say.. can you be more precise?
(some pseudo code would be apreaciated too!)
Thanks a lot!
> I lost your original post, so I can't check the code. However,
> another "fun" part of dealing with Windows bitmaps is that each scanline
> needs to be padded to the nearest multiple of 32 bits. So, if you have
> a 256 color bitmap (8 bits per pixel) that is 3 pixel wide, each
> scanline needs to be stored in scanline that is 4 pixels wide. Are you
> meeting this criteria?
>
> Thanks,
> PeterM
- [Freetype] Rendering Fonts to Bitmap, Dexter, 2002/09/01
- Re: [Freetype] Rendering Fonts to Bitmap, Peter Montgomery, 2002/09/01
- Re: [Freetype] Rendering Fonts to Bitmap, Dexter, 2002/09/01
- Re: [Freetype] Rendering Fonts to Bitmap, Peter Montgomery, 2002/09/02
- Re: [Freetype] Rendering Fonts to Bitmap,
Dexter <=
- Re: [Freetype] Rendering Fonts to Bitmap, Riccardo Cohen, 2002/09/02
- Re: [Freetype] Rendering Fonts to Bitmap, Dexter, 2002/09/02
- [Freetype] How do I render italic or bold if no file, Riccardo Cohen, 2002/09/04
- [Freetype] How do I render italic or bold if no file, Riccardo Cohen, 2002/09/09
- Re: [Freetype] How do I render italic or bold if no file, Dave Williss, 2002/09/19
- Re: [Freetype] How do I render italic or bold if no file, Riccardo Cohen, 2002/09/19
- Re: [Freetype] How do I render italic or bold if no file, James H. Cloos Jr., 2002/09/19
- Re: [Freetype] Rendering Fonts to Bitmap, Peter Montgomery, 2002/09/03
- Re: [Freetype] Rendering Fonts to Bitmap, Dexter, 2002/09/10