Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2002-10

StretchBlt

8 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrew Johnson
Show quoted text 11 lines
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.

Show quoted text 14 lines
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.

Andrew

_________________________________________________________________ Get a speedy connection with MSN Broadband.� Join now! http://resourcecenter.msn.com/access/plans/freeactivation.asp

Reply by email

andrew johnson
to Andrew Johnson: On Tue, 29 Oct 2002 18:22:28 -0600 (CST) I am not certain I understand. Could you clarify?
"Jesus Reyes" wrote
By the way, TextRect has problems when TextStyle.Clipped=true I think because it does not restore the clip region.

I haven't done extensive testing but I just looked at the code, and before the clipping is set we back up the DC with SaveDC, and when we are done we restore it with RestoreDC so if there IS a problem it is not in DrawText.

Could you please elaborate on what the problem actually is?

Andrew

Reply by email

Jesus Reyes
to Andrew Johnson: On Tue, 29 Oct 2002 18:22:28 -0600 (CST) I am not certain I understand. Could you clarify?

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).

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 :).

I hope the text above results readable.

Regards.

Jesus Reyes A.

Earlier message 38 lines
----- Original Message ----- From: Andrew Johnson To: Sent: Tuesday, October 29, 2002 6:29 PM Subject: Re: [lazarus] StretchBlt > On Tue, 29 Oct 2002 18:22:28 -0600 (CST) > "Jesus Reyes" wrote : > > > >It Seems like StretchBlt doesn't take care of boundary > >clipping, . So Canvas.Draw doesn't clip bitmaps > >correctly. can be fixed? > > > > I am not certain I understand. Could you clarify? > > AFAIK Clipping works mostly correct in StretchBlt, and what doesn't work h as > partly to do with Flaws in the GTK 1.X code design. But if there is a true > design problem/bug in the LCL interface code itself, it should indeed be > fixed. > > Andrew > > _________________________________________________________________ > Unlimited Internet access for only $21.95/month. Try MSN! > http://resourcecenter.msn.com/access/plans/2monthsfree.asp > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________ Do You Yahoo!? La mejor conexi�n a internet y 25MB extra a tu correo por $100 al mes. http://net.yahoo.com.mx

Reply by email

Jesus Reyes

It Seems like StretchBlt doesn't take care of boundary clipping, . So Canvas.Draw doesn't clip bitmaps
correctly. can be fixed?

Jesus Reyes A.

_________________________________________________________ Do You Yahoo!?
La mejor conexi�n a internet y 25MB extra a tu correo por $100 al mes. http://net.yahoo.com.mx

Reply by email

Andrew Johnson
Show quoted text 5 lines
It Seems like StretchBlt doesn't take care of boundary clipping, . So Canvas.Draw doesn't clip bitmaps correctly. can be fixed?

I am not certain I understand. Could you clarify?

AFAIK Clipping works mostly correct in StretchBlt, and what doesn't work has partly to do with Flaws in the GTK 1.X code design. But if there is a true design problem/bug in the LCL interface code itself, it should indeed be fixed.

Andrew

_________________________________________________________________ Unlimited Internet access for only $21.95/month.� Try MSN! http://resourcecenter.msn.com/access/plans/2monthsfree.asp

Reply by email

andrew johnson
to Jesus Reyes: Ok, here is the code I'm working at, it is a grid in a very preeliminar state but I only…

Well... First you are doing things the absolute slowest way possible for the pixmaps.. gaah! it was like moving through muck.. anyway. after turning off the pixmaps I saw what you meant I think. However the problem is not one I am completely certain how to take care of.. since I can't find it! What you might do however with your code is use TextRect instead of TextOut.. and just turn off the clipping flag until its fixed in the LCL. I think that the problem must be in ExtSelectRgn somewhere but I am in the dark as to what or where.(yet..)

Andrew

Jesus Reyes wrote 55 lines
Ok, here is the code I'm working at, it is a grid in a very preeliminar state but I only want to show the TextRect problem, to see it do the following. 1). Select Cell col=2, row=1 ( Cell[2,1] ) 2). Press F2 3). Write "This is a long string of text" 4). Press ENTER -the text should span thru 2 more cells 5). Select Cell[3,1] 6). Press F2 and Write "HERE" an then ENTER The Text at Cell[2,1] Should be clipped, but it doesn't (at least in my box). Now, Toggle the checkbox to test a substitute of TextRect. (you should navigate on the grid so it gets refreshed). Jesus Reyes A. --- andrew johnson escribi�: > On Wed, 2002-10-30 at 01:13 > "Jesus Reyes" wrote: > > > By the way, TextRect has problems when > TextStyle.Clipped=true I think > > because it does not restore the clip region. > > I haven't done extensive testing but I just looked > at the code, and before > the clipping is set we back up the DC with SaveDC, > and when we are done we > restore it with RestoreDC so if there IS a problem > it is not in DrawText. > > Could you please elaborate on what the problem > actually is? > > Andrew > > _________________________________________________________________ > To unsubscribe: mail > with > "unsubscribe" as the Subject > archives at http://www.lazarus.freepascal.org/mailarchives _________________________________________________________ Do You Yahoo!? La mejor conexi�n a internet y 25MB extra a tu correo por $100 al mes. http://net.yahoo.com.mx
andrew johnson

