1 7 8 17 18 package com.sun.image.codec.jpeg; 19 20 import sun.awt.image.codec.JPEGImageDecoderImpl; 21 import sun.awt.image.codec.JPEGImageEncoderImpl; 22 import sun.awt.image.codec.JPEGParam; 23 import java.awt.image.BufferedImage ; 24 import java.awt.image.Raster ; 25 import java.awt.image.ColorModel ; 26 import java.io.InputStream ; 27 import java.io.OutputStream ; 28 29 44 public class JPEGCodec { 45 private JPEGCodec() { } 46 47 51 public static JPEGImageDecoder createJPEGDecoder(InputStream src) { 52 return new JPEGImageDecoderImpl(src); 53 } 54 55 59 public static JPEGImageDecoder createJPEGDecoder(InputStream src, 60 JPEGDecodeParam jdp) { 61 return new JPEGImageDecoderImpl(src, jdp); 62 } 63 64 68 public static JPEGImageEncoder createJPEGEncoder(OutputStream dest) { 69 return new JPEGImageEncoderImpl(dest); 70 } 71 75 public static JPEGImageEncoder createJPEGEncoder(OutputStream dest, 76 JPEGEncodeParam jep) { 77 return new JPEGImageEncoderImpl(dest, jep); 78 } 79 80 87 public static JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage bi) 88 { 89 int colorID = JPEGParam.getDefaultColorId(bi.getColorModel()); 90 return getDefaultJPEGEncodeParam(bi.getRaster(), colorID); 91 } 92 93 104 public static JPEGEncodeParam getDefaultJPEGEncodeParam(Raster ras, 105 int colorID) 106 { 107 JPEGParam ret = new JPEGParam(colorID, ras.getNumBands()); 108 ret.setWidth(ras.getWidth()); 109 ret.setHeight(ras.getHeight()); 110 111 return ret; 112 } 113 114 132 public static JPEGEncodeParam getDefaultJPEGEncodeParam(int numBands, 133 int colorID) 134 throws ImageFormatException 135 { 136 return new JPEGParam(colorID, numBands); 137 } 138 139 147 148 public static JPEGEncodeParam getDefaultJPEGEncodeParam(JPEGDecodeParam jdp) 149 throws ImageFormatException { 150 return new JPEGParam(jdp); 151 } 152 } 153 | Popular Tags |