[lazarus] StretchBlt

Andrew Johnson aj_genius at hotmail.com
Wed Oct 30 07:10:06 EST 2002

On Wed, 30 Oct 2002 00:13:32 -0600
"Jesus Reyes" <jesusrmx at yahoo.com.mx> wrote :
>I'm working in a TCustomControl descendent which is inserted in a
>Tscrollbox. As part of the paint event I draw some bitmaps (actually
>TPixmaps) on its canvas using Canvas.draw(....). This is an interactive
>control but due the paint events it feels too slow. I draw the entire
>control on each paint event because I believed that the lcl by means of the
>clip region did take care of unneeded parts and mostly it does (I mean
>Canvas.TextOut, Rectangle, FillRect which are what i tried works ok. By the
>way, TextRect has problems when TextStyle.Clipped=true  I think because it
>does not restore the clip region).

AFAIK TextRect Clipping works fine. Including the restoration of the Region, 
however I will look into it and see if something has been changed or lost in 
the code.

>To test the clip region misbehavior in the Paint event I get the current
>clip box using getClipBox and it is always the full extent of the control
>including invisible parts (I don't know if that is correct or it should be
>only the visible area). Then,  before any other thing I do an
>IntersectClipRect(canvas.handle, 0, 0, 50, 20) . After that I render my
>control normally. As result, tt apears as a perfect 50 by 20 rectangle
>correctly rendered surrounded by a gray background (do you know how to get
>rid of that?) except by the bitmaps wich are rendered out and crossing this
>clipped rectangle and lying over the control background.
>This is why i think that the problem is at the StretchBlt routine. Maybe
>Source or Dest Rects doesn't get correctly calculated or GTK is wrong or me

This is the problem I meant about GTK 1. I could not figure out how to have 
a Pixmap with an alpha channel use the clipping region. GTK has a clip box, 
a clip region, and a clip bitmap. ClipBitmaps are used by the alpha channel 
of any pixmap and it apears that GTK only allows ONE of the clipping's to be 
set, aka you can have a bitmap OR a clip region, not both. This means that 
for it to work properly any transparency Masks needs to be converted into a 
clipping region, and merged witht the existing region to get proper results. 
I could not figure out how to do this with relative speed, so for the moment 
I have ignored it. I have since considered, it may be possible to created a 
Bitmap of the size of the destination, and fill it with the clipping region 
applied, then blt the clipping mask onto it with the proper offset, and use 
this new clipping Bitmap as the mask instead. But I haven't tried, and I 
imagine than on most systems speeds of StretchBlt'ing/BitBlt'ing would 
decrease dramatically. If you have ideas on how to fix his let me know.. but 
otherwise you are probably out of luck, unless you want to draw to a buffer 
first. aka create a temporary Pixmap, draw to it instead, and then copyrect 
the area you wish. But this will make probably things slower.. not faster.


Get a speedy connection with MSN Broadband.  Join now! 

More information about the Lazarus mailing list