diff options
Diffstat (limited to 'awt/org/apache/harmony/x/imageio/plugins/jpeg')
7 files changed, 0 insertions, 886 deletions
diff --git a/awt/org/apache/harmony/x/imageio/plugins/jpeg/IISDecodingImageSource.java b/awt/org/apache/harmony/x/imageio/plugins/jpeg/IISDecodingImageSource.java deleted file mode 100644 index 051f906..0000000 --- a/awt/org/apache/harmony/x/imageio/plugins/jpeg/IISDecodingImageSource.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @author Rustem Rafikov - * @version $Revision: 1.2 $ - */ -package org.apache.harmony.x.imageio.plugins.jpeg; - -import javax.imageio.stream.ImageInputStream; - -import org.apache.harmony.awt.gl.image.DecodingImageSource; - -import java.io.InputStream; -import java.io.IOException; - -/** - * This allows usage of the java2d jpegdecoder with ImageInputStream in - * the JPEGImageReader. Temporary, only to make JPEGImageReader#read(..) - * working. - * - */ -public class IISDecodingImageSource extends DecodingImageSource { - - private final InputStream is; - - public IISDecodingImageSource(ImageInputStream iis) { - is = new IISToInputStreamWrapper(iis); - } - - @Override - protected boolean checkConnection() { - return true; - } - - @Override - protected InputStream getInputStream() { - return is; - } - - static class IISToInputStreamWrapper extends InputStream { - - private ImageInputStream input; - - public IISToInputStreamWrapper(ImageInputStream input) { - this.input=input; - } - - @Override - public int read() throws IOException { - return input.read(); - } - - @Override - public int read(byte[] b) throws IOException { - return input.read(b); - } - - @Override - public int read(byte[] b, int off, int len) throws IOException { - return input.read(b, off, len); - } - - @Override - public long skip(long n) throws IOException { - return input.skipBytes(n); - } - - @Override - public boolean markSupported() { - return true; // This is orig - - // ???AWT: FIXME - // This is an error in Harmony. Not all input streams - // have mark support and it is not ok to just return true. - // There should be an input.markSupported(). However, if - // this call returns false, nothing works anymore. - - // The backside is that BitmapFactory uses a call to markSupport() - // to find out if it needs to warp the stream in a - // BufferedInputStream to get mark support, and this fails! - - // Currently, the hack is in BitmapFactory, where we always - // wrap the stream in a BufferedInputStream. - } - - @Override - public void mark(int readlimit) { - input.mark(); - } - - @Override - public void reset() throws IOException { - input.reset(); - } - - @Override - public void close() throws IOException { - input.close(); - } - } -} diff --git a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGConsts.java b/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGConsts.java deleted file mode 100644 index 067a825..0000000 --- a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGConsts.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @author Rustem V. Rafikov - * @version $Revision: 1.2 $ - */ -package org.apache.harmony.x.imageio.plugins.jpeg; - -public class JPEGConsts { - - private JPEGConsts() {} - - public static final int SOI = 0xD8; - - //-- IJG (Independed JPEG Group) color spaces - public static final int JCS_UNKNOW = 0; - public static final int JCS_GRAYSCALE = 1; - public static final int JCS_RGB = 2; - public static final int JCS_YCbCr = 3; - public static final int JCS_CMYK = 4; - public static final int JCS_YCC = 5; - public static final int JCS_RGBA = 6; - public static final int JCS_YCbCrA = 7; - public static final int JCS_YCCA = 10; - public static final int JCS_YCCK = 11; - - public static int[][] BAND_OFFSETS = {{}, {0}, {0, 1}, {0, 1, 2}, {0, 1, 2, 3}}; - - public static final float DEFAULT_JPEG_COMPRESSION_QUALITY = 0.75f; -} diff --git a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java b/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java deleted file mode 100644 index 110ed23..0000000 --- a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReader.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @author Rustem V. Rafikov - * @version $Revision: 1.4 $ - */ -package org.apache.harmony.x.imageio.plugins.jpeg; - - -import javax.imageio.ImageReader; -import javax.imageio.ImageReadParam; -import javax.imageio.ImageTypeSpecifier; -import javax.imageio.plugins.jpeg.JPEGImageReadParam; -import javax.imageio.stream.ImageInputStream; -import javax.imageio.metadata.IIOMetadata; -import javax.imageio.spi.ImageReaderSpi; - -import org.apache.harmony.awt.gl.image.DecodingImageSource; -import org.apache.harmony.awt.gl.image.OffscreenImage; - -import java.io.IOException; -import java.util.Iterator; -import java.awt.image.BufferedImage; - -/** - * This implementation uses org.apache.harmony.awt.gl.image.JpegDecoder to read - * an image. The only implemented method is read(..); - * - * TODO: Implements generic decoder to be used by javad2 and imageio - * - * @see org.apache.harmony.awt.gl.image.JpegDecoder - * @see org.apache.harmony.x.imageio.plugins.jpeg.IISDecodingImageSource - */ -public class JPEGImageReader extends ImageReader { - - ImageInputStream iis; - - public JPEGImageReader(ImageReaderSpi imageReaderSpi) { - super(imageReaderSpi); - } - - @Override - public int getHeight(int i) throws IOException { - //-- TODO imlement - throw new UnsupportedOperationException("not implemented yet"); - } - - @Override - public int getWidth(int i) throws IOException { - //-- TODO imlement - throw new UnsupportedOperationException("not implemented yet"); - } - - @Override - public int getNumImages(boolean b) throws IOException { - //-- TODO imlement - throw new UnsupportedOperationException("not implemented yet"); - } - - @Override - public Iterator<ImageTypeSpecifier> getImageTypes(int i) throws IOException { - //-- TODO imlement - throw new UnsupportedOperationException("not implemented yet"); - } - - @Override - public IIOMetadata getStreamMetadata() throws IOException { - //-- TODO imlement - throw new UnsupportedOperationException("not implemented yet"); - } - - @Override - public IIOMetadata getImageMetadata(int i) throws IOException { - //-- TODO imlement - throw new UnsupportedOperationException("not implemented yet"); - } - - @Override - public BufferedImage read(int i, ImageReadParam imageReadParam) throws IOException { - if (iis == null) { - throw new IllegalArgumentException("input stream == null"); - } - - DecodingImageSource source = new IISDecodingImageSource(iis); - OffscreenImage image = new OffscreenImage(source); - source.addConsumer(image); - source.load(); - // The interrupted flag should be cleared because ImageDecoder interrupts - // current thread while decoding. The same technique is used in - // ImageLoader#run(). Another solution can be to create - // a separate decoding thread. However, decoder keeps its own pool - // of threads so creating a new thread will be just a waste of resources. - Thread.interrupted(); - return image.getBufferedImage(); - } - - @Override - public BufferedImage read(int i) throws IOException { - return read(i, null); - } - - @Override - public void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata) { - super.setInput(input, seekForwardOnly, ignoreMetadata); - iis = (ImageInputStream) input; - } - - @Override - public ImageReadParam getDefaultReadParam() { - return new JPEGImageReadParam(); - } -} diff --git a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReaderSpi.java b/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReaderSpi.java deleted file mode 100644 index c719ce7..0000000 --- a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageReaderSpi.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @author Rustem V. Rafikov - * @version $Revision: 1.3 $ - */ -package org.apache.harmony.x.imageio.plugins.jpeg; - -import java.io.IOException; -import java.util.Locale; -import javax.imageio.ImageReader; -import javax.imageio.spi.ImageReaderSpi; -import javax.imageio.spi.ServiceRegistry; -import javax.imageio.stream.ImageInputStream; - -public class JPEGImageReaderSpi extends ImageReaderSpi { - - public JPEGImageReaderSpi() { - super(JPEGSpiConsts.vendorName, JPEGSpiConsts.version, - JPEGSpiConsts.names, JPEGSpiConsts.suffixes, - JPEGSpiConsts.MIMETypes, JPEGSpiConsts.readerClassName, - STANDARD_INPUT_TYPE, JPEGSpiConsts.writerSpiNames, - JPEGSpiConsts.supportsStandardStreamMetadataFormat, - JPEGSpiConsts.nativeStreamMetadataFormatName, - JPEGSpiConsts.nativeStreamMetadataFormatClassName, - JPEGSpiConsts.extraStreamMetadataFormatNames, - JPEGSpiConsts.extraStreamMetadataFormatClassNames, - JPEGSpiConsts.supportsStandardImageMetadataFormat, - JPEGSpiConsts.nativeImageMetadataFormatName, - JPEGSpiConsts.nativeImageMetadataFormatClassName, - JPEGSpiConsts.extraImageMetadataFormatNames, - JPEGSpiConsts.extraImageMetadataFormatClassNames); - } - - - @Override - public boolean canDecodeInput(Object source) throws IOException { - ImageInputStream markable = (ImageInputStream) source; - try { - markable.mark(); - - byte[] signature = new byte[3]; - markable.seek(0); - markable.read(signature, 0, 3); - markable.reset(); - - if ((signature[0] & 0xFF) == 0xFF && - (signature[1] & 0xFF) == JPEGConsts.SOI && - (signature[2] & 0xFF) == 0xFF) { // JPEG - return true; - } - } catch (IOException e) { - e.printStackTrace(); - } - return false; - } - - @Override - public ImageReader createReaderInstance(Object extension) throws IOException { - return new JPEGImageReader(this); - } - - @Override - public String getDescription(Locale locale) { - return "DRL JPEG decoder"; - } - - @Override - public void onRegistration(ServiceRegistry registry, Class<?> category) { - // super.onRegistration(registry, category); - } -} diff --git a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriter.java b/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriter.java deleted file mode 100644 index ae3e876..0000000 --- a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriter.java +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @author Rustem V. Rafikov - * @version $Revision: 1.3 $ - */ -package org.apache.harmony.x.imageio.plugins.jpeg; - -import com.android.internal.awt.ImageOutputStreamWrapper; - -import javax.imageio.ImageWriter; -import javax.imageio.IIOImage; -import javax.imageio.ImageTypeSpecifier; -import javax.imageio.ImageWriteParam; -import javax.imageio.plugins.jpeg.JPEGImageWriteParam; -import javax.imageio.stream.ImageOutputStream; -import javax.imageio.spi.ImageWriterSpi; -import javax.imageio.metadata.IIOMetadata; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Bitmap.CompressFormat; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.awt.image.*; -import java.awt.*; -import java.awt.color.ColorSpace; - -/** - * @author Rustem V. Rafikov - * @version $Revision: 1.3 $ - */ -public class JPEGImageWriter extends ImageWriter { - - // /* ???AWT: Debugging - private static final boolean DEBUG = false; - private static Bitmap bm; - public static Bitmap getBitmap() { - return bm; - } - private static BufferedImage bufImg; - public static BufferedImage getBufImage() { - return bufImg; - } - static private RenderedImage renImg; - static public RenderedImage getRenImage() { - return renImg; - } - // */ - - private long cinfo; - private RenderedImage image; - private Raster sourceRaster; - private WritableRaster scanRaster; - private int srcXOff = 0; - private int srcYOff = 0; - private int srcWidth; - private int srcHeight; - - //-- y step for image subsampling - private int deltaY = 1; - //-- x step for image subsampling - private int deltaX = 1; - - private ImageOutputStream ios; - - public JPEGImageWriter(ImageWriterSpi imageWriterSpi) { - super(imageWriterSpi); - //???AWT: cinfo = initCompressionObj(); - cinfo = System.currentTimeMillis(); - } - - static { - //???AWT - /* - System.loadLibrary("jpegencoder"); - initWriterIds(ImageOutputStream.class); - */ - } - - @Override - public void write(IIOMetadata iioMetadata, IIOImage iioImage, ImageWriteParam param) - throws IOException { - - if (ios == null) { - throw new IllegalArgumentException("ios == null"); - } - if (iioImage == null) { - throw new IllegalArgumentException("Image equals null"); - } - - RenderedImage img = null; - if (!iioImage.hasRaster()) { - img = iioImage.getRenderedImage(); - if (img instanceof BufferedImage) { - sourceRaster = ((BufferedImage) img).getRaster(); - } else { - sourceRaster = img.getData(); - } - } else { - sourceRaster = iioImage.getRaster(); - } - - // AWT???: Debugging - if (DEBUG) { - if( img==null ) { - System.out.println("****J: Image is NULL"); - } else { - renImg = img; - bufImg = (BufferedImage)img; - } - } - - int numBands = sourceRaster.getNumBands(); - int sourceIJGCs = img == null ? JPEGConsts.JCS_UNKNOW : getSourceCSType(img); - - srcWidth = sourceRaster.getWidth(); - srcHeight = sourceRaster.getHeight(); - - int destWidth = srcWidth; - int destHeight = srcHeight; - - boolean progressive = false; - - if (param != null) { - Rectangle reg = param.getSourceRegion(); - if (reg != null) { - srcXOff = reg.x; - srcYOff = reg.y; - - srcWidth = reg.width + srcXOff > srcWidth - ? srcWidth - srcXOff - : reg.width; - srcHeight = reg.height + srcYOff > srcHeight - ? srcHeight - srcYOff - : reg.height; - } - - //-- TODO uncomment when JPEGImageWriteParam be implemented - //-- Only default progressive mode yet - // progressive = param.getProgressiveMode() == ImageWriteParam.MODE_DEFAULT; - - //-- def is 1 - deltaX = param.getSourceXSubsampling(); - deltaY = param.getSourceYSubsampling(); - - //-- def is 0 - int offsetX = param.getSubsamplingXOffset(); - int offsetY = param.getSubsamplingYOffset(); - - srcXOff += offsetX; - srcYOff += offsetY; - srcWidth -= offsetX; - srcHeight -= offsetY; - - destWidth = (srcWidth + deltaX - 1) / deltaX; - destHeight = (srcHeight + deltaY - 1) / deltaY; - } - - //-- default DQTs (see JPEGQTable java doc and JPEG spec K1 & K2 tables) - //-- at http://www.w3.org/Graphics/JPEG/itu-t81.pdf - //-- Only figuring out how to set DQT in IJG library for future metadata - //-- support. IJG def tables are the same. - //JPEGQTable[] dqt = new JPEGQTable[2]; -// int[][] dqt = null; -// int[][] dqt = new int[2][]; -// dqt[0] = JPEGQTable.K1Div2Luminance.getTable(); -// dqt[1] = JPEGQTable.K2Div2Chrominance.getTable(); - - //???AWT: I think we don't need this amymore - /* - //-- using default color space - //-- TODO: Take destination cs from param or use default if there is no cs - int destIJGCs = img == null ? JPEGConsts.JCS_UNKNOW : getDestinationCSType(img); - - DataBufferByte dbuffer = new DataBufferByte(numBands * srcWidth); - - scanRaster = Raster.createInterleavedRaster(dbuffer, srcWidth, 1, - numBands * srcWidth, numBands, JPEGConsts.BAND_OFFSETS[numBands], null); - - encode(dbuffer.getData(), srcWidth, destWidth, destHeight, deltaX, - sourceIJGCs, destIJGCs, numBands, progressive, - null, cinfo); - */ - - SampleModel model = sourceRaster.getSampleModel(); - - if (model instanceof SinglePixelPackedSampleModel) { - DataBufferInt ibuf = (DataBufferInt)sourceRaster.getDataBuffer(); - int[] pixels = ibuf.getData(); - - // Create a bitmap with the pixel - bm = Bitmap.createBitmap(pixels, srcWidth, srcHeight, Bitmap.Config.ARGB_8888); - - // Use Bitmap.compress() to write the image - ImageOutputStreamWrapper iosw = new ImageOutputStreamWrapper(ios); - bm.compress(CompressFormat.JPEG, 100, iosw); - } else { - // ???AWT: Add support for other color models - throw new RuntimeException("Color model not supported yet"); - } - - } - - @Override - public void dispose() { - super.dispose(); - if (cinfo != 0) { - //???AWT: dispose(cinfo); - cinfo = 0; - ios = null; - } - } - - - public IIOMetadata getDefaultStreamMetadata(ImageWriteParam imageWriteParam) { - throw new UnsupportedOperationException("not supported yet"); - } - - public IIOMetadata getDefaultImageMetadata(ImageTypeSpecifier imageTypeSpecifier, ImageWriteParam imageWriteParam) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public IIOMetadata convertStreamMetadata(IIOMetadata iioMetadata, ImageWriteParam imageWriteParam) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public IIOMetadata convertImageMetadata(IIOMetadata iioMetadata, ImageTypeSpecifier imageTypeSpecifier, ImageWriteParam imageWriteParam) { - throw new UnsupportedOperationException("not supported yet"); - } - - @Override - public void setOutput(Object output) { - super.setOutput(output); - ios = (ImageOutputStream) output; - //???AWT: setIOS(ios, cinfo); - sourceRaster = null; - scanRaster = null; - srcXOff = 0; - srcYOff = 0; - srcWidth = 0; - srcHeight = 0; - deltaY = 1; - } - - /** - * Frees resources - * @param structPointer - */ - //???AWT: private native void dispose(long structPointer); - - /** - * Inits methods Ids for native to java callbacks - * @param iosClass - */ - //???AWT: private native static void initWriterIds(Class<ImageOutputStream> iosClass); - - /** - * Inits compression objects - * @return pointer to the native structure - */ - //???AWT: private native long initCompressionObj(); - - /** - * Sets image output stream in IJG layer - * @param stream - */ - //???AWT: private native void setIOS(ImageOutputStream stream, long structPointer); - - /** - * Runs encoding process. - * - * @param data image data buffer to encode - * @param srcWidth - source width - * @param width - destination width - * @param height destination height - * @param deltaX - x subsampling step - * @param inColorSpace - original color space - * @param outColorSpace - destination color space - * @param numBands - number of bands - * @param cinfo - native handler - * @return - */ - //???AWT: - /* - private native boolean encode(byte[] data, int srcWidth, - int width, int height, int deltaX, - int inColorSpace, int outColorSpace, - int numBands, boolean progressive, - int[][] dqt, - long cinfo); - */ - - /** - * Callback for getting a next scanline - * @param scanline scan line number - */ - @SuppressWarnings("unused") - private void getScanLine(int scanline) { - //-- TODO: processImageProgress in ImageWriter - Raster child = sourceRaster.createChild(srcXOff, - srcYOff + scanline * deltaY, srcWidth, 1, 0, 0, null); - - scanRaster.setRect(child); - } - - /** - * Maps color space types to IJG color spaces - * @param image - * @return - */ - private int getSourceCSType(RenderedImage image) { - int type = JPEGConsts.JCS_UNKNOW; - ColorModel cm = image.getColorModel(); - - if (null == cm) { - return type; - } - - if (cm instanceof IndexColorModel) { - throw new UnsupportedOperationException("IndexColorModel is not supported yet"); - } - - boolean hasAlpha = cm.hasAlpha(); - ColorSpace cs = cm.getColorSpace(); - switch(cs.getType()) { - case ColorSpace.TYPE_GRAY: - type = JPEGConsts.JCS_GRAYSCALE; - break; - case ColorSpace.TYPE_RGB: - type = hasAlpha ? JPEGConsts.JCS_RGBA : JPEGConsts.JCS_RGB; - break; - case ColorSpace.TYPE_YCbCr: - type = hasAlpha ? JPEGConsts.JCS_YCbCrA : JPEGConsts.JCS_YCbCr; - break; - case ColorSpace.TYPE_3CLR: - type = hasAlpha ? JPEGConsts.JCS_YCCA : JPEGConsts.JCS_YCC; - break; - case ColorSpace.TYPE_CMYK: - type = JPEGConsts.JCS_CMYK; - break; - } - return type; - } - - /** - * Returns destination color space. - * (YCbCr[A] for RGB) - * - * @param image - * @return - */ - private int getDestinationCSType(RenderedImage image) { - int type = JPEGConsts.JCS_UNKNOW; - ColorModel cm = image.getColorModel(); - if (null != cm) { - boolean hasAlpha = cm.hasAlpha(); - ColorSpace cs = cm.getColorSpace(); - - switch(cs.getType()) { - case ColorSpace.TYPE_GRAY: - type = JPEGConsts.JCS_GRAYSCALE; - break; - case ColorSpace.TYPE_RGB: - type = hasAlpha ? JPEGConsts.JCS_YCbCrA : JPEGConsts.JCS_YCbCr; - break; - case ColorSpace.TYPE_YCbCr: - type = hasAlpha ? JPEGConsts.JCS_YCbCrA : JPEGConsts.JCS_YCbCr; - break; - case ColorSpace.TYPE_3CLR: - type = hasAlpha ? JPEGConsts.JCS_YCCA : JPEGConsts.JCS_YCC; - break; - case ColorSpace.TYPE_CMYK: - type = JPEGConsts.JCS_CMYK; - break; - } - } - return type; - } - - public ImageWriteParam getDefaultWriteParam() { - return new JPEGImageWriteParam(getLocale()); - } -} diff --git a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriterSpi.java b/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriterSpi.java deleted file mode 100644 index b7990e0..0000000 --- a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGImageWriterSpi.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @author Rustem V. Rafikov - * @version $Revision: 1.3 $ - */ -package org.apache.harmony.x.imageio.plugins.jpeg; - -import javax.imageio.spi.ImageWriterSpi; -import javax.imageio.ImageWriter; -import javax.imageio.ImageTypeSpecifier; -import java.io.IOException; -import java.util.Locale; - -public class JPEGImageWriterSpi extends ImageWriterSpi { - - public JPEGImageWriterSpi() { - super(JPEGSpiConsts.vendorName, JPEGSpiConsts.version, - JPEGSpiConsts.names, JPEGSpiConsts.suffixes, JPEGSpiConsts.MIMETypes, - JPEGSpiConsts.writerClassName, STANDARD_OUTPUT_TYPE, - JPEGSpiConsts.readerSpiNames, JPEGSpiConsts.supportsStandardStreamMetadataFormat /*TODO: support st. metadata format*/, - JPEGSpiConsts.nativeStreamMetadataFormatName, JPEGSpiConsts.nativeStreamMetadataFormatClassName, - JPEGSpiConsts.extraStreamMetadataFormatNames, JPEGSpiConsts.extraStreamMetadataFormatClassNames, - JPEGSpiConsts.supportsStandardImageMetadataFormat, JPEGSpiConsts.nativeImageMetadataFormatName, JPEGSpiConsts.nativeImageMetadataFormatClassName, - JPEGSpiConsts.extraImageMetadataFormatNames, JPEGSpiConsts.extraImageMetadataFormatClassNames); - } - - @Override - public boolean canEncodeImage(ImageTypeSpecifier imageTypeSpecifier) { - return true; - } - - @Override - public ImageWriter createWriterInstance(Object o) throws IOException { - return new JPEGImageWriter(this); - } - - @Override - public String getDescription(Locale locale) { - return "DRL JPEG Encoder"; - } -} diff --git a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGSpiConsts.java b/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGSpiConsts.java deleted file mode 100644 index c3b4a50..0000000 --- a/awt/org/apache/harmony/x/imageio/plugins/jpeg/JPEGSpiConsts.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * @author Rustem V. Rafikov - * @version $Revision: 1.2 $ - */ -package org.apache.harmony.x.imageio.plugins.jpeg; - -/** - * @author Rustem V. Rafikov - * @version $Revision: 1.2 $ - */ -public class JPEGSpiConsts { - private JPEGSpiConsts() {} - - public static final String vendorName = "Intel Corporation"; - public static final String version = "0.1 beta"; - - static final String readerClassName = "org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageReader"; - static final String writerClassName = "org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriter"; - - static final String[] names = {"jpeg", "jpg", "JPEG", "JPG"}; - static final String[] suffixes = {"jpeg", "jpg"}; - static final String[] MIMETypes = {"image/jpeg"}; - - static final String[] writerSpiNames = {"org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriterSpi"}; - static final String[] readerSpiNames = {"org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageReaderSpi"}; - - //-- TODO fill this stuff with correct data - static final boolean supportsStandardStreamMetadataFormat = false; - static final String nativeStreamMetadataFormatName = null; - static final String nativeStreamMetadataFormatClassName = null; - static final String[] extraStreamMetadataFormatNames = null; - static final String[] extraStreamMetadataFormatClassNames = null; - static final boolean supportsStandardImageMetadataFormat = false; - static final String nativeImageMetadataFormatName = - "org.apache.harmony.x.imageio.plugins.jpeg.MyFormatMetadata_1.0"; - static final String nativeImageMetadataFormatClassName = - "org.apache.harmony.x.imageio.plugins.jpeg.MyFormatMetadata"; - static final String[] extraImageMetadataFormatNames = null; - static final String[] extraImageMetadataFormatClassNames = null; - -} |