[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

WebDrawingArea to Image


Hello,


I would like to create an Image file from the drawing commands I use into a WebDrawingArea object, like we can do it for DrawingArea object.
It is possible to do it like that ?

Public Sub Create_Image()

  Dim hImg As New Image(Paint.Width, Paint.Height, Color.White, Image.Standard)

  Htmldata = WebDrawingAreaCourbe.ToHTML()

  Paint.Begin(hImg)
  Paint.Scale(1, 1)

    'Exemple of code to draw
    Paint.LineWidth = 1

    Paint.Rectangle(50, 50, 150, 150)
    Paint.Stroke(Color.Red, True)
    Paint.Fill(Color.SetAlpha(Color.SoftBlue, 192))

    Paint.Rectangle(80, 80, 150, 150)
    Paint.Stroke(Color.SetAlpha(Color.Yellow, 64))

    Paint.Arc(100, 100, 60)
    Paint.Fill(Color.Red)
    Paint.Rectangle(20, 20, 120, 70)
    Paint.Fill(Color.SetAlpha(Color.Royal, 64))

    Paint.Ellipse(20, 20, 120, 70, 0, -Pi / 2)
    Paint.Stroke(Color.Green)

    Paint.Rectangle(40, 80, 120, 70)
    Paint.Brush = Paint.LinearGradient(80, 140, 100, 120, [Color.Red, Color.Green, Color.Violet], [0, 0.5, 1])
    Paint.Fill()

    Paint.Rectangle(60, 90, 120, 70)
    Paint.Brush = Paint.LinearGradient(220, 200, 340, 200, [Color.Red, Color.Green, Color.Violet], [0, 0.5, 1])
    Paint.Fill()

    Paint.Arc(100, 320, 40)
    Paint.Brush = Paint.RadialGradient(100, 320, 2, 100, 320, 40, ["red", "yellow", "lightblue"], [0, 0.6, 1])
    Paint.Fill()

  Paint.End()

  Try hImg.Save("/tmp/imagecourbe.png")
  If Error Then
    ModLogs.EcrireLogs("Error during image saving ! - Error: " & Error.Text)
  Endif

End

I know it's possible with Cairo library too, but through gb.gui.web component I not sure.

Any idea ?

Thank you

-- Olivier


Follow-Ups:
Re: WebDrawingArea to ImageOlivier Cruilles <olivier.cruilles@xxxxxxxx>
Re: WebDrawingArea to ImageBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>