001: /*
002: * $RCSfile: RectIterCSMFloat.java,v $
003: *
004: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
005: *
006: * Use is subject to license terms.
007: *
008: * $Revision: 1.1 $
009: * $Date: 2005/02/11 04:55:43 $
010: * $State: Exp $
011: */
012: package com.sun.media.jai.iterator;
013:
014: import java.awt.Rectangle;
015: import java.awt.image.RenderedImage;
016: import com.sun.media.jai.util.DataBufferUtils;
017:
018: /**
019: */
020: public class RectIterCSMFloat extends RectIterCSM {
021:
022: float[][] bankData;
023: float[] bank;
024:
025: public RectIterCSMFloat(RenderedImage im, Rectangle bounds) {
026: super (im, bounds);
027:
028: this .bankData = new float[numBands + 1][];
029: dataBufferChanged();
030: }
031:
032: protected final void dataBufferChanged() {
033: if (bankData == null) {
034: return;
035: }
036:
037: float[][] bd = DataBufferUtils.getBankDataFloat(dataBuffer);
038: for (int i = 0; i < numBands; i++) {
039: bankData[i] = bd[bankIndices[i]];
040: }
041: bank = bankData[b];
042:
043: adjustBandOffsets();
044: }
045:
046: public void startBands() {
047: super .startBands();
048: bank = bankData[0];
049: }
050:
051: public void nextBand() {
052: super .nextBand();
053: bank = bankData[b];
054: }
055:
056: public final int getSample() {
057: return (int) bank[offset + bandOffset];
058: }
059:
060: public final int getSample(int b) {
061: return (int) bankData[b][offset + bandOffsets[b]];
062: }
063:
064: public final float getSampleFloat() {
065: return bank[offset + bandOffset];
066: }
067:
068: public final float getSampleFloat(int b) {
069: return bankData[b][offset + bandOffsets[b]];
070: }
071:
072: public final double getSampleDouble() {
073: return (double) bank[offset + bandOffset];
074: }
075:
076: public final double getSampleDouble(int b) {
077: return (double) bankData[b][offset + bandOffsets[b]];
078: }
079:
080: public int[] getPixel(int[] iArray) {
081: if (iArray == null) {
082: iArray = new int[numBands];
083: }
084: for (int b = 0; b < numBands; b++) {
085: iArray[b] = (int) bankData[b][offset + bandOffsets[b]];
086: }
087: return iArray;
088: }
089:
090: public float[] getPixel(float[] fArray) {
091: if (fArray == null) {
092: fArray = new float[numBands];
093: }
094: for (int b = 0; b < numBands; b++) {
095: fArray[b] = bankData[b][offset + bandOffsets[b]];
096: }
097: return fArray;
098: }
099:
100: public double[] getPixel(double[] dArray) {
101: if (dArray == null) {
102: dArray = new double[numBands];
103: }
104: for (int b = 0; b < numBands; b++) {
105: dArray[b] = (double) bankData[b][offset + bandOffsets[b]];
106: }
107: return dArray;
108: }
109: }
|