0 Replies Latest reply: Mar 5, 2010 5:34 AM by 843802 RSS

    Encoding and Storing an input file to a BMP file using JAI-error

    843802
      Hi

      I am trying to encode and store a given input file to a BMP file using the JAI libraries. But it gives an error in line(1) and (2) wher the encoding and storing is taking place. It says "BMP cannot be resolved".Here is the code:

      import java.io.*;
      import javax.media.jai.*;

      public class Test {
           
           static public BufferedReader console = new BufferedReader(
      new InputStreamReader(System.in));
           
           public static void main(String args[]){
                // Define the source and destination file names.
           String inputFile =null;
           String outputFile =null;

           //take inputFileName from command line
           try{
           inputFile = console.readLine();
           }
           catch(IOException e) {
           System.out.println(e);
           System.exit(1);
           }
           
           //take outputFileName from command line
           try{
           outputFile = console.readLine();
           }
           catch(IOException e) {
      System.out.println(e);
      System.exit(1);
                }
           

           // Load the input image.
           RenderedOp src = JAI.create("fileload", inputFile);

           // Encode the file as a BMP image.
           FileOutputStream stream = null;
                try {
                     stream = new FileOutputStream(outputFile);
                } catch (FileNotFoundException e) {
                     System.out.println("Cannot write the BMP File");
                     e.printStackTrace();
                }
           JAI.create("encode", src, stream, BMP, null); // (1)

           // Store the image in the BMP format.
           JAI.create("filestore", src, outputFile, BMP, null); // (2)


           }

      }
      Am I missing out on some library?
      Please help