Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

convert text file into binnary format bitmap using java

import java.awt.image.BufferedImage;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Test3 {
public static void main(String[] args) throws IOException {
  
 
int i =0;
int w = 320;
int h = 240;
int  imageData[] = new int[w * h];
  
FileInputStream file_input = new FileInputStream ("D:abc.bin");
DataInputStream data_in    = new DataInputStream (file_input );
  
while (true) {
  try {
  imageData[i++] = data_in.readInt ();
     
  }
  catch (EOFException eof) {
    System.out.println ("End of File");
    break;
  }
}
BufferedImage finalImage;
finalImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);//TYPE_INT_ARGB
finalImage.setRGB(0, 0, w, h, imageData, 0 ,w);
ImageIO.write(finalImage, "bmp", new File("D:abc.bmp"));
  
}
}
Source by coderanch.com #
 
PREVIOUS NEXT
Tagged: #convert #text #file #binnary #format #bitmap #java
ADD COMMENT
Topic
Name
2+6 =