Reply by email

Jesus Reyes
to andrew johnson: On Wed, 2002-10-30 at 01:13 I haven't done extensive testing but I just looked at the…

Ok, here is the code I'm working at, it is a grid in a very preeliminar state but I only want to show the TextRect problem, to see it do the following.

1). Select Cell col=2, row=1 ( Cell[2,1] )
2). Press F2
3). Write "This is a long string of text"
4). Press ENTER
-the text should span thru 2 more cells
5). Select Cell[3,1]
6). Press F2 and Write "HERE" an then ENTER

The Text at Cell[2,1] Should be clipped, but it
doesn't (at least in my box).

Now, Toggle the checkbox to test a substitute of
TextRect. (you should navigate on the grid so it gets refreshed).

Jesus Reyes A.

--- andrew johnson escribi�:

Show quoted text 20 lines
On Wed, 2002-10-30 at 01:13 "Jesus Reyes" wrote: > By the way, TextRect has problems when TextStyle.Clipped=true I think > because it does not restore the clip region. I haven't done extensive testing but I just looked at the code, and before the clipping is set we back up the DC with SaveDC, and when we are done we restore it with RestoreDC so if there IS a problem it is not in DrawText. Could you please elaborate on what the problem actually is? Andrew

_________________________________________________________________

To unsubscribe: mail with "unsubscribe" as the Subject archives at

http://www.lazarus.freepascal.org/mailarchives

_________________________________________________________ Do You Yahoo!?
La mejor conexi�n a internet y 25MB extra a tu correo por $100 al mes. http://net.yahoo.com.mx -------------- next part --------------
A non-text attachment was scrubbed...
Name: gz00000.gz
Type: application/octet-stream
Size: 31244 bytes
Desc: "lgrid.tar.gz"
Url : http://localhost/pipermail/lazarus/attachments/20021030/217d19a3/gz00000.obj

Reply by email

andrew johnson
to Jesus Reyes

Oh.. almost forgot, on the slowness of things.. One reason you are so slow is (apart from the Pixmap's) you are drawing everything regardless of if it is visible or not. I suggest you take a look at Tony's Grid, it is somewhat flawed for your purposes in that it is designed with a specific purpose in mind, whereas yours is quite a bit more generic, however how he handles drawing is much better then your way I think, and it might help speed up the process as his only draws those rows/columns which are in screen, and he shows how, to an extent, to handle fixed rows. You've got a great start though, and if you can get the TGrid's worked out too match Delphi's we may be able too use your grids in the LCL, which will be that much less that needs to be done. I was going to base a grid off of Tony's, but depending on yours, I may not have too as yours is already looking to be closer in concept to Delphi's TCustomGrid, or at least TStringGrid.

Andrew

andrew johnson wrote 74 lines
Well... First you are doing things the absolute slowest way possible for the pixmaps.. gaah! it was like moving through muck.. anyway. after turning off the pixmaps I saw what you meant I think. However the problem is not one I am completely certain how to take care of.. since I can't find it! What you might do however with your code is use TextRect instead of TextOut.. and just turn off the clipping flag until its fixed in the LCL. I think that the problem must be in ExtSelectRgn somewhere but I am in the dark as to what or where.(yet..) Andrew On Wed, 2002-10-30 at 20:48, Jesus Reyes wrote: > Ok, here is the code I'm working at, it is a grid in a > very preeliminar state but I only want to show the > TextRect problem, to see it do the following. > > 1). Select Cell col=2, row=1 ( Cell[2,1] ) > 2). Press F2 > 3). Write "This is a long string of text" > 4). Press ENTER > -the text should span thru 2 more cells > 5). Select Cell[3,1] > 6). Press F2 and Write "HERE" an then ENTER > > The Text at Cell[2,1] Should be clipped, but it > doesn't (at least in my box). > > Now, Toggle the checkbox to test a substitute of > TextRect. (you should navigate on the grid so it gets > refreshed). > > Jesus Reyes A. > > > > --- andrew johnson escribi�: > > On Wed, 2002-10-30 at 01:13 > > "Jesus Reyes" wrote: > > > > > By the way, TextRect has problems when > > TextStyle.Clipped=true I think > > > because it does not restore the clip region. > > > > I haven't done extensive testing but I just looked > > at the code, and before > > the clipping is set we back up the DC with SaveDC, > > and when we are done we > > restore it with RestoreDC so if there IS a problem > > it is not in DrawText. > > > > Could you please elaborate on what the problem > > actually is? > > > > Andrew > > > > > _________________________________________________________________ > > To unsubscribe: mail > > with > > "unsubscribe" as the Subject > > archives at > http://www.lazarus.freepascal.org/mailarchives > > > _________________________________________________________ > Do You Yahoo!? > La mejor conexi�n a internet y 25MB extra a tu correo por $100 al mes. http://net.yahoo.com.mx -- andrew johnson _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
andrew johnson

Reply by email