int char_to_bmp_sdl(void)
{
TTF_Font *font;
SDL_Surface *text;
/* Initialize the TTF library */
if ( TTF_Init() < 0 ) {
fprintf(stderr, "Couldn't initialize TTF: %s\n",SDL_GetError());
SDL_Quit();
return(2);
}
font = TTF_OpenFont("cu.ttf", 48);
if ( font == NULL ) {
fprintf(stderr, "Couldn't open TTF: %s\n",SDL_GetError());
return -1;
}
// TTF_SetFontStyle(font, 0);
// TTF_SetFontOutline(font, 0);
// TTF_SetFontKerning(font, 1);
// TTF_SetFontHinting(font, 0);
//SDL_Color forecol= { 0xFF, 0xFF, 0xFF, 0 };
SDL_Color forecol= { 0x00, 0x00, 0x00, 0 };
char *string = "Mon Oct 28 10:33:23 CST 2013";
text = TTF_RenderUTF8_Solid(font, string, forecol);
SDL_PixelFormat *fmt;
fmt = (SDL_PixelFormat*)malloc(sizeof(SDL_PixelFormat));
memset(fmt,0,sizeof(SDL_PixelFormat));
fmt->BitsPerPixel = 16;
fmt->BytesPerPixel = 2;
fmt->Rmask = 0xff000000;//0x00FF0000
fmt->Gmask = 0x0000ff00;//0x0000FF00
fmt->Bmask = 0x00ff00ff;//0x000000FF
fmt->Amask = 0;
printf("%s %d\n ",__FUNCTION__,__LINE__);
SDL_Surface *temp = SDL_ConvertSurface(text,fmt,0);
SDL_SaveBMP(temp, "sdl_osd.bmp");
SDL_FreeSurface(text);
SDL_FreeSurface(temp);
TTF_CloseFont(font);
TTF_Quit();
}