From: hackbard Date: Tue, 25 Feb 2003 03:57:51 +0000 (+0000) Subject: started dfb-photoshow X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=339e646f49c5dae97f33a9abf366a1770db7dbb9;p=my-code%2Fdfb-photoshow.git started dfb-photoshow --- 339e646f49c5dae97f33a9abf366a1770db7dbb9 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ee8479e --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +# Makefile of dfb-photoshow + +INCLUDEDIR = /usr/include + +CFLAGS = -DDEBUG -O3 -Wall -I/usr/X11/include -I/usr/include/directfb +LIBS = -L/usr/X11/lib -L/usr/lib/directfb-0.9.15 -lX11 -lXext -ldirectfb + +OBJS = dfb-photoshow.o + +dfb-photoshow: $(OBJS) + $(CC) -o $@ $(OBJS) $(LIBS) +clean: + rm $(OBJS) diff --git a/TODO b/TODO new file mode 100644 index 0000000..13ccca4 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +TODO +---- + +- scale if image is bigger then screen +- implement search in c + diff --git a/dfb-photoshow.c b/dfb-photoshow.c new file mode 100644 index 0000000..68af401 --- /dev/null +++ b/dfb-photoshow.c @@ -0,0 +1,89 @@ +/* + * dfb-photoshow.c + * + * author: hackbard + * + */ + +#include +#include +#include + +IDirectFB *dfb = NULL; +IDirectFBSurface *primary = NULL; +int screen_width = 0; +int screen_height = 0; + +#define DFBCHECK(x...) \ +{ \ + DFBResult err=x; \ + if(err!=DFB_OK) { \ + fprintf(stderr,"file: %s , line: %d !\n\t",__FILE__,__LINE__); \ + DirectFBErrorFatal( #x, err ); \ + } \ +} + +IDirectFBSurface *logo = NULL; +IDirectFBFont *font = NULL; +char *text = "directfb photoshow (written by hackbard 2003)"; + +int main(int argc,char **argv) { + int i; + DFBSurfaceDescription dsc; + DFBFontDescription font_dsc; + IDirectFBImageProvider *img_prov; + + DFBCHECK(DirectFBInit (&argc, &argv)); + + DFBCHECK(DirectFBCreate(&dfb)); + DFBCHECK(dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN)); + + dsc.flags=DSDESC_CAPS; + dsc.caps=DSCAPS_PRIMARY|DSCAPS_FLIPPING; + DFBCHECK(dfb->CreateSurface(dfb,&dsc,&primary)); + + font_dsc.flags = DFDESC_HEIGHT; + font_dsc.height = 20; + DFBCHECK(dfb->CreateFont(dfb,"./decker.ttf",&font_dsc,&font)); + DFBCHECK(primary->SetFont(primary,font)); + + DFBCHECK(primary->GetSize(primary,&screen_width,&screen_height)); + fprintf(stdout,"dimensions: %dx%d\n",screen_width,screen_height); + + /* welcome */ + DFBCHECK(primary->SetColor(primary,0x00,0x00,0x00,0x00)); + DFBCHECK(primary->FillRectangle(primary,0,0,screen_width,screen_height)); + DFBCHECK(primary->SetColor(primary,0x80,0x80,0xff,0xff)); + DFBCHECK(primary->DrawString(primary,text,-1,5,screen_height/2,DSTF_LEFT)); + DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC)); + sleep(10); + font->Release(font); + + for(i=2;iCreateImageProvider(dfb,argv[i],&img_prov)); + DFBCHECK(img_prov->GetSurfaceDescription(img_prov,&dsc)); + DFBCHECK(dfb->CreateSurface(dfb,&dsc,&logo )); + DFBCHECK(img_prov->RenderTo(img_prov,logo,NULL)); + img_prov->Release(img_prov); + DFBCHECK (primary->SetColor(primary,0x00,0x00,0x00,0x00)); + DFBCHECK(primary->FillRectangle(primary,0,0,screen_width,screen_height)); + DFBCHECK(primary->SetColor(primary,0x80,0x80,0xff,0xff)); + DFBCHECK(primary->DrawLine(primary,0,0,screen_width-1,screen_height-1)); + if((screen_width>=dsc.width)&&(screen_height>=dsc.height)) { + DFBCHECK(primary->Blit(primary,logo,NULL,(screen_width-dsc.width)/2,(screen_height-dsc.height)/2)); + } + else { + DFBCHECK(primary->StretchBlit(primary,logo,NULL,NULL)); + } + DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC)); + sleep(atoi(argv[1])); + logo->Release(logo); + } + + primary->Release(logo); + primary->Release(primary); + dfb->Release(dfb); + + return 23; /* ;) */ +} +