1. /*
  2. * @(#)BandedSampleModel.java 1.27 00/02/02
  3. *
  4. * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. /* ****************************************************************
  11. ******************************************************************
  12. ******************************************************************
  13. *** COPYRIGHT (c) Eastman Kodak Company, 1997
  14. *** As an unpublished work pursuant to Title 17 of the United
  15. *** States Code. All rights reserved.
  16. ******************************************************************
  17. ******************************************************************
  18. ******************************************************************/
  19. package java.awt.image;
  20. /**
  21. * This class represents image data which is stored in a band interleaved
  22. * fashion and for
  23. * which each sample of a pixel occupies one data element of the DataBuffer.
  24. * It subclasses ComponentSampleModel but provides a more efficent
  25. * implementation for accessing band interleaved image data than is provided
  26. * by ComponentSampleModel. This class should typically be used when working
  27. * with images which store sample data for each band in a different bank of the
  28. * DataBuffer. Accessor methods are provided so that image data can be
  29. * manipulated directly. Pixel stride is the number of
  30. * data array elements between two samples for the same band on the same
  31. * scanline. The pixel stride for a BandedSampleModel is one.
  32. * Scanline stride is the number of data array elements between
  33. * a given sample and the corresponding sample in the same column of the next
  34. * scanline. Band offsets denote the number
  35. * of data array elements from the first data array element of the bank
  36. * of the DataBuffer holding each band to the first sample of the band.
  37. * The bands are numbered from 0 to N-1.
  38. * Bank indices denote the correspondence between a bank of the data buffer
  39. * and a band of image data. This class supports
  40. * {@link DataBuffer#TYPE_BYTE TYPE_BYTE},
  41. * {@link DataBuffer#TYPE_USHORT TYPE_USHORT},
  42. * {@link DataBuffer#TYPE_SHORT TYPE_SHORT},
  43. * {@link DataBuffer#TYPE_INT TYPE_INT} datatypes
  44. */
  45. public final class BandedSampleModel extends ComponentSampleModel
  46. {
  47. /**
  48. * Constructs a BandedSampleModel with the specified parameters.
  49. * The pixel stride will be one data element. The scanline stride
  50. * will be the same as the width. Each band will be stored in
  51. * a separate bank and all band offsets will be zero.
  52. * @param dataType The data type for storing samples.
  53. * @param w The width (in pixels) of the region of
  54. * image data described.
  55. * @param h The height (in pixels) of the region of image
  56. * data described.
  57. * @param numBands The number of bands for the image data.
  58. * @throws IllegalArgumentException if <code>dataType</code> is not
  59. * one of the supported data types
  60. */
  61. public BandedSampleModel(int dataType, int w, int h, int numBands) {
  62. super(dataType, w, h, 1, w,
  63. BandedSampleModel.createIndiciesArray(numBands),
  64. BandedSampleModel.createOffsetArray(numBands));
  65. }
  66. /**
  67. * Constructs a BandedSampleModel with the specified parameters.
  68. * The number of bands will be inferred from the lengths of the
  69. * bandOffsets bankIndices arrays, which must be equal. The pixel
  70. * stride will be one data element.
  71. * @param dataType The data type for storing samples.
  72. * @param w The width (in pixels) of the region of
  73. * image data described.
  74. * @param h The height (in pixels) of the region of
  75. * image data described.
  76. * @param numBands The number of bands for the image data.
  77. * @param scanlineStride The line stride of the of the image data.
  78. * @param bankIndices The bank index for each band.
  79. * @param bandOffsets The band offset for each band.
  80. * @throws IllegalArgumentException if <code>dataType</code> is not
  81. * one of the supported data types
  82. */
  83. public BandedSampleModel(int dataType,
  84. int w, int h,
  85. int scanlineStride,
  86. int bankIndices[],
  87. int bandOffsets[]) {
  88. super(dataType, w, h, 1,scanlineStride, bankIndices, bandOffsets);
  89. }
  90. /**
  91. * Creates a new BandedSampleModel with the specified
  92. * width and height. The new BandedSampleModel will have the same
  93. * number of bands, storage data type, and bank indices
  94. * as this BandedSampleModel. The band offsets will be compressed
  95. * such that the offset between bands will be w*pixelStride and
  96. * the minimum of all of the band offsets is zero.
  97. * @param w the width of the resulting <code>BandedSampleModel</code>
  98. * @param h the height of the resulting <code>BandedSampleModel</code>
  99. * @return a new <code>BandedSampleModel</code> with the specified
  100. * width and height.
  101. * @throws IllegalArgumentException if <code>w</code> or
  102. * <code>h</code> equals either
  103. * <code>Integer.MAX_VALUE</code> or
  104. * <code>Integer.MIN_VALUE</code>
  105. * @throws IllegalArgumentException if <code>dataType</code> is not
  106. * one of the supported data types
  107. */
  108. public SampleModel createCompatibleSampleModel(int w, int h) {
  109. int[] bandOffs;
  110. if (numBanks == 1) {
  111. bandOffs = orderBands(bandOffsets, w*h);
  112. }
  113. else {
  114. bandOffs = new int[bandOffsets.length];
  115. }
  116. SampleModel sampleModel =
  117. new BandedSampleModel(dataType, w, h, w, bankIndices, bandOffs);
  118. return sampleModel;
  119. }
  120. /**
  121. * Creates a new BandedSampleModel with a subset of the bands of this
  122. * BandedSampleModel. The new BandedSampleModel can be
  123. * used with any DataBuffer that the existing BandedSampleModel
  124. * can be used with. The new BandedSampleModel/DataBuffer
  125. * combination will represent an image with a subset of the bands
  126. * of the original BandedSampleModel/DataBuffer combination.
  127. * @throws RasterFormatException if the number of bands is greater than
  128. * the number of banks in this sample model.
  129. * @throws IllegalArgumentException if <code>dataType</code> is not
  130. * one of the supported data types
  131. */
  132. public SampleModel createSubsetSampleModel(int bands[]) {
  133. if (bands.length > bankIndices.length)
  134. throw new RasterFormatException("There are only " +
  135. bankIndices.length +
  136. " bands");
  137. int newBankIndices[] = new int[bands.length];
  138. int newBandOffsets[] = new int[bands.length];
  139. for (int i=0; i<bands.length; i++) {
  140. newBankIndices[i] = bankIndices[bands[i]];
  141. newBandOffsets[i] = bandOffsets[bands[i]];
  142. }
  143. return new BandedSampleModel(this.dataType, width, height,
  144. this.scanlineStride,
  145. newBankIndices, newBandOffsets);
  146. }
  147. /**
  148. * Creates a DataBuffer that corresponds to this BandedSampleModel,
  149. * The DataBuffer's data type, number of banks, and size
  150. * will be consistent with this BandedSampleModel.
  151. * @throws IllegalArgumentException if <code>dataType</code> is not
  152. * either <code>DataBuffer.TYPE_BYTE</code>,
  153. * <code>DataBuffer.TYPE_USHORT</code>, or
  154. * <code>DataBuffer.TYPE_SHORT</code>, or
  155. * <code>DataBuffer.TYPE_INT</code>
  156. */
  157. public DataBuffer createDataBuffer() {
  158. DataBuffer dataBuffer = null;
  159. int size = scanlineStride * height;
  160. switch (dataType) {
  161. case DataBuffer.TYPE_BYTE:
  162. dataBuffer = new DataBufferByte(size, numBands);
  163. break;
  164. case DataBuffer.TYPE_USHORT:
  165. dataBuffer = new DataBufferUShort(size, numBands);
  166. break;
  167. case DataBuffer.TYPE_SHORT:
  168. dataBuffer = new DataBufferShort(size, numBands);
  169. break;
  170. case DataBuffer.TYPE_INT:
  171. dataBuffer = new DataBufferInt(size, numBands);
  172. break;
  173. }
  174. return dataBuffer;
  175. }
  176. /**
  177. * Returns data for a single pixel in a primitive array of type
  178. * TransferType. For a BandedSampleModel, this will be the same
  179. * as the data type, and samples will be returned one per array
  180. * element. Generally, obj
  181. * should be passed in as null, so that the Object will be created
  182. * automatically and will be of the right primitive data type.
  183. * <p>
  184. * The following code illustrates transferring data for one pixel from
  185. * DataBuffer <code>db1</code>, whose storage layout is described by
  186. * BandedSampleModel <code>bsm1</code>, to DataBuffer <code>db2</code>,
  187. * whose storage layout is described by
  188. * BandedSampleModel <code>bsm2</code>.
  189. * The transfer will generally be more efficient than using
  190. * getPixel/setPixel.
  191. * <pre>
  192. * BandedSampleModel bsm1, bsm2;
  193. * DataBufferInt db1, db2;
  194. * bsm2.setDataElements(x, y, bsm1.getDataElements(x, y, null, db1),
  195. * db2);
  196. * </pre>
  197. * Using getDataElements/setDataElements to transfer between two
  198. * DataBuffer/SampleModel pairs is legitimate if the SampleModels have
  199. * the same number of bands, corresponding bands have the same number of
  200. * bits per sample, and the TransferTypes are the same.
  201. * <p>
  202. * If obj is non-null, it should be a primitive array of type TransferType.
  203. * Otherwise, a ClassCastException is thrown. An
  204. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  205. * not in bounds, or if obj is non-null and is not large enough to hold
  206. * the pixel data.
  207. * @param x The X coordinate of the pixel location.
  208. * @param y The Y coordinate of the pixel location.
  209. * @param obj If non-null, a primitive array in which to return
  210. * the pixel data.
  211. * @param data The DataBuffer containing the image data.
  212. */
  213. public Object getDataElements(int x, int y, Object obj, DataBuffer data) {
  214. int type = getTransferType();
  215. int numDataElems = getNumDataElements();
  216. int pixelOffset = y*scanlineStride + x;
  217. switch(type) {
  218. case DataBuffer.TYPE_BYTE:
  219. byte[] bdata;
  220. if (obj == null) {
  221. bdata = new byte[numDataElems];
  222. } else {
  223. bdata = (byte[])obj;
  224. }
  225. for (int i=0; i<numDataElems; i++) {
  226. bdata[i] = (byte)data.getElem(bankIndices[i],
  227. pixelOffset + bandOffsets[i]);
  228. }
  229. obj = (Object)bdata;
  230. break;
  231. case DataBuffer.TYPE_USHORT:
  232. case DataBuffer.TYPE_SHORT:
  233. short[] sdata;
  234. if (obj == null) {
  235. sdata = new short[numDataElems];
  236. } else {
  237. sdata = (short[])obj;
  238. }
  239. for (int i=0; i<numDataElems; i++) {
  240. sdata[i] = (short)data.getElem(bankIndices[i],
  241. pixelOffset + bandOffsets[i]);
  242. }
  243. obj = (Object)sdata;
  244. break;
  245. case DataBuffer.TYPE_INT:
  246. int[] idata;
  247. if (obj == null) {
  248. idata = new int[numDataElems];
  249. } else {
  250. idata = (int[])obj;
  251. }
  252. for (int i=0; i<numDataElems; i++) {
  253. idata[i] = data.getElem(bankIndices[i],
  254. pixelOffset + bandOffsets[i]);
  255. }
  256. obj = (Object)idata;
  257. break;
  258. }
  259. return obj;
  260. }
  261. /**
  262. * Returns all samples for the specified pixel in an int array.
  263. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  264. * not in bounds.
  265. * @param x The X coordinate of the pixel location.
  266. * @param y The Y coordinate of the pixel location.
  267. * @param iArray If non-null, returns the samples in this array.
  268. * @param data The DataBuffer containing the image data.
  269. */
  270. public int[] getPixel(int x, int y, int iArray[], DataBuffer data) {
  271. int[] pixels;
  272. if (iArray != null) {
  273. pixels = iArray;
  274. } else {
  275. pixels = new int [numBands];
  276. }
  277. int pixelOffset = y*scanlineStride + x;
  278. for (int i=0; i<numBands; i++) {
  279. pixels[i] = data.getElem(bankIndices[i],
  280. pixelOffset + bandOffsets[i]);
  281. }
  282. return pixels;
  283. }
  284. /**
  285. * Returns all samples for the specified rectangle of pixels in
  286. * an int array, one sample per data array element.
  287. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  288. * not in bounds.
  289. * @param x The X coordinate of the upper left pixel location.
  290. * @param y The Y coordinate of the upper left pixel location.
  291. * @param w The width of the pixel rectangle.
  292. * @param h The height of the pixel rectangle.
  293. * @param iArray If non-null, returns the samples in this array.
  294. * @param data The DataBuffer containing the image data.
  295. */
  296. public int[] getPixels(int x, int y, int w, int h,
  297. int iArray[], DataBuffer data) {
  298. int[] pixels;
  299. if (iArray != null) {
  300. pixels = iArray;
  301. } else {
  302. pixels = new int[w*h*numBands];
  303. }
  304. for (int k = 0; k < numBands; k++) {
  305. int lineOffset = y*scanlineStride + x + bandOffsets[k];
  306. int srcOffset = k;
  307. int bank = bankIndices[k];
  308. for (int i = 0; i < h; i++) {
  309. int pixelOffset = lineOffset;
  310. for (int j = 0; j < w; j++) {
  311. pixels[srcOffset] = data.getElem(bank, pixelOffset++);
  312. srcOffset += numBands;
  313. }
  314. lineOffset += scanlineStride;
  315. }
  316. }
  317. return pixels;
  318. }
  319. /**
  320. * Returns as int the sample in a specified band for the pixel
  321. * located at (x,y).
  322. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  323. * not in bounds.
  324. * @param x The X coordinate of the pixel location.
  325. * @param y The Y coordinate of the pixel location.
  326. * @param b The band to return.
  327. * @param data The DataBuffer containing the image data.
  328. */
  329. public int getSample(int x, int y, int b, DataBuffer data) {
  330. int sample =
  331. data.getElem(bankIndices[b],
  332. y*scanlineStride + x + bandOffsets[b]);
  333. return sample;
  334. }
  335. /**
  336. * Returns the sample in a specified band
  337. * for the pixel located at (x,y) as a float.
  338. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  339. * not in bounds.
  340. * @param x The X coordinate of the pixel location.
  341. * @param y The Y coordinate of the pixel location.
  342. * @param b The band to return.
  343. * @param data The DataBuffer containing the image data.
  344. */
  345. public float getSampleFloat(int x, int y, int b, DataBuffer data) {
  346. float sample = data.getElemFloat(bankIndices[b],
  347. y*scanlineStride + x + bandOffsets[b]);
  348. return sample;
  349. }
  350. /**
  351. * Returns the sample in a specified band
  352. * for a pixel located at (x,y) as a double.
  353. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  354. * not in bounds.
  355. * @param x The X coordinate of the pixel location.
  356. * @param y The Y coordinate of the pixel location.
  357. * @param b The band to return.
  358. * @param data The DataBuffer containing the image data.
  359. */
  360. public double getSampleDouble(int x, int y, int b, DataBuffer data) {
  361. double sample = data.getElemDouble(bankIndices[b],
  362. y*scanlineStride + x + bandOffsets[b]);
  363. return sample;
  364. }
  365. /**
  366. * Returns the samples in a specified band for the specified rectangle
  367. * of pixels in an int array, one sample per data array element.
  368. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  369. * not in bounds.
  370. * @param x The X coordinate of the upper left pixel location.
  371. * @param y The Y coordinate of the upper left pixel location.
  372. * @param w The width of the pixel rectangle.
  373. * @param h The height of the pixel rectangle.
  374. * @param b The band to return.
  375. * @param iArray If non-null, returns the samples in this array.
  376. * @param data The DataBuffer containing the image data.
  377. */
  378. public int[] getSamples(int x, int y, int w, int h, int b,
  379. int iArray[], DataBuffer data) {
  380. int samples[];
  381. if (iArray != null) {
  382. samples = iArray;
  383. } else {
  384. samples = new int [w*h];
  385. }
  386. int lineOffset = y*scanlineStride + x + bandOffsets[b];
  387. int srcOffset = 0;
  388. int bank = bankIndices[b];
  389. for (int i = 0; i < h; i++) {
  390. int sampleOffset = lineOffset;
  391. for (int j = 0; j < w; j++) {
  392. samples[srcOffset++] = data.getElem(bank, sampleOffset++);
  393. }
  394. lineOffset += scanlineStride;
  395. }
  396. return samples;
  397. }
  398. /**
  399. * Sets the data for a single pixel in the specified DataBuffer from a
  400. * primitive array of type TransferType. For a BandedSampleModel,
  401. * this will be the same as the data type, and samples are transferred
  402. * one per array element.
  403. * <p>
  404. * The following code illustrates transferring data for one pixel from
  405. * DataBuffer <code>db1</code>, whose storage layout is described by
  406. * BandedSampleModel <code>bsm1</code>, to DataBuffer <code>db2</code>,
  407. * whose storage layout is described by
  408. * BandedSampleModel <code>bsm2</code>.
  409. * The transfer will generally be more efficient than using
  410. * getPixel/setPixel.
  411. * <pre>
  412. * BandedSampleModel bsm1, bsm2;
  413. * DataBufferInt db1, db2;
  414. * bsm2.setDataElements(x, y, bsm1.getDataElements(x, y, null, db1),
  415. * db2);
  416. * </pre>
  417. * Using getDataElements/setDataElements to transfer between two
  418. * DataBuffer/SampleModel pairs is legitimate if the SampleModels have
  419. * the same number of bands, corresponding bands have the same number of
  420. * bits per sample, and the TransferTypes are the same.
  421. * <p>
  422. * obj must be a primitive array of type TransferType. Otherwise,
  423. * a ClassCastException is thrown. An
  424. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  425. * not in bounds, or if obj is not large enough to hold the pixel data.
  426. * @param x The X coordinate of the pixel location.
  427. * @param y The Y coordinate of the pixel location.
  428. * @param obj If non-null, returns the primitive array in this object.
  429. * @param data The DataBuffer containing the image data.
  430. */
  431. public void setDataElements(int x, int y, Object obj, DataBuffer data) {
  432. int type = getTransferType();
  433. int numDataElems = getNumDataElements();
  434. int pixelOffset = y*scanlineStride + x;
  435. switch(type) {
  436. case DataBuffer.TYPE_BYTE:
  437. byte[] barray = (byte[])obj;
  438. for (int i=0; i<numDataElems; i++) {
  439. data.setElem(bankIndices[i], pixelOffset + bandOffsets[i],
  440. ((int)barray[i])&0xff);
  441. }
  442. break;
  443. case DataBuffer.TYPE_USHORT:
  444. case DataBuffer.TYPE_SHORT:
  445. short[] sarray = (short[])obj;
  446. for (int i=0; i<numDataElems; i++) {
  447. data.setElem(bankIndices[i], pixelOffset + bandOffsets[i],
  448. ((int)sarray[i])&0xffff);
  449. }
  450. break;
  451. case DataBuffer.TYPE_INT:
  452. int[] iarray = (int[])obj;
  453. for (int i=0; i<numDataElems; i++) {
  454. data.setElem(bankIndices[i], pixelOffset + bandOffsets[i],
  455. iarray[i]);
  456. }
  457. break;
  458. }
  459. }
  460. /**
  461. * Sets a pixel in the DataBuffer using an int array of samples for input.
  462. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  463. * not in bounds.
  464. * @param x The X coordinate of the pixel location.
  465. * @param y The Y coordinate of the pixel location.
  466. * @param iArray The input samples in an int array.
  467. * @param data The DataBuffer containing the image data.
  468. */
  469. public void setPixel(int x, int y, int iArray[], DataBuffer data) {
  470. int pixelOffset = y*scanlineStride + x;
  471. for (int i=0; i<numBands; i++) {
  472. data.setElem(bankIndices[i], pixelOffset + bandOffsets[i],
  473. iArray[i]);
  474. }
  475. }
  476. /**
  477. * Sets all samples for a rectangle of pixels from an int array containing
  478. * one sample per array element.
  479. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  480. * not in bounds.
  481. * @param x The X coordinate of the upper left pixel location.
  482. * @param y The Y coordinate of the upper left pixel location.
  483. * @param w The width of the pixel rectangle.
  484. * @param h The height of the pixel rectangle.
  485. * @param iArray The input samples in an int array.
  486. * @param data The DataBuffer containing the image data.
  487. */
  488. public void setPixels(int x, int y, int w, int h,
  489. int iArray[], DataBuffer data) {
  490. for (int k = 0; k < numBands; k++) {
  491. int lineOffset = y*scanlineStride + x + bandOffsets[k];
  492. int srcOffset = k;
  493. int bank = bankIndices[k];
  494. for (int i = 0; i < h; i++) {
  495. int pixelOffset = lineOffset;
  496. for (int j = 0; j < w; j++) {
  497. data.setElem(bank, pixelOffset++, iArray[srcOffset]);
  498. srcOffset += numBands;
  499. }
  500. lineOffset += scanlineStride;
  501. }
  502. }
  503. }
  504. /**
  505. * Sets a sample in the specified band for the pixel located at (x,y)
  506. * in the DataBuffer using an int for input.
  507. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  508. * not in bounds.
  509. * @param x The X coordinate of the pixel location.
  510. * @param y The Y coordinate of the pixel location.
  511. * @param b The band to set.
  512. * @param s The input sample as an int.
  513. * @param data The DataBuffer containing the image data.
  514. */
  515. public void setSample(int x, int y, int b, int s,
  516. DataBuffer data) {
  517. data.setElem(bankIndices[b],
  518. y*scanlineStride + x + bandOffsets[b], s);
  519. }
  520. /**
  521. * Sets a sample in the specified band for the pixel located at (x,y)
  522. * in the DataBuffer using a float for input.
  523. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  524. * not in bounds.
  525. * @param x The X coordinate of the pixel location.
  526. * @param y The Y coordinate of the pixel location.
  527. * @param b The band to set.
  528. * @param s The input sample as a float.
  529. * @param data The DataBuffer containing the image data.
  530. */
  531. public void setSample(int x, int y, int b,
  532. float s ,
  533. DataBuffer data) {
  534. data.setElemFloat(bankIndices[b],
  535. y*scanlineStride + x + bandOffsets[b], s);
  536. }
  537. /**
  538. * Sets a sample in the specified band for the pixel located at (x,y)
  539. * in the DataBuffer using a double for input.
  540. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  541. * not in bounds.
  542. * @param x The X coordinate of the pixel location.
  543. * @param y The Y coordinate of the pixel location.
  544. * @param b The band to set.
  545. * @param s The input sample as a double.
  546. * @param data The DataBuffer containing the image data.
  547. */
  548. public void setSample(int x, int y, int b,
  549. double s,
  550. DataBuffer data) {
  551. data.setElemDouble(bankIndices[b],
  552. y*scanlineStride + x + bandOffsets[b], s);
  553. }
  554. /**
  555. * Sets the samples in the specified band for the specified rectangle
  556. * of pixels from an int array containing one sample per data array element.
  557. * ArrayIndexOutOfBoundsException may be thrown if the coordinates are
  558. * not in bounds.
  559. * @param x The X coordinate of the upper left pixel location.
  560. * @param y The Y coordinate of the upper left pixel location.
  561. * @param w The width of the pixel rectangle.
  562. * @param h The height of the pixel rectangle.
  563. * @param b The band to set.
  564. * @param iArray The input sample array.
  565. * @param data The DataBuffer containing the image data.
  566. */
  567. public void setSamples(int x, int y, int w, int h, int b,
  568. int iArray[], DataBuffer data) {
  569. int lineOffset = y*scanlineStride + x + bandOffsets[b];
  570. int srcOffset = 0;
  571. int bank = bankIndices[b];
  572. for (int i = 0; i < h; i++) {
  573. int sampleOffset = lineOffset;
  574. for (int j = 0; j < w; j++) {
  575. data.setElem(bank, sampleOffset++, iArray[srcOffset++]);
  576. }
  577. lineOffset += scanlineStride;
  578. }
  579. }
  580. private static int[] createOffsetArray(int numBands) {
  581. int[] bandOffsets = new int[numBands];
  582. for (int i=0; i < numBands; i++) {
  583. bandOffsets[i] = 0;
  584. }
  585. return bandOffsets;
  586. }
  587. private static int[] createIndiciesArray(int numBands) {
  588. int[] bankIndicies = new int[numBands];
  589. for (int i=0; i < numBands; i++) {
  590. bankIndicies[i] = i;
  591. }
  592. return bankIndicies;
  593. }
  594. }