• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Image Processing In Java

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
The City calls upon her steadfast protectors. Now for a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic