Search This Blog

Showing posts with label java byte array to image. Show all posts
Showing posts with label java byte array to image. Show all posts

Monday, January 7, 2013

Convert image to byte array and byte array to image file


This code will convert an image file to byte array and will write it into a binary file, and will read the binary file and converti it to image file.



import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.BufferedInputStream;
import javax.imageio.ImageIO;


public class conveter {

 /**
  * @param args
  */
 public static void main(String[] args) {
  try {
    
   byte[] imageInByte;
   BufferedImage originalImage = ImageIO.read(new File(
     "Chrysanthemum.jpg"));
 

Featured Posts

Unlock Hidden Windows Startup and Shutdown Details : How to Enable Verbose Startup and Shutdown Messages in Windows 11

WINDOWS TROUBLESHOOTING · FULL GUIDE Unlock Hidden Windows Startup and Shutdown Details Enable Verbose Status...