Drawing on image control

derez

Expert
Licensed User
Longtime User
Erel
All the drawing commands like circle, line are limited to drawing on forms.
It will be useful to have them work on controls.
Thanks.
David
 
Last edited:

dennishea

Active Member
Licensed User
:) Erel, I know I understand what your saying but I'm not sure I understand how to implement it. Could you post a tiny example. Thanks in advance for your help.

:)
 

derez

Expert
Licensed User
Longtime User
drawing on control

Erel
I do it with the use of dzimage.dll :
I draw on another form and then copy the part I need to the image control.
I just thought it can save some time and code.

example:

north_arrow(15,37,-rtrack)
form6.Circle(15,37,12,Rgb(255,255,255),f)
form6.Polygon(alX,0,alY,0,4,cBlack,f)
compass.Image = img.CopyImage(form6.Image,3,25,25,25)
 

klaus

Expert
Licensed User
Longtime User
Hello Erel,
could the polygon function and the circle function, which exists for forms, also be added to the Drawer object so we have all the drawing functions in one object ?
Otherwise if I want to draw a filled ellipse I have to use the Drawer function and if I want to add a filled polygon I must do it on the form and then combine both images.

Best regards
Klaus
Switzerland
 

klaus

Expert
Licensed User
Longtime User
Thank's Erel
I know that the circle is a particular case of an ellipse.
But from the drawing point of view:
- the circle is defined by it's center coordinates and the radius
- the ellipse is defined by it's outer rectangle
So why not include both ?

Best regards
Klaus
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I see your point and will consider it.

Generally speaking in order to keep the language simple I prefer not to overload it with almost duplicated functions.
You can also achieve it with:
B4X:
Sub DrawCircle(drawerObject,x,y,r,color,fill)
    rect.New1(x-r,y-r,2*r,2*r)
    If fill Then
        brush.Color = color
        Control(drawerObject,Drawer).FillEllipse(brush.Value,rect.Value)
    Else
        pen.Color = color
        Control(drawerObject,Drawer).DrawEllipse(pen.Value,rect.Value)
    End If
    Control(drawerObject,Drawer).Refresh2(rect.Value)
End Sub

Calling this sub:
DrawCircle ("drawer1",100,100,30,cRed,True)
 

klaus

Expert
Licensed User
Longtime User
Hello Erel
I understand your point of view not to overload the laguage with duplicate functions. But on the other hand it's not that convenient to have several fuctions on different places and then need to play with bitmaps or other objects to put everything together. I have some trouble with this.

Best regards
Klaus
 
Top