Topic: DirectFB on imx21
Hi All,
I have been working on a IMX21 based board which has a LCD controller that
can display using 16bpp (5R,6G,5B).
I have written independent application using the frame buffer driver and
try to write the text with any color combination it's gives me correct.
Now i want to implement the same thing using "DirectFB".
I am facing a strange problem here. The colors are not correct and am finding strange glitches in font drawings.
If somebody has worked on it then please let me know the solution.
> Problem:
>
> I cannot draw a rectangle with correct color in directfb standalone
> application also.
>
> Please see to this......................................................
>
>
> Code:
> main()
{
int i,width;
/*
> * A structure describing font properties.
> */
> DFBFontDescription font_dsc;
> /*
> * (Locals)
> */
> DFBSurfaceDescription dsc;
> DFBSurfacePixelFormat PixelFormat;
> PixelFormat = DSPF_RGB16;
> /*
> * (Initialize)
> */
> DFBCHECK (DirectFBInit (&argc, &argv));
> DFBCHECK (DirectFBCreate (&dfb));
> DFBCHECK (dfb->SetCooperativeLevel (dfb, DFSCL_FULLSCREEN));
> dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT;
> dsc.caps = DSCAPS_PRIMARY | DSCAPS_FLIPPING;
> dsc.pixelformat = PixelFormat;
> DFBCHECK (dfb->CreateSurface( dfb, &dsc, &primary ));
> DFBCHECK (primary->GetSize (primary, &screen_width, &screen_height));
> /*
> * First we need to create a font interface by passing a filename
> * and a font description to specify the desired font size. DirectFB will
> * find (or not) a suitable font loader.
> */
> font_dsc.flags = DFDESC_HEIGHT |
> DFDESC_ATTRIBUTES|DSDESC_PIXELFORMAT;
> font_dsc.height = 40;
>
> font_dsc.attributes =0;//DFFA_NOCHARMAP;// 0;//antialias ? 0 :
> DFFA_MONOCHROME;
>
> DFBCHECK (dfb->CreateFont (dfb, "arial18.bdf", &font_dsc, &font));
> printf("\nCreateFont***********************\n");
> /*
> * Set the font to the surface we want to draw to.
> */
> DFBCHECK (primary->SetFont (primary, font));
> /* font_dsc.flags = DFDESC_ATTRIBUTES;
>
>
>
> font_dsc.attributes = antialias ? 0 : DFFA_MONOCHROME;*/
>
> /*
> * Determine the size of our string when drawn using the loaded font.
> * Since we are interested in the full string, we pass -1 as string
> length.
> */
> DFBCHECK (font->GetStringWidth (font, text, -1, &width));
> /*******************************************/
> DFBCHECK (primary->SetColor (primary, 0xFF, 0x00, 0x00,0xFF));
> DFBCHECK (primary->FillRectangle (primary, 0, 0, screen_width,
> screen_height));
> DFBCHECK (primary->SetColor (primary, 0x00, 0x00, 0x00, 0xF0));
> DFBCHECK (primary->DrawString (primary, text, -1,0 , screen_height / 2,
> DSTF_LEFT));
> DFBCHECK (primary->Flip (primary, NULL, DSFLIP_WAITFORSYNC));
>
> /*
> * Release the font.
> */
> font->Release (font);
> /*
> * (Release)
> */
> primary->Release (primary);
> dfb->Release (dfb);
> }
Thanks,
Sameer