Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

creating a .BMP file using Byte array data  RSS feed

 
ramya ganta
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,

How to create a .bmp file using byte array data?
Iam using

ByteArryInputStream bais = new ByteArrayInputStream(bytedata);
ImageIO.Write(ImageIO.read(bais),"BMP",new File("TestImage.BMP"));

Then , TestImage.bmp is creating but it is not having any data in it.
so, Please help me.


ramya
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd start by making sure that the result of "ImageIO.read(bais)" is a working BufferedImage (meaning, that it can be displayed OK).

By the way, are there any exceptions?
 
ramya ganta
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

I didn't understand your question.
Iam not getting any exeption.
but, .bmp file is creating but with out image in it

please, give me a solution for
creating a .bmp file using byte array

ramya
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I meant is, you need to find out where your code is going wrong. You could start by making sure that what you're trying to store in the file (the BufferedImage returned by "ImageIO.read(bais)") is indeed a valid image. You can do that by displaying it in a GUI.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!