Jump to content
Ruslan

Draw objects on canvas and manipulate with them

Recommended Posts

Maybe a stupid question but not for me at the moment.

Need a way to draw rectangles on a canvas and then to make it possible to resize, move, delete or clone. That is needed to automate some process of segmentation objects (same kind of objects by rectangles with same aspect ratio) on a bunch of images (>100K).

For now I can draw rectagles on a TImage canvas wthout any questions. But can't figure out how to select that rectangle with mouse, resize it, scale it and move.

Or maybe should I look at shapes?

Share this post


Link to post

Yóu can draw like this.

But the Canvas is a raster-based area, which doesn't contain graphical objects.

So the only way would be to re-paint the objects, as you like.

Usually this is done via FrameBuffer bitmaps, where you can do the clearing and drawing, and then
paint the whole frame buffer to the canvas each frame (or when changed).

Edited by Rollo62
  • Like 1

Share this post


Link to post

I would not draw directly on the canvas. Use TShapes.

You may also want to have a look at this selection component that is part of FMX:

TSelection

 

  • Like 1

Share this post


Link to post

use TPath  and  change before drawing again or  use  TObjectList  and  always  draw the full objectlist , individual items are  rects .....

 

Share this post


Link to post

Instead of reinventing the wheel why not try one of the many existing solutions.

For example Graphics32 or Image32. Here's a shot of an old demo of the GR32_Objects unit:

image.thumb.png.377b8062d60d0a7cd3e6f8ab7b092f8e.png

and here's one of a similar Image32 demo:

image.png.f5a13f85ffb980a8ca53d8de7dbddd3c.png

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×