• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Image Processing In Java

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an Image in a
webserver and I am getting it through the InputStream of URLConnection.Once I
get the Image Object
I would like to convert that into it's byte representation so that I can send it
ahead.So do you
know of any such process by which I can accomplish the above task.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you've got an InputStream, you have direct access to the bytes of the image, using one of the various read() methods. So I'm not sure what you're really asking. If you want to "send it ahead" I think you want to create an OutputStream that goes to wherever you're sending the data, and then make a loop that reads from the InputStream and writes to the OutputStream. Perhaps if you clarify what you want we can help better.
Also, we ask users to register using a first and last name at JavaRanch. See here for more details.
 
author
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're passing the Image around within java objects you could simply cteate a basic sub-class of Image and have that sub-class implement serializable. Then you could use the Object Streams to pass the data. If you a refering to sending the Image to other apps (i.e. to a browser or ftp server for upload) you can use a java.awt.image.PixelGrabber to get the pixels and then convert them into bytes. This is a convient way to go if you've already got the image in memory and are not reading it in from a file. Just a couple of thoughts
Sean
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!