/* Initialize the display bitmap named `bit' */ static void Init_Display( void ) { grInitDevices(); bit.mode = gr_pixel_mode_gray; bit.width = width; bit.rows = height; bit.grays = 256; surface = grNewSurface( 0, &bit ); if ( !surface ) PanicZ( "could not allocate display surface\n" ); graph_init = 1; }
FTDemo_Display* FTDemo_Display_New( grPixelMode mode, int width, int height ) { FTDemo_Display* display; grSurface* surface; grBitmap bit; display = (FTDemo_Display *)malloc( sizeof ( FTDemo_Display ) ); if ( !display ) return NULL; if ( mode != gr_pixel_mode_gray && mode != gr_pixel_mode_rgb24 ) return NULL; grInitDevices(); bit.mode = mode; bit.width = width; bit.rows = height; bit.grays = 256; surface = grNewSurface( 0, &bit ); if ( !surface ) { free( display ); return NULL; } display->surface = surface; display->bitmap = &surface->bitmap; grSetGlyphGamma( 1.0 ); display->fore_color = grFindColor( display->bitmap, 0x00, 0x00, 0x00, 0xff ); display->back_color = grFindColor( display->bitmap, 0xff, 0xff, 0xff, 0xff ); display->warn_color = grFindColor( display->bitmap, 0xff, 0x00, 0x00, 0xff ); return display; }