Recent

Author Topic: [ solved ] drawn lines not persistent  (Read 1772 times)

Jumbo

  • New Member
  • *
  • Posts: 29
[ solved ] drawn lines not persistent
« on: September 29, 2023, 03:07:17 pm »
In the topic ; Image not shown after use scrollbar ; <link>https://forum.lazarus.freepascal.org/index.php/topic,64747.0.html<\link>
I encounter anoter issue.

On the image1.picture I drawn some lines, but they are wiped out when scrolling or when image2 is moved over them.

The image,picture is a loadfromfile( ... PNG ) file.  has it something to do with the image-type?
The semi mouspointer is also a PGN file.

Again, any idea or help is appreciated.
« Last Edit: September 30, 2023, 12:01:19 pm by Jumbo »

wp

  • Hero Member
  • *****
  • Posts: 11754
Re: drawn lines not persistent
« Reply #1 on: September 29, 2023, 03:17:59 pm »
When a user-drawing is wiped out, the most typical error is that the drawing was not made in an OnPaint event.

Jumbo

  • New Member
  • *
  • Posts: 29
Re: drawn lines not persistent
« Reply #2 on: September 29, 2023, 05:04:30 pm »
Thanks, That might be the issue.. I will try out.

Will respond to it soon tested.

Jumbo

  • New Member
  • *
  • Posts: 29
Re: drawn lines not persistent
« Reply #3 on: September 29, 2023, 07:27:31 pm »
Tried to put the draw line in the onpaint, but now only the last draw-action seems to win ?

Very strange how it works.

Maybe have a look in the project I upladed in my other post about the Missing image after scroll

wp

  • Hero Member
  • *****
  • Posts: 11754
Re: drawn lines not persistent
« Reply #4 on: September 29, 2023, 10:38:51 pm »
Last draw-action? Do you mean that you see only the last of the two drawn lines in Image1Paint? This should not occur (unless you have some issue with the coordinates in MyXY[]). Or do you mean that when you click several times you see only the cross for the last click operation? This is because you do not store the previous click positions.

I see an annoying flicker in your application. Did not investigate too deeply but my first guess would be that drawing an image over an image could cause this because this has a lot of overhead. Rather than using a TImage for the cursor I would load the cursor in a bitmap and draw the bitmap directly in the Image.Canvas.

In the attachment you find a simple application which does the drawing operations of your project, as far as I understood. It avoids using a second image component for the cursor and is much faster (at least for me - Win 11). Every click position is stored in an array. The array points are draw in the image. When a click occurs on an already existing point the point is deleted - just an addon... The main image is embedded in a scrollbox which handles the scrollbars.

Jumbo

  • New Member
  • *
  • Posts: 29
Re: drawn lines not persistent
« Reply #5 on: September 30, 2023, 12:00:30 pm »
Alright, thanks for the reaction. abf the example.

I did not know the lines had to be drawn repeatedly. But I have to put them in an array
and draw them at eery new point again. Clear enough. I will implement it.


 

TinyPortal © 2005-2018