I have a problem.
First I make surface with prelocated data(default videomode 640x480x16):
size = 64*64*2;
void *bmpdata = malloc(size);
bmpdata = memset (&bmpdata,0xFF,size);  //white square 64x64

Then I Create surface and blit:
out_desc.caps = DSCAPS_SYSTEMONLY;
out_desc.flags=(DFBSurfaceDescriptionFlags)(DSDESC_CAPS|DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT|DSDESC_PREALLOCATED);
out_desc.width = 64;
out_desc.height = 64;
out_desc.pixelformat = DSPF_RGB16;
out_desc.preallocated[0].data = (void*) bmpdata;
out_desc.preallocated[0].pitch = 64*2;
out_desc.preallocated[1].data = NULL; //What is it? Please answer.
out_desc.preallocated[1].pitch = 0;
DFBCHECK( dfb->CreateSurface( dfb, &out_desc, &out_surface ) )
DFBCHECK (primary->Blit(primary,out_surface,NULL,200,200));
DFBCHECK (primary->Flip (primary, NULL, 0));

And I see white square but top side of them is not line (set of random
points). Where is a error? (full source attached)

Also How can I bli surface with pixelformat DSPF_A1 to primary surface
with RGB16?

Please, answer.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <directfb.h>
#include <string.h>
static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static IDirectFBInputDevice    *keyboard;
static IDirectFBInputDevice    *mouse;
static IDirectFBEventBuffer    *input_buffer;

#define DFBCHECK(x...)                                         \
  {                                                            \
    DFBResult err = x;                                         \
                                                               \
    if (err != DFB_OK)                                         \
      {                                                        \
        fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
        DirectFBErrorFatal( #x, err );                         \
      }                                                        \
  }

int main (int argc, char **argv)
{
  size_t size;
  void* tdata;
  int pitch;
  IDirectFBSurface* out_surface;
  DFBSurfaceDescription out_desc;
  DFBSurfaceDescription dsc;

  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 )); //RESOLUTION 640x480x16
  DFBCHECK(dfb->GetInputDevice( dfb, DIDID_KEYBOARD, &keyboard ));
  DFBCHECK(dfb->GetInputDevice( dfb, DIDID_MOUSE, &mouse )); //FIX: Mouse not found error.
  DFBCHECK(dfb->CreateInputEventBuffer (dfb, DICAPS_ALL, DFB_TRUE, &input_buffer));
  
//   DFBCHECK (primary->SetColor(primary,0xcf,0x1d,0x8a,0xff));
//   DFBCHECK (primary->FillRectangle (primary, 200, 232, 30,64));
  size = 64*64*2;
  void *bmpdata1 = malloc(size);
  void *bmpdata = malloc(size);
  bmpdata = memset (&bmpdata1,0xFF,size);

  out_desc.caps = DSCAPS_SYSTEMONLY; 
  out_desc.flags=(DFBSurfaceDescriptionFlags)(DSDESC_CAPS|DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT|DSDESC_PREALLOCATED);
  out_desc.width = 64;
  out_desc.height = 64;
  out_desc.pixelformat = DSPF_RGB16;
  out_desc.preallocated[0].data = (void*) bmpdata;
  out_desc.preallocated[0].pitch = 64*2;
  out_desc.preallocated[1].data = NULL;
  out_desc.preallocated[1].pitch = 0;
//   DFBCHECK (primary->Lock (primary, DSLF_READ|DSLF_WRITE, &tdata, &pitch));
  DFBCHECK( dfb->CreateSurface( dfb, &out_desc, &out_surface ) );
  fprintf(stderr, "WARNING: Next bliting don't work. Why?\n");
  DFBCHECK (primary->Blit(primary,out_surface,NULL,200,200));
  //DFBCHECK (primary->Flip (primary, NULL, 0));
//   DFBCHECK (primary->Unlock (primary) );
  //sleep(5);
  //DFBCHECK (primary->SetDrawingFlags(primary,DSDRAW_DST_COLORKEY));
  //DFBCHECK (primary->SetPorterDuff(primary,DSPD_XOR));
//   DFBCHECK (primary->SetColor(primary,0xcf,0x1d,0x8a,0xff));
//   DFBCHECK (primary->FillRectangle (primary, 200, 232, 30,64));
  DFBCHECK (primary->Flip (primary, NULL, 0));
  sleep(5);
  primary->Release( primary );
  input_buffer->Release(input_buffer);
  keyboard->Release( keyboard );
  mouse->Release( mouse );
  free(bmpdata);
  dfb->Release( dfb );
  return 23;
}
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to