Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Getting Bitmap from Canvas and converting it into image file format

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am drawing some lines or any shapes in an applet. now i want to save that drawing or applet into an image like gif or jpeg. one funda is that we will click on one button on applet, it will contact a setvlet on the server and on the server i have to write some code.
I got reply from one of the javaranch member Tim Holloway as follows:
You'll need to convert the applet's canvas into a bitmap, convert the bitmap into JPEG or GIF format, then send the bitmap in a binary file transmission to the server. The server really can't do anything but catch the file - all the work has to be done on the client.
Can any one help me out in this regards.
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone posted this code a while back... it draws some text on a canvas and saves it as a JPEG image... it helped me understand what to do to generate an image file from an image...

It saves it as a JPEG because a JPEG encoder is shipped with the JDK by Sun... to save as a GIF file you'll either need to look at the Java Media Framework, or go with a 3rd party implementation...

Yeast devil! Back to the oven that baked you! And take this tiny ad too:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic