Quoting Denis Oliver Kropp ([EMAIL PROTECTED]):
> Quoting Sarfraz Nawaz ([EMAIL PROTECTED]):
> > >
> > There's no method for drawing a single pixel, because developers shouldn't
> > use such a method. Drawing several pixels with one call for each pixel is
> > very much overhead. Instead you should lock the surface data via Lock() and
> > write all pixels yourself.
> > 
> > If you like you can use FillRectangle() with size 1x1. It has the same overhead
> > as a DrawPixel() method would have.
> > >
> > 
> > Can you explain the locking and writing pixels approach a bit further. I
> > would be writing around 400 pixels in one go and then blitting the surfaces.
> 
> You have to call Lock() and get a data pointer and the pitch (number of bytes
> to add to the data pointer to get to the next row).
> 
> Furthermore it depends on the pixel format how your pixels have to be written.
> 
> Example (not checked if it compiles):
> 
> DFBResult fill_surface( IDirectFBSurface *surface, __u8 r, __u8 g, __u8 b )
> {
>      DFBResult              ret;
>      void                  *data;
>      int                    pitch;
>      int                    x, y, width, height;
>      DFBSurfacePixelFormat  format;
> 
>      ret = surface->Lock( surface, DSLF_WRITE, &data, &pitch );
>      if (ret) {
>           DirectFBError( "IDirectFBSurface::Lock() failed", ret );
>           return ret;
>      }
> 
>      surface->GetSize( surface, &width, &height );
>      surface->GetPixelFormat( surface, &format );
> 
>      switch (format) {
>           case DSPF_RGB16:
>                for (y=0; y<height; y++) {
>                     __u16 *dst = data + y * pitch;
> 
>                     for (x=0; x<width; x++)
>                          dst[x] = PIXEL_RGB16( r, g, b );

You can copy these pixel macros from "DirectFB/src/gfx/convert.h".

-- 
Best regards,
  Denis Oliver Kropp

.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/                 |
"------------------------------------------"

                            Convergence GmbH


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

Reply via email to