tif to bmp (new to JAI)

  • Thread starter timothy ma and constance lee
  • Start date
T

timothy ma and constance lee

Sirs

I create a program:
package com.hsbc.cgd.hfe.central.common;

import com.sun.image.codec.jpeg.*;
import com.sun.media.jai.codecimpl.BMPImageEncoder;

import java.awt.*;
import java.awt.image.*;
import java.io.*;

import javax.media.jai.JAI;
import javax.media.jai.RenderedOp;

/**
* Thumbnail.java (requires Java 1.2+)
* Load an image, scale it down and save it as a JPEG file.
* @author Marco Schmidt
*/
public class Tiff2Bmp {
public static void main(String[] args){
// Define the source and destination file names.
String inputFile = "c:\\hfeutil\\jars\\1.tif";
String outputFile = "c:\\hfeutil\\jars\\1.bmp";

// 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) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JAI.create("encode", src, stream, "BMP", null);

// Store the image in the BMP format.
JAI.create("filestore", src, outputFile, "BMP", null);
}
}
However, it throws:
Exception in thread "main" java.lang.RuntimeException: - Unable to render
RenderedOp for this operation.

at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:827)

at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:867)

at javax.media.jai.RenderedOp.getSampleModel(RenderedOp.java:2233)

at com.sun.media.jai.codecimpl.BMPCodec.canEncodeImage(BMPCodec.java:51)

at
javax.media.jai.operator.EncodeDescriptor.validateArguments(EncodeDescriptor.java:164)

at javax.media.jai.JAI.createNS(JAI.java:1086)

at javax.media.jai.JAI.create(JAI.java:973)

at javax.media.jai.JAI.create(JAI.java:1668)

at com.hsbc.cgd.hfe.central.common.Tiff2Bmp.main(Tiff2Bmp.java:35)



Please Kindly help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top