01: /*
02: * $RCSfile: RandomIterCSMFloat.java,v $
03: *
04: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
05: *
06: * Use is subject to license terms.
07: *
08: * $Revision: 1.1 $
09: * $Date: 2005/02/11 04:55:42 $
10: * $State: Exp $
11: */
12: package com.sun.media.jai.iterator;
13:
14: import java.awt.Rectangle;
15: import java.awt.image.RenderedImage;
16: import com.sun.media.jai.util.DataBufferUtils;
17:
18: /**
19: * @since EA2
20: */
21: public class RandomIterCSMFloat extends RandomIterCSM {
22:
23: float[][] bankData;
24:
25: public RandomIterCSMFloat(RenderedImage im, Rectangle bounds) {
26: super (im, bounds);
27: }
28:
29: protected final void dataBufferChanged() {
30: this .bankData = DataBufferUtils.getBankDataFloat(dataBuffer);
31: }
32:
33: public final int getSample(int x, int y, int b) {
34: makeCurrent(x - boundsX, y - boundsX);
35: return (int) bankData[b][(x - sampleModelTranslateX)
36: * pixelStride + (y - sampleModelTranslateY)
37: * scanlineStride + bandOffsets[b]];
38: }
39:
40: public final float getSampleFloat(int x, int y, int b) {
41: makeCurrent(x - boundsX, y - boundsX);
42: return bankData[b][(x - sampleModelTranslateX) * pixelStride
43: + (y - sampleModelTranslateY) * scanlineStride
44: + bandOffsets[b]];
45: }
46:
47: public final double getSampleDouble(int x, int y, int b) {
48: makeCurrent(x - boundsX, y - boundsX);
49: return (double) bankData[b][(x - sampleModelTranslateX)
50: * pixelStride + (y - sampleModelTranslateY)
51: * scanlineStride + bandOffsets[b]];
52: }
53:
54: public float[] getPixel(int x, int y, float[] fArray) {
55: if (fArray == null) {
56: fArray = new float[numBands];
57: }
58:
59: int offset = (x - sampleModelTranslateX) * pixelStride
60: + (y - sampleModelTranslateY) * scanlineStride;
61: for (int b = 0; b < numBands; b++) {
62: fArray[b] = bankData[b][offset + bandOffsets[b]];
63: }
64: return fArray;
65: }
66: }
|