Hi Denis,
I did as you suggested and to my suprise i am getting the pixelformat as
DSPF_RGB16,
I don't know why, i am using desktop PC, using Linux Framebuffer device,
So no how can i set the pixel format for DSPF_LUT8,
I am attaching the sample code that i modifed to bare minimum.
Please help me with this.
regards
animesh
On Thu, Mar 20, 2008 at 3:23 AM, Denis Oliver Kropp <[EMAIL PROTECTED]>
wrote:
> animesh wrote:
> > Hi,
> > My code is not working, it always crashes at the SetColorIndex giving
> > the following message
> >
> > (#) DirectFBError [primary->SetColorIndex(primary, 0)]: Not supported!
> >
> > Can anyone provide me with an working code or suggest any modification
> > in present code, so that SetColorIndex, can work.
> >
> > Basicaly i am trying to do this.
> > 1) Create on surface with Palette support.
> > 2) Set the palette to the surface.
> > 3) Then access a particular color in the Palette uing setcolorindex.
> > 4) Draw a rectangle using that color.
> >
> > Can anyone suggest where i am getting wrong.
>
> Your code looks fine. Can you add a primary->GetPixelFormat() and report
> back?
>
> --
> Best regards,
> Denis Oliver Kropp
>
> .------------------------------------------.
> | DirectFB - Hardware accelerated graphics |
> | http://www.directfb.org/ |
> "------------------------------------------"
>
--
Regards,
Animesh Bhadra,
+91-9880868571
#include <stdio.h>
#include <unistd.h>
#include <directfb.h>
static IDirectFB *dfb = NULL;
static IDirectFBSurface *primary = NULL;
static IDirectFBPalette *palette = NULL;
static int screen_width = 0;
static int screen_height = 0;
#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)
{
DFBColor colors[256];
DFBColor plt_colors[256];
unsigned int i = 0;
DFBSurfaceDescription dsc;
DFBSurfacePixelFormat dfbpixelformat;
/*Create the super interface*/
DFBCHECK (DirectFBInit (&argc, &argv));
DFBCHECK (DirectFBCreate (&dfb));
DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
/*Configure Palette*/
/* colors[0].a = 0xff;
colors[0].r = 0xFF;
colors[0].g = 0x00;
colors[0].b = 0x00;
colors[1].a = 0xFF;
colors[1].r = 0x00;
colors[1].g = 0xFF;
colors[1].b = 0x00;
colors[2].a = 0xFF;
colors[2].r = 0x00;
colors[2].g = 0x00;
colors[2].b = 0xFF;
*/
for (i = 0; i < 256; i++)
{
colors[i].a = 0xFF;
colors[i].r = 0x00;
colors[i].g = 0xFF;
colors[i].b = 0x00;
}
dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT | DSDESC_PALETTE;
dsc.caps = DSCAPS_PRIMARY;
dsc.pixelformat = DSPF_LUT8;
dsc.palette.size = 256;
dsc.palette.entries = colors;
DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
printf("CreateSurface \n");
DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
/* get access to the palette */
DFBCHECK(primary->GetPalette(primary, &palette ));
i = 0;
DFBCHECK(palette->GetSize(palette, &i ));
printf("palette size = %d\n", i);
DFBCHECK(palette->GetEntries(palette, plt_colors, i, 0 ));
printf("alpha = %x....Red = %x, Green = %x Blue = %x\n", plt_colors[0].a, plt_colors[0].r, plt_colors[0].g, plt_colors[0].b);
DFBCHECK(palette->SetEntries( palette, colors, 256, 0 ));
DFBCHECK(palette->GetEntries(palette, plt_colors, i, 0 ));
printf("alpha = %x....Red = %x, Green = %x Blue = %x\n", plt_colors[0].a, plt_colors[0].r, plt_colors[0].g, plt_colors[0].b);
printf("Screen Width = %d, Screen Height = %d\n",screen_width, screen_height );
DFBCHECK(primary->GetPixelFormat(primary, &dfbpixelformat));
switch (dfbpixelformat)
{
case DSPF_UNKNOWN:
printf("DSPF_UNKNOWN \n");
break;
case DSPF_ARGB1555:
printf("DSPF_ARGB1555 \n");
break;
case DSPF_RGB16:
printf("DSPF_RGB16 \n");
break;
case DSPF_RGB24:
printf("DSPF_RGB24 \n");
break;
case DSPF_RGB32:
printf("DSPF_RGB32 \n");
break;
case DSPF_ARGB:
printf("DSPF_ARGB \n");
break;
case DSPF_A8:
printf("DSPF_A8 \n");
break;
case DSPF_YUY2:
printf("DSPF_YUY2 \n");
break;
case DSPF_RGB332:
printf("DSPF_RGB332 \n");
break;
case DSPF_UYVY:
printf("DSPF_UYVY \n");
break;
case DSPF_I420:
printf("DSPF_I420 \n");
break;
case DSPF_YV12:
printf("DSPF_YV12 \n");
break;
case DSPF_LUT8:
printf("DSPF_LUT8 \n");
break;
default:
printf("pixel format not found \n");
}
DFBCHECK(primary->SetColorIndex(primary, 0));
DFBCHECK (primary->FillRectangle (primary, 200, 100, 100, 100));
printf("Rectangle With Blue Color\n");
DFBCHECK (primary->Flip (primary, NULL, 0));
sleep (4);
palette->Release(palette);
primary->Release( primary );
dfb->Release( dfb );
return 23;
}
_______________________________________________
directfb-users mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-users