GWT Canvas resize ImageData and get Canvas.toDataUrl

413 views
Skip to first unread message

Musicman75

unread,
Jan 30, 2013, 1:50:44 AM1/30/13
to google-we...@googlegroups.com
Hello,

for 2 days now I'm trying to resize my Canas data to get a smaller value when calling Canvas.toDataUrl.

The szenario:

User draws to a Canvas (Sign something). The drawing Canvas is sized to the Window size.
Before transgering the data to the server I want to scale the Canvas to fit to a smaller size.

I think this is very simple, but at the moment I'm bainfucked :-).

The steps:

- Get Canvas data
- Resize/Scale Canvas data
- Get data by calling Canvas.toDataUrl
- Transfer to server as image/png;base64..... String

Thanks a lot for any answer.

Stephan

Musicman75

unread,
Jan 30, 2013, 2:03:51 AM1/30/13
to google-we...@googlegroups.com
By the way, I don't want to paint the resized image to the UI.
Only get the resized data to thranfer to the server.

Thad

unread,
Feb 6, 2013, 11:08:15 AM2/6/13
to google-we...@googlegroups.com
I put my canvas info and a description of what I've drawn into a serializable POJO and send it to the server. On the server I create a java.awt.image.BufferedImage and draw to its java.awt.Graphics2D. Now call ImageIO.write(BufferedImage, "png", OutputStream) to write the file.
Reply all
Reply to author
Forward
0 new messages