Drawing on image control

Discussion in 'Basic4ppc Wishlist' started by derez, Jan 15, 2008.

  1. derez

    derez Expert Licensed 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: Jan 15, 2008
  2. Erel

    Erel Administrator Staff Member Licensed User

    You could draw on image controls (and ImageButtons) with the ImageLib library.
    Draw on a bitmap and set the bitmap to be the control's image.
     
  3. dennishea

    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.

    :)
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Example is attached.
     

    Attached Files:

  5. dennishea

    dennishea Active Member Licensed User

    Many Thanks Erel

    :) :sign0188: :)
     
  6. derez

    derez Expert Licensed 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)
     
  7. klaus

    klaus Expert Licensed 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
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    FillEllipse / DrawEllipse are suitable for circles too (when the rectangle is also a square).
    Polygon will be added to the drawer functionality.
     
  9. klaus

    klaus Expert Licensed 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
     
  10. Erel

    Erel Administrator Staff Member Licensed 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:
    Code:
    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)
     
  11. klaus

    klaus Expert Licensed 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
     
Loading...