Hi all,

              I have doubt in DSBLIT_SRC_COLORKEY. I have two surface called
as primary and secondary surface. While Blitting (copying the 

Secondary surface into primary), I need to copy pixel that doesn't match the
source color key. 

I have done like the below.

ret = primary->SetBlittingFlags(primary,DSBLIT_SRC_COLORKEY); 

ret = primary->SetSrcColorKey(primary,0xFF,0x00,0x00);      

primary->Blit(primary,secondary,&rect,50,100);

 

is any thing wrong with the code?  

 

Problem : If I set the source color key as black the functionality of
DSBLIT_SRC_COLORKEY is working fine, 

if I set any other color other than black for source color key , the
functionality of DSBLIT_SRC_COLORKEY is not working.

 

The full source code is below.

 

#include <directfb.h>

#include <time.h>

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <string.h>

 

static IDirectFB            *dfb     = NULL;

static IDirectFBSurface     *primary = NULL;

static IDirectFBSurface     *secondary = NULL;

static DFBRectangle rect;

 

int

main( int argc, char *argv[] )

{

 

     DFBResult             ret;

     DFBSurfaceDescription desc;

 

     /* Initialize DirectFB including command line parsing. */

     ret = DirectFBInit( &argc, &argv );

     if (ret) {

          DirectFBError( "DirectFBInit() failed", ret );

     }

 

     /* Create the super interface. */

     ret = DirectFBCreate( &dfb );

     if (ret) {

          DirectFBError( "DirectFBCreate() failed", ret );

     }

     

     desc.flags       = DSDESC_CAPS;

     desc.caps        = DSCAPS_PRIMARY | DSCAPS_DOUBLE;

     

     /* Create the primary surface. */

     ret = dfb->CreateSurface( dfb, &desc, &primary );

     if (ret) {

          DirectFBError( "IDirectFB::CreateSurface() failed", ret );


     }

 

       

     rect.x = 0;

     rect.y = 0;

     rect.w = 50;

     rect.h = 50;

     

     ret = primary->GetSubSurface(primary,&rect,&secondary);

     

      if (ret) {

          DirectFBError( "IDirectFB::CreateSurface() failed", ret );


     }

     

    

     primary->Clear( primary, 0xFF, 0x00, 0xFF, 0xFF );

     secondary->SetColor(secondary,0xFF,0x00,0x00,0x00);   

     secondary->FillRectangle(secondary,0,0,50,50);    

     secondary->Flip( secondary, NULL, 0 );      

                

     rect.x = 0;

     rect.y = 0;

     rect.w = 50;

     rect.h = 50;

     

    ret = primary->SetBlittingFlags(primary,DSBLIT_SRC_COLORKEY); 

    ret = primary->SetSrcColorKey(primary,0xFF,0x00,0x00);      

    primary->Blit(primary,secondary,&rect,50,100);

     

    primary->Flip( primary, NULL, 0 );

 

     sleep(100);

      

      /* Release the primary surface. */

     if (primary)

          primary->Release( primary );

 

     /* Release the super interface. */

     if (dfb)

          dfb->Release( dfb );

 

}

 

Thanks in advance,

Dharma.

_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users

Reply via email to