Sign in Join

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

Mailing lists / lazarus / 2010-11

TPicture beginupdate or similar

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Leonardo M. Ramé

Hi again, I'm doing some transformations on a TImage using Canvas.CopyRect and don't want to show intermediate steps before the final one is done, I need to do something similar to TListView's Items.BeginUpdate - Items.EndUpdate.

What I have is a big image on background, and in the OnMouseMove event I copy the area surrounding the mouse to a temporal bitmap, then draw over the original image on that area. When the user moves the mouse again, before doing anithing, I paint the original area with the temporary bitmap to obtain the original image, then re-draw on the new area. This causes flickering, and I thing it can be avoided using something like BeginUpdate at the beginning of my method and EndUpdate at the end.

Any hint?.

Reply by email

Leonardo M. Ramé
to Leonardo M. Ramé
Leonardo M. Ram? wrote 19 lines
Hi again, I'm doing some transformations on a TImage using Canvas.CopyRect and don't want to show intermediate steps before the final one is done, I need to do something similar to TListView's Items.BeginUpdate - Items.EndUpdate. What I have is a big image on background, and in the OnMouseMove event I copy the area surrounding the mouse to a temporal bitmap, then draw over the original image on that area. When the user moves the mouse again, before doing anithing, I paint the original area with the temporary bitmap to obtain the original image, then re-draw on the new area. This causes flickering, and I thing it can be avoided using something like BeginUpdate at the beginning of my method and EndUpdate at the end. Any hint?. -- Leonardo M. Ram? http://leonardorame.blogspot.com

Sorry, done with a temporal bitmap.

Reply by email

Benito van der Zander
to Leonardo M. Ramé: Hi again, I'm doing some transformations on a TImage using Canvas.CopyRect and don't want…
Hi again, I'm doing some transformations on a TImage using Canvas.CopyRect

For changing pictures a TPaintBox is better

I need to do something similar to TListView's Items.BeginUpdate - Items.EndUpdate.

That doesn't exist for images, only temporary images and the doublebuffered property.

Show quoted text 6 lines
When the user moves the mouse again, before doing anithing, I paint the original area with the temporary bitmap to obtain the original image, then re-draw on the new area. This causes flickering, and I thing it can be avoided using something like BeginUpdate at the beginning of my method and EndUpdate at the end

Draw the area around new and old mouse position in an temporary image, and then draw the original image as well as the redrawing on that temporary image, and this temporary image on the visible control.
Then only one drawing changes the visible image and it can't flicker.

Benito

Reply by email

Leonardo M. Ramé
to Benito van der Zander
Benito van der Zander wrote 21 lines
> >Hi again, I'm doing some transformations on a TImage using >Canvas.CopyRect For changing pictures a TPaintBox is better >I need to do something similar to TListView's Items.BeginUpdate - Items.EndUpdate. That doesn't exist for images, only temporary images and the doublebuffered property. >When the user moves the mouse >again, before doing anithing, I paint the original area with the >temporary bitmap to obtain the original image, then re-draw on the new >area. This causes flickering, and I thing it can be avoided using >something like BeginUpdate at the beginning of my method and EndUpdate >at the end Draw the area around new and old mouse position in an temporary image, and then draw the original image as well as the redrawing on that temporary image, and this temporary image on the visible control. Then only one drawing changes the visible image and it can't flicker. Benito

Thanks Benito. I'm doing more or less what you say, but I can't get the desired results.

Could you take a look at the attached example?

Basically I'm doing this:

1) Define a TRect surrounding the mouse, a 40 by 40 pixels area
2) Define a TRect to contain the zoomed area, the same rect defined in (1) multiplied by a zoom factor.
3) Store the area defined in (2) into a temporary bitmap.
4) Using Canvas.CopyRect, I stretch the small rect (1) into (2) to get the zoom effect.
5) The next time the user moves the mouse, the program checks if theres's a temporary bitmap, then draw it in the same position captured in 3, and paint it into the image. I do this to restore the original image, then the steps 1 to 4 are repeated again.

The problem is, in steps 4 and 5, I do a Canvas.CopyRect on the original image, and when the user moves the mouse, the temporary image is shown just before the zoomed one, and I don't want the user note this flickering.

Leonardo M. Ram? http://leonardorame.blogspot.com -------------- next part -------------- A non-text attachment was scrubbed... Name: localzoom.tar.bz2 Type: application/octet-stream Size: 2838 bytes Desc: not available URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20101129/1c6e5c22/attachment-0001.obj>

Reply by email