In message <[EMAIL PROTECTED]>
          Sven Neumann <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> [EMAIL PROTECTED] (Simon Willcocks) writes:
> 
> > I'm writing a program that needs to plot images on the screen and it works
> > fine for any image without a mask, but when I try one with a mask the
> > transparent pixels come out in strange colours (e.g. mauve, light green,
> > apparently different for each image).
> > 
> > The images, whether PNG or GIF display fine under Konquerer, but dfbshow
> > (from the C++ examples) has the same problem I do.
> > 
> > I can attach a 711 byte example GIF file to a future message (or mail
> > direct) if anyone wants it.
> 
> It would be more helpful if you could show us some example code that
> shows how you load and display the images. It would also help to let
> us know which version of DirectFB you are using.

Apologies!  The versions are:

DirectFB-0.9.20
DFB++-0.9.20

I thought my code was irrelevant since the example class DFBImage in
DFB++-0.9.20/examples/dfbimage.cpp had the same problem.  I could extract
the parts in question, but since they were based on the example code I think
it's better to discuss that.

dfbshow is built from the files dfbimage.cpp, dfbapp.cpp and dfbshow.cpp;
here are the relevant sections:

>From dfbimage.cpp, DFBImage::LoadImage:

     dfb = DirectFB::Create();
     provider = dfb->CreateImageProvider( filename.data() );
     provider->GetImageDescription( &m_desc );
     provider->GetSurfaceDescription( &desc );
     if (width)
          desc.width = width;
     if (height)
          desc.height = height;
     surface = dfb->CreateSurface( desc );

     provider->RenderTo( surface, NULL );

     m_flags = DSBLIT_NOFX;
     if (m_desc.caps & DICAPS_ALPHACHANNEL)
//*** This is *not* the case for my image
          DFB_ADD_BLITTING_FLAG( m_flags, DSBLIT_BLEND_ALPHACHANNEL );
     
     if (m_desc.caps & DICAPS_COLORKEY) {
//*** This flag *is* set and call made
          DFB_ADD_BLITTING_FLAG( m_flags, DSBLIT_SRC_COLORKEY );

          surface->SetSrcColorKey( m_desc.colorkey_r,
                                   m_desc.colorkey_g,
                                   m_desc.colorkey_b );
     }

// provider and dfb are subsequently Released.


>From dfbshow.cpp, DFBShow::Render (called by DFBApp::Run at startup and
followed by a Flip of the surface):

     surface->Clear();
     surface->Blit( m_image, NULL, x, y );

The surface parameter is m_primary, created in DFBApp as follows:

     m_dfb = DirectFB::Create();
     DFBSurfaceDescription dsc;
     dsc.flags = DSDESC_CAPS;
     dsc.caps  = DSCAPS_PRIMARY;
     DFB_ADD_SURFACE_CAPS( dsc.caps, DSCAPS_FLIPPING );
     m_primary = m_dfb->CreateSurface( dsc );

I hope this helps.

If anyone with dfbshow compiled/installed could try to display an image with
a simple mask and tell me if you can see through it or not, I'd appreciate
even that!

Regards,
Simon


-- 
Info: To unsubscribe send a mail to [EMAIL PROTECTED] with 
"unsubscribe directfb-users" as subject.

Reply via email to