Friday, December 2, 2011

Java Clipboard Image Corrupted?

I try to create an applet which will capture the Image from the clipboard and POST it to my web server. However the code below doesn't work for me for some reason.
- Getting the TransferData from clipboard
- Cast it to BufferedImage
- Convert to byet array
- upload... 



Somehow the image I get at the server side is corrupted.
Run a (not so) few test and finally got it to work.





Additional steps is:
- Cast the TransferData into Image first.
- Convert Image into BufferedImage
- Then you will get the correct image at the server side.

If anyone bump into this problem, hope this post helps.
(I still don't know why it happened ...)

No comments: