• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to transfer a bufferedImage Object?

 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI, I have a BufferedImage in my client program.I want this to be sent to the server & converted into an ImageIcon only on the server.
code:
***************
public class SpyClient extends JFrame implements java.io.Serializable
{
--------
----
rob =new Robot();
Dimension d=Toolkit.getDefaultToolkit).getScreenSize();
System.out.println("dimension: "+d.toString());
bi=rob.createScreenCapture(new Rectangle(d));

soc2=new Socket("localhost",2000);
os=soc2.getOutputStream();
ObjectOutputStream ous=new ObjectOutputStream(os);
ous.writeObject(bi);
ous.flush();
os.close();
end of code:
***********
I receive an error that the object "java.awt.BufferedImage is not serializable".Is there any other way to do it?Please suggest me with some code as soon as possible.

Happy middling with java.
Netharam
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would either change it to an ImageIcon first and send that, or save the BufferedImage as a jpeg file or something and send that to the server.

-Nate
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote a program that captures a screen image, then sends that image to a server and then the server opens the image in an image viewer (I was just doing some testing). You would just have to change the part where I open the image, to convert the image to an imageIcon. If you want the code, tell me your E-mail address and I will send you the code.
 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nate I already tried using a jpeg file,but it is slower,moreover I don't want that image to be saved as file unless the users saves the image.So please reply with a code snippet of sending an ImageIcon instead of jpeg.
Hi Greg My e-mail ID can be viewed in my profile,anyway it is "netharam@yahoo.com".
Happy middling with java.
Netharam.
[ May 01, 2002: Message edited by: netharam ram ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's some really short examples of this...

The client...


And the server...


Even sending a ImageIcon takes a while... a whole screenshot is quite a bit of information...

-Nate
 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank U Nate,u'r code is very useful.I have a small doubt still.In this sample code u r saving the image to a JPEG file,but How to save it as a GIF file?Please reply this too.
Happy middling with java.
Netharam.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought I'd already answered that for you in this post?

-Nate
 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Nate I was a bit confused.Sorry again for this post.Nate,is there anyway of getting back the BufferedImage from an ImageIcon?
Happy middling with java.
Netharam.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a short code snippet from the Java Developers Almanac that shows how to convert an Image to a BufferedImage.



I got it from this page.

-Nate
 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u Nate.This code was very useful & the link too.
Happy middling with java.
Netharam.
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic