• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

BufferedImage to byte[]

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I convert from java.awt.image.BufferedImage to a byte[]?

Thanks.
[ June 18, 2006: Message edited by: Namitha karupaiya ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use javax.imageio.ImageIO to write it to a ByteArrayOutputStream
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the reply.

But I could not find a method which accept BufferedImage as a parameter and returnes a byte[].

I guess this has to be done by several steps which I could not do.

Any further help is very much appreciated.

Thanks.
[ June 19, 2006: Message edited by: Namitha karupaiya ]
 
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Several steps, yes. Joe already pointed out the first step:Now you have a ByteArrayOutputStream. I will leave it to you to design the second step, where you get a byte array from that.
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still confusing what a format name is in the write method:



What is that formatName? Please help me one step more.

Thanks.
 
Paul Clapham
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you read the documentation? What does it suggest to you? What have you tried so far?
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Namitha !

Have you got the solution now? I have many years experience in image processing software development. I am working for a well known company in the field. I can help you.

Waiting for your reply......

Take care. Bye for now......
 
Namitha karupaiya
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nesan Krish !!

Its pleasing to hear from you.

Could you please give a complete solution to my original question.

Thank you very much.
 
Paul Clapham
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Namitha, I just had a look through the API documentation and I found this static method in the ImageIO class:

public static String[] getWriterFormatNames()

Returns an array of Strings listing all of the informal format names understood by the current set of registered writers.

Since your question is what informal name you should be using, I would suggest that running this method and finding out what it returns might give you some useful information. In general I would suggest that you read the documentation and try things that you don't understand. Waiting for strangers to write your code for you is going to be a slow process and you shouldn't rely on it.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic