13 IDirectFB *dfb = NULL;
14 IDirectFBSurface *primary = NULL;
16 int screen_height = 0;
18 #define DFBCHECK(x...) \
22 fprintf(stderr,"file: %s , line: %d !\n\t",__FILE__,__LINE__); \
23 DirectFBErrorFatal( #x, err ); \
27 IDirectFBSurface *logo = NULL;
28 IDirectFBFont *font = NULL;
29 char *title_txt = "directfb photoshow";
30 char *author_txt="hackbard@hackdaworld.dyndns.org";
31 char *hp_txt="http://hackdaworld.dyndns.org";
32 char *msg1_txt="(press return to continue ...)";
34 void clear_primary(void) {
35 DFBCHECK(primary->SetColor(primary,0x00,0x00,0x00,0x00));
36 DFBCHECK(primary->FillRectangle(primary,0,0,screen_width,screen_height));
39 int main(int argc,char **argv) {
41 DFBSurfaceDescription dsc;
42 DFBFontDescription font_dsc;
43 IDirectFBImageProvider *img_prov;
45 DFBCHECK(DirectFBInit (&argc, &argv));
47 DFBCHECK(DirectFBCreate(&dfb));
48 DFBCHECK(dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN));
50 dsc.flags=DSDESC_CAPS;
51 dsc.caps=DSCAPS_PRIMARY|DSCAPS_FLIPPING;
52 DFBCHECK(dfb->CreateSurface(dfb,&dsc,&primary));
54 DFBCHECK(primary->GetSize(primary,&screen_width,&screen_height));
55 fprintf(stdout,"dimensions: %dx%d\n",screen_width,screen_height);
58 font_dsc.flags=DFDESC_HEIGHT;
59 font_dsc.height=screen_height/20;
60 DFBCHECK(dfb->CreateFont(dfb,"/usr/share/DFBSee/decker.ttf",&font_dsc,&font));
61 DFBCHECK(primary->SetFont(primary,font));
62 DFBCHECK(font->GetStringWidth(font,title_txt,-1,&str_width));
64 DFBCHECK(primary->SetColor(primary,0x80,0x80,0xff,0xff));
65 DFBCHECK(primary->DrawString(primary,title_txt,-1,(screen_width-str_width)/2,screen_height/4,DSTF_LEFT));
66 /* author,homepage,msg */
67 font_dsc.height=screen_height/40;
68 DFBCHECK(dfb->CreateFont(dfb,"/usr/share/DFBSee/decker.ttf",&font_dsc,&font));
69 DFBCHECK(primary->SetFont(primary,font));
70 DFBCHECK(font->GetStringWidth(font,author_txt,-1,&str_width));
71 DFBCHECK(primary->DrawString(primary,author_txt,-1,(screen_width-str_width)/2,screen_height/2,DSTF_LEFT));
72 DFBCHECK(font->GetStringWidth(font,hp_txt,-1,&str_width));
73 DFBCHECK(primary->DrawString(primary,hp_txt,-1,(screen_width-str_width)/2,(screen_height/2)+font_dsc.height,DSTF_LEFT));
74 DFBCHECK(font->GetStringWidth(font,msg1_txt,-1,&str_width));
75 DFBCHECK(primary->DrawString(primary,msg1_txt,-1,(screen_width-str_width)/2,(screen_height/2)+3*font_dsc.height,DSTF_LEFT));
76 DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
80 /* display pictures */
82 DFBCHECK(dfb->CreateImageProvider(dfb,argv[i],&img_prov));
83 DFBCHECK(img_prov->GetSurfaceDescription(img_prov,&dsc));
84 DFBCHECK(dfb->CreateSurface(dfb,&dsc,&logo ));
85 DFBCHECK(img_prov->RenderTo(img_prov,logo,NULL));
86 img_prov->Release(img_prov);
87 DFBCHECK (primary->SetColor(primary,0x00,0x00,0x00,0x00));
88 DFBCHECK(primary->FillRectangle(primary,0,0,screen_width,screen_height));
89 DFBCHECK(primary->SetColor(primary,0x80,0x80,0xff,0xff));
90 DFBCHECK(primary->DrawLine(primary,0,0,screen_width-1,screen_height-1));
91 if((screen_width>=dsc.width)&&(screen_height>=dsc.height)) {
92 DFBCHECK(primary->Blit(primary,logo,NULL,(screen_width-dsc.width)/2,(screen_height-dsc.height)/2));
95 DFBCHECK(primary->StretchBlit(primary,logo,NULL,NULL));
97 DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
102 primary->Release(logo);
103 primary->Release(primary);