< prev index next >
src/java.desktop/share/classes/sun/awt/image/ShortBandedRaster.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 27,37 ****
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.awt.image.RasterFormatException;
import java.awt.image.SampleModel;
import java.awt.image.BandedSampleModel;
- import java.awt.image.DataBuffer;
import java.awt.image.DataBufferUShort;
import java.awt.Rectangle;
import java.awt.Point;
/**
--- 27,36 ----
*** 70,83 ****
* Raster is automatically created. SampleModel must be of type
* BandedSampleModel.
* @param sampleModel The SampleModel that specifies the layout.
* @param origin The Point that specified the origin.
*/
! public ShortBandedRaster(SampleModel sampleModel,
! Point origin) {
this(sampleModel,
! sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
sampleModel.getHeight()),
origin,
--- 69,81 ----
* Raster is automatically created. SampleModel must be of type
* BandedSampleModel.
* @param sampleModel The SampleModel that specifies the layout.
* @param origin The Point that specified the origin.
*/
! public ShortBandedRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
! (DataBufferUShort) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
sampleModel.getHeight()),
origin,
*** 93,104 ****
* @param sampleModel The SampleModel that specifies the layout.
* @param dataBuffer The DataBufferUShort that contains the image data.
* @param origin The Point that specifies the origin.
*/
public ShortBandedRaster(SampleModel sampleModel,
! DataBuffer dataBuffer,
! Point origin) {
this(sampleModel, dataBuffer,
new Rectangle(origin.x, origin.y,
sampleModel.getWidth(),
sampleModel.getHeight()),
origin, null);
--- 91,103 ----
* @param sampleModel The SampleModel that specifies the layout.
* @param dataBuffer The DataBufferUShort that contains the image data.
* @param origin The Point that specifies the origin.
*/
public ShortBandedRaster(SampleModel sampleModel,
! DataBufferUShort dataBuffer,
! Point origin)
! {
this(sampleModel, dataBuffer,
new Rectangle(origin.x, origin.y,
sampleModel.getWidth(),
sampleModel.getHeight()),
origin, null);
*** 121,156 ****
* @param aRegion The Rectangle that specifies the image area.
* @param origin The Point that specifies the origin.
* @param parent The parent (if any) of this raster.
*/
public ShortBandedRaster(SampleModel sampleModel,
! DataBuffer dataBuffer,
Rectangle aRegion,
Point origin,
! ShortBandedRaster parent) {
!
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if (!(dataBuffer instanceof DataBufferUShort)) {
- throw new RasterFormatException("ShortBandedRaster must have " +
- "ushort DataBuffers");
- }
- DataBufferUShort dbus = (DataBufferUShort)dataBuffer;
if (sampleModel instanceof BandedSampleModel) {
BandedSampleModel bsm = (BandedSampleModel)sampleModel;
this.scanlineStride = bsm.getScanlineStride();
int bankIndices[] = bsm.getBankIndices();
int bandOffsets[] = bsm.getBandOffsets();
! int dOffsets[] = dbus.getOffsets();
dataOffsets = new int[bankIndices.length];
data = new short[bankIndices.length][];
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
for (int i = 0; i < bankIndices.length; i++) {
! data[i] = stealData(dbus, bankIndices[i]);
dataOffsets[i] = dOffsets[bankIndices[i]] +
xOffset + yOffset*scanlineStride + bandOffsets[i];
}
} else {
throw new RasterFormatException("ShortBandedRasters must have "+
--- 120,150 ----
* @param aRegion The Rectangle that specifies the image area.
* @param origin The Point that specifies the origin.
* @param parent The parent (if any) of this raster.
*/
public ShortBandedRaster(SampleModel sampleModel,
! DataBufferUShort dataBuffer,
Rectangle aRegion,
Point origin,
! ShortBandedRaster parent)
! {
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
if (sampleModel instanceof BandedSampleModel) {
BandedSampleModel bsm = (BandedSampleModel)sampleModel;
this.scanlineStride = bsm.getScanlineStride();
int bankIndices[] = bsm.getBankIndices();
int bandOffsets[] = bsm.getBandOffsets();
! int dOffsets[] = dataBuffer.getOffsets();
dataOffsets = new int[bankIndices.length];
data = new short[bankIndices.length][];
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
for (int i = 0; i < bankIndices.length; i++) {
! data[i] = stealData(dataBuffer, bankIndices[i]);
dataOffsets[i] = dOffsets[bankIndices[i]] +
xOffset + yOffset*scanlineStride + bandOffsets[i];
}
} else {
throw new RasterFormatException("ShortBandedRasters must have "+
*** 668,678 ****
int deltaX = x0 - x;
int deltaY = y0 - y;
return new ShortBandedRaster(sm,
! dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
this);
--- 662,672 ----
int deltaX = x0 - x;
int deltaY = y0 - y;
return new ShortBandedRaster(sm,
! (DataBufferUShort) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
this);
< prev index next >