Felipe thanks for the code, I guess this requires the source to be a TBitmap,
or something else with a Canvas property? I am actually working with a raw
memory buffer so that I can do fast scanline access. I was hoping there was
an X Windows or GTK call that could take a pointer to this memory in the way
that StretchDIBits does on Windows?
Thanks again,
Paul
On Tuesday 27 June 2006 1:27 am, Felipe Monteiro de Carvalho wrote:
> On 6/26/06, Paul Michell <[EMAIL PROTECTED]> wrote:
> > Does any one know of a Linux API call that performs the same function as
> > StretchDIBits on Windows? I am looking for a fast way of transferring a
> > memory buffer containing a 24bpp image to the screen. I would like to
> > avoid having to add additional dependencies beyond those required for a
> > standard LCL program, or having to transfer to some intermediate buffer
> > (such as a TBitmap) first.
>
> TtCanvas.StretchDraw works reasonably well. There are some issues,
> however. I will post some code from the virtual magnifying glass to
> show you how I did things differently on Windows and Unix to get both
> working well when performing stretch operation:
>
> {$IFDEF Win32}
> if vConfigurations.invertColors then
> begin
> DestCanvas.Brush.Color := clWhite;
> DestCanvas.FillRect(Bounds(ClientLeft, ClientTop, ClientWidth,
> ClientHeight));
> end;
>
> StretchBlt(DestCanvas.Handle, ClientLeft, ClientTop, ClientWidth,
> ClientHeight,
> bmpDisplay.Canvas.Handle, ScreenRect.Left, ScreenRect.Top,
> ScreenRect.Right - ScreenRect.Left, ScreenRect.Bottom -
> ScreenRect.Top, dwROP);
> {$ENDIF}
> {$IFDEF Unix}
> // Cleans the screen to solve a bug on some systems. Possibly a gtk bug
> DestCanvas.Brush.Color := clWhite;
> DestCanvas.FillRect(Bounds(ClientLeft, ClientTop, ClientWidth,
> ClientHeight));
>
> {*******************************************************************
> * Paints in two steps. First copies a rect from bmpDisplay, and
> then enlarges it
> * This is required on Gtk because StretchBlt only accepts SrcX = SrcY
> = 0 *******************************************************************}
>
> bmpEnlargedDisplay.Canvas.CopyRect(
> Bounds(0, 0, ScreenRect.Right - ScreenRect.Left,
> ScreenRect.Bottom - ScreenRect.Top),
> bmpDisplay.Canvas, ScreenRect);
>
> bmpEnlargedDisplay.Height := ScreenRect.Bottom - ScreenRect.Top;
> bmpEnlargedDisplay.Width := ScreenRect.Right - ScreenRect.Left;
>
> DestCanvas.StretchDraw(
> Bounds(ClientLeft, ClientTop, ClientWidth, ClientHeight),
> bmpEnlargedDisplay);
> {$ENDIF}
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives