Howdy,
        I have been trying to use directfb to display a sequential list of
640x480 jpegs.  However I can't get it to work.  The latest attempt has
involved hacking up some of the code from dfbsee.  However all I get is
a blue screen and no image.  I am using the aty128 driver, gcc, and the
2.4.22 kernel in a gentoo system.  The code I tried was:

#include <stdio.h>
#include <unistd.h>
#include <directfb.h>

#define IMAGEPATH "/home/hal9000/robot/robot/images/"

static char *(images[20]) = { "/home/hal9000/robot/robot/images/wail_014_fHV.jpg",
                             "/home/hal9000/robot/robot/images/wail_014_fV.jpg",
                             "/home/hal9000/robot/robot/images/wail_015.jpg",
                             "/home/hal9000/robot/robot/images/wail_015_fH.jpg",
                             "/home/hal9000/robot/robot/images/wail_015_fHV.jpg",
                             "/home/hal9000/robot/robot/images/wail_015_fV.jpg",
                             
"/home/hal9000/robot/robot/images/shit_grin_laugh_33_fHV.jpg",
                             "/home/hal9000/robot/robot/images/shitgrinlaugh2.jpg",
                             "/home/hal9000/robot/robot/images/rrrrr10.jpg",
                             "/home/hal9000/robot/robot/images/normal_laughing.jpg",
                             "/home/hal9000/robot/robot/images/normal_002_fV.jpg",
                             "/home/hal9000/robot/robot/images/mumbles10_fV.jpg",
                             "/home/hal9000/robot/robot/images/psst10.jpg",
                             "/home/hal9000/robot/robot/images/moan_28.jpg",
                             "/home/hal9000/robot/robot/images/moan19a_fH.jpg",
                             
"/home/hal9000/robot/robot/images/killer_look_119b_fV.jpg",
                             
"/home/hal9000/robot/robot/images/howling_laugh_039_fV.jpg",
                             "/home/hal9000/robot/robot/images/howlinglaugh21_fV.jpg",
                             "/home/hal9000/robot/robot/images/ghost_howl_050_fH.jpg",
                             "/home/hal9000/robot/robot/images/help10.jpg" };
IDirectFB *dfb = NULL;
IDirectFBSurface *primary;
                                 
#define DFBCHECK(x...)                                                  \
  {                                                                     \
        DFBResult err = x;                                              \
                                                                        \
        if (err != DFB_OK)                                              \
            {                                                           \
                fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ );  \
                DirectFBErrorFatal( #x, err );                          \
            }                                                           \
  }
  
int image_load(char *file, int *w, int *h, 
                    DFBImageCapabilities  *caps, IDirectFBSurface **surface)
{
        DFBSurfaceDescription   dsc;
        DFBImageDescription     image_dsc;
        IDirectFBImageProvider *provider;

        dfb->CreateImageProvider (dfb, file, &provider);
        provider->GetImageDescription (provider, &image_dsc);
        provider->GetSurfaceDescription (provider, &dsc);
        
        *w = dsc.width;
        *h = dsc.height;
        
        primary->GetPixelFormat (primary, &dsc.pixelformat);
        DFBCHECK (dfb->CreateSurface (dfb, &dsc, surface));
        provider->RenderTo(provider, *surface, NULL);
        sleep(1);
        provider->Release(provider);
        
        if (image_dsc.caps & DICAPS_COLORKEY)
        (*surface)->SetSrcColorKey (*surface, 
                                     image_dsc.colorkey_r,
                                     image_dsc.colorkey_g,
                                     image_dsc.colorkey_b);
        *caps = image_dsc.caps;
        
        return DFB_OK;
}       

int main (int argc, char **argv)
{
  int i;
  char str[1000];
  IDirectFBSurface *image = NULL;
  DFBImageCapabilities caps;
  DFBSurfaceDescription  dsc;

  DFBCHECK(DirectFBInit (&argc, &argv));
  DirectFBSetOption ("bg-none", NULL);
  DirectFBSetOption ("no-cursor", NULL);        
  
  DirectFBCreate (&dfb);
  dfb->GetCardCapabilities(dfb, &caps);
  dsc.flags = DSDESC_CAPS;
  dsc.caps = DSCAPS_PRIMARY;
  dfb->SetVideoMode(dfb, 640, 480, 16);
 
  DFBCHECK (dfb->CreateSurface (dfb, &dsc, &primary));
  /*primary->GetSize (primary, &screen_width, &screen_height);*/

  /*  Puts the interface into the specified cooperative level. */
  dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN);

  for(i = 0; i < 20; i++) {
        int w,h;
        image_load(images[i], &w, &h, &caps, &image);
        image->Release(image);
  }
  
  return 23;
}


Thanks for the time.
                                Fred

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to