Rank: Advanced Member
Groups: Guest
Joined: 4/26/2012(UTC) Posts: 36
Thanks: 6 times
|
Hi, I'm trying to save my (layered) canvas to an image and then use the resulting image as the source for an image elsewhere on my page (e.g. <img src="my_canvas_image.png" alt="some_text"/>. I have used the remote scripting method to save the canvas to an image like so: Code:Dim bmp As Aurigma.GraphicsMill.Bitmap = _canvasViewer.Canvas.RenderWorkspace(dpi, Aurigma.GraphicsMill.ColorSpace.Rgb)
bmp.Transforms.Resize(width, height)
bmp.Save("my_canvas_image.png", New Aurigma.GraphicsMill.Codecs.PngEncoderOptions(True))
however the javascript code $('#my_image')attr('src', 'my_canvas_image.png'); that I execute after the invokeRemoteMethod on the client executes before the image is generated so it never shows. To get around this timing issue I tried making an ajax call and passing in the serialized canvas data to a PageMethod and populating it with the serialized data, but I don't know if it's possible. I tried using various things based on the following approach but I kept getting errors. Is this possible? Code:<WebMethod()> _
Public Shared Function MyMethod(ByVal serializedData As String) As String
Dim fileName As String = "random_image_name.png"
Dim cv As New Aurigma.GraphicsMill.AjaxControls.CanvasViewer
cv...etc ' try to recreate canvas using serializedData
Dim bmp As Aurigma.GraphicsMill.Bitmap = cv.Canvas.RenderWorkspace....etc
return fileName ' use client side
End Function
Thanks Edited by user Thursday, September 6, 2012 7:15:04 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 5/29/2010(UTC) Posts: 1,310
Thanks: 8 times Was thanked: 111 time(s) in 111 post(s)
|
Hello Norman,
Unfortunately, there is no way to achieve it. Saving image takes some time. Therefore using remote script method is unsuitable in the case you described. I would like to recommend you to use post back. It will also allow to update an image you in the <img /> tag. |
Best regards, Dmitry Obukhov
Technical Support. Aurigma, Inc.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.