1 /*
2 * Copyright (c) 1995, 2010, 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
192 bi.setAccelerationPriority(image.getAccelerationPriority());
193 return bi;
194 }
195
196 public void setProperties(Hashtable<?,?> props) {
197 if (src != null) {
198 src.checkSecurity(null, false);
199 }
200 image.setProperties(props);
201 newInfo(image, ImageObserver.PROPERTIES, 0, 0, 0, 0);
202 }
203
204 public void setColorModel(ColorModel model) {
205 if (src != null) {
206 src.checkSecurity(null, false);
207 }
208 srcModel = model;
209
210 // Check to see if model is INT_RGB
211 if (model instanceof IndexColorModel) {
212 if (model.getTransparency() == model.TRANSLUCENT) {
213 // REMIND:
214 // Probably need to composite anyway so force ARGB
215 cmodel = ColorModel.getRGBdefault();
216 srcLUT = null;
217 }
218 else {
219 IndexColorModel icm = (IndexColorModel) model;
220 numSrcLUT = icm.getMapSize();
221 srcLUT = new int[Math.max(numSrcLUT, 256)];
222 icm.getRGBs(srcLUT);
223 srcLUTtransIndex = icm.getTransparentPixel();
224 cmodel = model;
225 }
226 }
227 else {
228 if (cmodel == null) {
229 cmodel = model;
230 srcLUT = null;
231 }
232 else if (model instanceof DirectColorModel) {
569 convertToRGB();
570 }
571
572 if ((model == cmodel) &&
573 (biRaster instanceof IntegerComponentRaster)) {
574 IntegerComponentRaster iraster =
575 (IntegerComponentRaster) biRaster;
576
577 if (off == 0 && scansize == w) {
578 iraster.setDataElements(x, y, w, h, pix);
579 }
580 else {
581 // Need to pack the data
582 for (yoff=y; yoff < y+h; yoff++, lineOff+=scansize) {
583 System.arraycopy(pix, lineOff, storage, 0, w);
584 iraster.setDataElements(x, yoff, w, 1, storage);
585 }
586 }
587 }
588 else {
589 if (model.getTransparency() != model.OPAQUE &&
590 cmodel.getTransparency() == cmodel.OPAQUE) {
591 convertToRGB();
592 }
593
594 if (isDefaultBI) {
595 IntegerComponentRaster iraster =
596 (IntegerComponentRaster) biRaster;
597 int[] data = iraster.getDataStorage();
598 if (cmodel.equals(model)) {
599 int sstride = iraster.getScanlineStride();
600 int doff = y*sstride + x;
601 for (yoff=0; yoff < h; yoff++, lineOff += scansize) {
602 System.arraycopy(pix, lineOff, data, doff, w);
603 doff += sstride;
604 }
605 // Note: manual modification of pixels, mark the
606 // raster as changed
607 iraster.markDirty();
608 }
609 else {
610 for (yoff=y; yoff < y+h; yoff++, lineOff += scansize) {
|
1 /*
2 * Copyright (c) 1995, 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
192 bi.setAccelerationPriority(image.getAccelerationPriority());
193 return bi;
194 }
195
196 public void setProperties(Hashtable<?,?> props) {
197 if (src != null) {
198 src.checkSecurity(null, false);
199 }
200 image.setProperties(props);
201 newInfo(image, ImageObserver.PROPERTIES, 0, 0, 0, 0);
202 }
203
204 public void setColorModel(ColorModel model) {
205 if (src != null) {
206 src.checkSecurity(null, false);
207 }
208 srcModel = model;
209
210 // Check to see if model is INT_RGB
211 if (model instanceof IndexColorModel) {
212 if (model.getTransparency() == Transparency.TRANSLUCENT) {
213 // REMIND:
214 // Probably need to composite anyway so force ARGB
215 cmodel = ColorModel.getRGBdefault();
216 srcLUT = null;
217 }
218 else {
219 IndexColorModel icm = (IndexColorModel) model;
220 numSrcLUT = icm.getMapSize();
221 srcLUT = new int[Math.max(numSrcLUT, 256)];
222 icm.getRGBs(srcLUT);
223 srcLUTtransIndex = icm.getTransparentPixel();
224 cmodel = model;
225 }
226 }
227 else {
228 if (cmodel == null) {
229 cmodel = model;
230 srcLUT = null;
231 }
232 else if (model instanceof DirectColorModel) {
569 convertToRGB();
570 }
571
572 if ((model == cmodel) &&
573 (biRaster instanceof IntegerComponentRaster)) {
574 IntegerComponentRaster iraster =
575 (IntegerComponentRaster) biRaster;
576
577 if (off == 0 && scansize == w) {
578 iraster.setDataElements(x, y, w, h, pix);
579 }
580 else {
581 // Need to pack the data
582 for (yoff=y; yoff < y+h; yoff++, lineOff+=scansize) {
583 System.arraycopy(pix, lineOff, storage, 0, w);
584 iraster.setDataElements(x, yoff, w, 1, storage);
585 }
586 }
587 }
588 else {
589 if (model.getTransparency() != Transparency.OPAQUE &&
590 cmodel.getTransparency() == Transparency.OPAQUE) {
591 convertToRGB();
592 }
593
594 if (isDefaultBI) {
595 IntegerComponentRaster iraster =
596 (IntegerComponentRaster) biRaster;
597 int[] data = iraster.getDataStorage();
598 if (cmodel.equals(model)) {
599 int sstride = iraster.getScanlineStride();
600 int doff = y*sstride + x;
601 for (yoff=0; yoff < h; yoff++, lineOff += scansize) {
602 System.arraycopy(pix, lineOff, data, doff, w);
603 doff += sstride;
604 }
605 // Note: manual modification of pixels, mark the
606 // raster as changed
607 iraster.markDirty();
608 }
609 else {
610 for (yoff=y; yoff < y+h; yoff++, lineOff += scansize) {
|