T
T
TotTip2020-06-18 13:47:11
Delphi
TotTip, 2020-06-18 13:47:11

How to draw a translucent rectangle in paintbox?

Hello!
How to draw a translucent rectangle in paintbox?
I tried to experiment with Canvas.Pen.Mode, but this is not quite the effect that I need - the rectangle turns out to be too bright (screen attached).
As I understand it, just with Canvas.Rectangle this will not work (correct if wrong).
So far, the following solution has come to mind: when drawing a rectangle, place it on a bitmap, change the transparency of the bitmap and then draw this bitmap on the paintbox.
For transparency, I came across such a thing https://sourceforge.net/projects/tfastdib/ (are there any other options?)

The problem is that I don't know how to implement this in delphi - I don't understand how to implement the moment with placing the drawn rectangle in the bitmap and then transferring this bitmap to the same place on the paintbox.

In general, the essence of this rectangle is a kind of text
highlighter In the image, a picture is loaded and a paintbox is placed on top of it, the user can draw rectangles - select some areas ()

screen

5eeb45a3e56c7203575619.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
Hemul GM, 2020-06-18
@TotTip

Through the standard Canvas it is impossible (or so crutch) to draw a translucent object. To do this, you can use (in the standard VCL) GDI + or in new versions of Delphi - TDirect2DCanvas
Drawing with Canvas is generally a bad idea. Minimum performance.
You can immediately start learning FMX (FireMonkey framework). It is cross-platform and all the graphics in it are drawn through the video card. So quickly, by default there is anti-aliasing and so on.
And PaintBox can be found as an example and see everything there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question