]> hackdaworld.org Git - my-code/dfb-photoshow.git/commitdiff
left button for last image
authorhackbard <hackbard>
Thu, 27 Feb 2003 11:54:32 +0000 (11:54 +0000)
committerhackbard <hackbard>
Thu, 27 Feb 2003 11:54:32 +0000 (11:54 +0000)
event stuff fixed
scaling fixed!!

dfb-photoshow.c

index de27606d99b7f9e94c99c34df5453d3dd3982a51..c3da3659ecc57a677c7a90c47b73aa51dba71463 100644 (file)
@@ -39,7 +39,7 @@ IDirectFBEventBuffer *k_buf=NULL;
 char *title_txt="directfb photoshow";
 char *exp_txt="an image presenter ...";
 char *hp_txt="http://hackdaworld.dyndns.org";
-char *msg1_txt="(press key to continue, space pauses, esc quits ...)";
+char *msg1_txt="(press key to continue, space pauses, left key for last image, esc quits ...)";
 
 void clear_primary(void) {
  DFBCHECK(primary->SetColor(primary,0x00,0x00,0x00,0x00));
@@ -94,6 +94,7 @@ int main(int argc,char **argv) {
  i=2;
  while(i<argc) {
   do {
+   printf("image: %s\n",argv[i]);
    if((int)k_buf->GetEvent(k_buf,DFB_EVENT(&k_event))!=0) {
     if(k_event.type==DIET_KEYPRESS) {
      int a;
@@ -105,32 +106,39 @@ int main(int argc,char **argv) {
      if(a==(int)DIKI_SPACE) {
       char *pause_txt="paused (press button to continue)";
       DFBCHECK(font->GetStringWidth(font,pause_txt,-1,&str_width));
+      DFBCHECK(primary->SetColor(primary,0x80,0x80,0xff,0xff));
       DFBCHECK(primary->DrawString(primary,pause_txt,-1,(screen_width-str_width)/2,screen_height/2,DSTF_LEFT));
       DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
       DFBCHECK(k_buf->Reset(k_buf));
       DFBCHECK(k_buf->WaitForEvent(k_buf));
       k_event.key_id=DIKI_A; /* no longer pause! */
      }
+     if(a==(int)DIKI_LEFT) {
+      i=((i<=3)?2:i-2);
+      k_event.key_id=DIKI_A; /* no longer back key! */
+      break;
+     }
     }
    }
    DFBCHECK(dfb->CreateImageProvider(dfb,argv[i],&img_prov));
    DFBCHECK(img_prov->GetSurfaceDescription(img_prov,&dsc));
+   if((screen_width<dsc.width)||(screen_height<dsc.height)) {
+    float q_w=(float)(dsc.width)/screen_width;
+    float q_h=(float)(dsc.height)/screen_height;
+    if(q_w>=q_h) {
+     dsc.width=(int)(dsc.width/q_w);
+     dsc.height=(int)(dsc.height/q_w);
+    } else {
+     dsc.width=(int)(dsc.width/q_h);
+     dsc.height=(int)(dsc.height/q_h);
+    }
+   }
    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));
-   }
+   clear_primary();
+   DFBCHECK(primary->Blit(primary,logo,NULL,(screen_width-dsc.width)/2,(screen_height-dsc.height)/2));
    DFBCHECK(primary->Flip(primary,NULL,DSFLIP_WAITFORSYNC));
-   // sleep(atoi(argv[1]));
-   // DFBCHECK(k_buf->Reset(k_buf));
    DFBCHECK(k_buf->Reset(k_buf));
    k_buf->WaitForEventWithTimeout(k_buf,atoi(argv[1]),0);
    logo->Release(logo);