1 /*
2 * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
789 if (seleBand)
790 sampleModel = sampleModel.createSubsetSampleModel(sourceBands);
791 raster = Raster.createWritableRaster(sampleModel, new Point());
792 bi = new BufferedImage(colorModel, raster, false, null);
793 }
794 } else {
795 raster = bi.getWritableTile(0, 0);
796 sampleModel = bi.getSampleModel();
797 colorModel = bi.getColorModel();
798
799 noTransform &= destinationRegion.equals(raster.getBounds());
800 }
801
802 byte bdata[] = null; // buffer for byte data
803 short sdata[] = null; // buffer for short data
804 int idata[] = null; // buffer for int data
805
806 // the sampleModel can be null in case of embedded image
807 if (sampleModel != null) {
808 if (sampleModel.getDataType() == DataBuffer.TYPE_BYTE)
809 bdata = (byte[])
810 ((DataBufferByte)raster.getDataBuffer()).getData();
811 else if (sampleModel.getDataType() == DataBuffer.TYPE_USHORT)
812 sdata = (short[])
813 ((DataBufferUShort)raster.getDataBuffer()).getData();
814 else if (sampleModel.getDataType() == DataBuffer.TYPE_INT)
815 idata = (int[])
816 ((DataBufferInt)raster.getDataBuffer()).getData();
817 }
818
819 // There should only be one tile.
820 switch(imageType) {
821
822 case VERSION_2_1_BIT:
823 // no compression
824 read1Bit(bdata);
825 break;
826
827 case VERSION_2_4_BIT:
828 // no compression
829 read4Bit(bdata);
830 break;
831
832 case VERSION_2_8_BIT:
833 // no compression
834 read8Bit(bdata);
835 break;
836
|
1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
789 if (seleBand)
790 sampleModel = sampleModel.createSubsetSampleModel(sourceBands);
791 raster = Raster.createWritableRaster(sampleModel, new Point());
792 bi = new BufferedImage(colorModel, raster, false, null);
793 }
794 } else {
795 raster = bi.getWritableTile(0, 0);
796 sampleModel = bi.getSampleModel();
797 colorModel = bi.getColorModel();
798
799 noTransform &= destinationRegion.equals(raster.getBounds());
800 }
801
802 byte bdata[] = null; // buffer for byte data
803 short sdata[] = null; // buffer for short data
804 int idata[] = null; // buffer for int data
805
806 // the sampleModel can be null in case of embedded image
807 if (sampleModel != null) {
808 if (sampleModel.getDataType() == DataBuffer.TYPE_BYTE)
809 bdata = ((DataBufferByte)raster.getDataBuffer()).getData();
810 else if (sampleModel.getDataType() == DataBuffer.TYPE_USHORT)
811 sdata = ((DataBufferUShort)raster.getDataBuffer()).getData();
812 else if (sampleModel.getDataType() == DataBuffer.TYPE_INT)
813 idata = ((DataBufferInt)raster.getDataBuffer()).getData();
814 }
815
816 // There should only be one tile.
817 switch(imageType) {
818
819 case VERSION_2_1_BIT:
820 // no compression
821 read1Bit(bdata);
822 break;
823
824 case VERSION_2_4_BIT:
825 // no compression
826 read4Bit(bdata);
827 break;
828
829 case VERSION_2_8_BIT:
830 // no compression
831 read8Bit(bdata);
832 break;
833
|