Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-27-2008, 04:53 AM
Member
 
Join Date: Apr 2008
Posts: 3
Smily is on a distinguished road
Convert Byte [] to BufferedImage
I was wondering if any can show me how to create a bufferedImage from a byte []. I saw an example on the forums here that converts a bufferedImage to a byte []. So I thought someone might know. Thanks


The following was the code I found
Code:
private byte[] image_byte_data(BufferedImage image) { WritableRaster raster = image.getRaster(); DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer(); return buffer.getData(); }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-28-2008, 12:41 PM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 286
roots is on a distinguished road
Java 2D - How to convert byte[] to BufferedImage
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-28-2008, 07:06 PM
Member
 
Join Date: Apr 2008
Posts: 3
Smily is on a distinguished road
Thanks for the response, however there is one particular part I'm stuck at. Is there a way to convert a byte [] to an bufferedimage without knowing the original height of the Image. For example, you take a bufferedimage convert it to byte [], then you store it into a database. Some point later you come back and just want to reconstruct the image using the byte array.

So my question would be, before I convert a bufferedimage to a byte [] should I also save the length and width of the image into the database so that I can reconstruct the image back up? The reason I'm asking this is because the images are all of different size.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-28-2008, 07:54 PM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 286
roots is on a distinguished road
"should I also save the length and width ?"
Yes. byte[] only gives the pixels.
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Byte Values javaplus New To Java 1 06-23-2008 02:08 AM
using Byte arrays mew New To Java 2 01-30-2008 05:54 AM
BufferedImage to Byte Java Tip Java Tips 0 01-22-2008 10:17 PM
int to byte ravian New To Java 1 01-13-2008 09:22 PM
Byte Streams JavaForums Java Blogs 0 12-26-2007 04:01 PM


All times are GMT +3. The time now is 12:00 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org