KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > ext > awt > image > rendered > AbstractRed


1 /*
2
3    Copyright 2001,2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.ext.awt.image.rendered;
19
20 import java.awt.Point JavaDoc;
21 import java.awt.Rectangle JavaDoc;
22 import java.awt.Shape JavaDoc;
23 import java.awt.Transparency JavaDoc;
24 import java.awt.color.ColorSpace JavaDoc;
25 import java.awt.image.ColorModel JavaDoc;
26 import java.awt.image.ComponentColorModel JavaDoc;
27 import java.awt.image.DataBuffer JavaDoc;
28 import java.awt.image.Raster JavaDoc;
29 import java.awt.image.RenderedImage JavaDoc;
30 import java.awt.image.SampleModel JavaDoc;
31 import java.awt.image.WritableRaster JavaDoc;
32 import java.util.HashMap JavaDoc;
33 import java.util.Iterator JavaDoc;
34 import java.util.List JavaDoc;
35 import java.util.Map JavaDoc;
36 import java.util.Set JavaDoc;
37 import java.util.Vector JavaDoc;
38
39 import org.apache.batik.ext.awt.image.GraphicsUtil;
40
41
42 // import org.apache.batik.ext.awt.image.DataBufferReclaimer;
43
// import java.awt.image.DataBufferInt;
44
// import java.awt.image.SinglePixelPackedSampleModel;
45

46
47 /**
48  * This is an abstract base class that takes care of most of the
49  * normal issues surrounding the implementation of the CachableRed
50  * (RenderedImage) interface. It tries to make no assumptions about
51  * the subclass implementation.
52  *
53  * @author <a HREF="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
54  * @version $Id: AbstractRed.java,v 1.12 2005/03/27 08:58:33 cam Exp $
55  */

56 public abstract class AbstractRed implements CachableRed {
57
58     protected Rectangle JavaDoc bounds;
59     protected Vector JavaDoc srcs;
60     protected Map JavaDoc props;
61     protected SampleModel JavaDoc sm;
62     protected ColorModel JavaDoc cm;
63     protected int tileGridXOff, tileGridYOff;
64     protected int tileWidth, tileHeight;
65     protected int minTileX, minTileY;
66     protected int numXTiles, numYTiles;
67
68     /**
69      * void constructor. The subclass must call one of the
70      * flavors of init before the object becomes usable.
71      * This is useful when the proper parameters to the init
72      * method need to be computed in the subclasses constructor.
73      */

74     protected AbstractRed() {
75     }
76
77
78     /**
79      * Construct an Abstract RenderedImage from a bounds rect and props
80      * (may be null). The srcs Vector will be empty.
81      * @param bounds this defines the extent of the rable in the
82      * user coordinate system.
83      * @param props this initializes the props Map (may be null)
84      */

85     protected AbstractRed(Rectangle JavaDoc bounds, Map JavaDoc props) {
86         init((CachableRed)null, bounds, null, null,
87              bounds.x, bounds.y, props);
88     }
89
90     /**
91      * Construct an Abstract RenderedImage from a source image and
92      * props (may be null).
93      * @param src will be the first (and only) member of the srcs
94      * Vector. Src is also used to set the bounds, ColorModel,
95      * SampleModel, and tile grid offsets.
96      * @param props this initializes the props Map. */

97     protected AbstractRed(CachableRed src, Map JavaDoc props) {
98         init(src, src.getBounds(), src.getColorModel(), src.getSampleModel(),
99              (src==null)?0:src.getTileGridXOffset(),
100              (src==null)?0:src.getTileGridYOffset(),
101              props);
102     }
103
104     /**
105      * Construct an Abstract RenderedImage from a source image, bounds
106      * rect and props (may be null).
107      * @param src will be the first (and only) member of the srcs
108      * Vector. Src is also used to set the ColorModel, SampleModel,
109      * and tile grid offsets.
110      * @param bounds The bounds of this image.
111      * @param props this initializes the props Map. */

112     protected AbstractRed(CachableRed src, Rectangle JavaDoc bounds, Map JavaDoc props) {
113         init(src, bounds, src.getColorModel(), src.getSampleModel(),
114              (src==null)?0:src.getTileGridXOffset(),
115              (src==null)?0:src.getTileGridYOffset(),
116              props);
117     }
118
119     /**
120      * Construct an Abstract RenderedImage from a source image, bounds
121      * rect and props (may be null).
122      * @param src will be the first (and only) member of the srcs
123      * Vector. Src is also used to set the ColorModel, SampleModel,
124      * and tile grid offsets.
125      * @param bounds The bounds of this image.
126      * @param cm The ColorModel to use. If null it will default to
127      * ComponentColorModel.
128      * @param sm The sample model to use. If null it will construct
129      * a sample model the matches the given/generated ColorModel and is
130      * the size of bounds.
131      * @param props this initializes the props Map. */

132     protected AbstractRed(CachableRed src, Rectangle JavaDoc bounds,
133                           ColorModel JavaDoc cm, SampleModel JavaDoc sm,
134                           Map JavaDoc props) {
135         init(src, bounds, cm, sm,
136              (src==null)?0:src.getTileGridXOffset(),
137              (src==null)?0:src.getTileGridYOffset(),
138              props);
139     }
140
141     /**
142      * Construct an Abstract Rable from a bounds rect and props
143      * (may be null). The srcs Vector will be empty.
144      * @param src will be the first (and only) member of the srcs
145      * Vector. Src is also used to set the ColorModel, SampleModel,
146      * and tile grid offsets.
147      * @param bounds this defines the extent of the rable in the
148      * user coordinate system.
149      * @param cm The ColorModel to use. If null it will default to
150      * ComponentColorModel.
151      * @param sm The sample model to use. If null it will construct
152      * a sample model the matches the given/generated ColorModel and is
153      * the size of bounds.
154      * @param tileGridXOff The x location of tile 0,0.
155      * @param tileGridYOff The y location of tile 0,0.
156      * @param props this initializes the props Map.
157      */

158     protected AbstractRed(CachableRed src, Rectangle JavaDoc bounds,
159                           ColorModel JavaDoc cm, SampleModel JavaDoc sm,
160                           int tileGridXOff, int tileGridYOff,
161                           Map JavaDoc props) {
162         init(src, bounds, cm, sm, tileGridXOff, tileGridYOff, props);
163     }
164
165     /**
166      * This is one of two basic init function (this is for single
167      * source rendereds).
168      * It is provided so subclasses can compute various values
169      * before initializing all the state in the base class.
170      * You really should call this method before returning from
171      * your subclass constructor.
172      *
173      * @param src The source for the filter
174      * @param bounds The bounds of the image
175      * @param cm The ColorModel to use. If null it defaults to
176      * ComponentColorModel/ src's ColorModel.
177      * @param sm The Sample modle to use. If this is null it will
178      * use the src's sample model if that is null it will
179      * construct a sample model that matches the ColorModel
180      * and is the size of the whole image.
181      * @param tileGridXOff The x location of tile 0,0.
182      * @param tileGridYOff The y location of tile 0,0.
183      * @param props Any properties you want to associate with the image.
184      */

185     protected void init(CachableRed src, Rectangle JavaDoc bounds,
186                         ColorModel JavaDoc cm, SampleModel JavaDoc sm,
187                         int tileGridXOff, int tileGridYOff,
188                         Map JavaDoc props) {
189         this.srcs = new Vector JavaDoc(1);
190         if (src != null) {
191             this.srcs.add(src);
192             if (bounds == null) bounds = src.getBounds();
193             if (cm == null) cm = src.getColorModel();
194             if (sm == null) sm = src.getSampleModel();
195         }
196
197         this.bounds = bounds;
198         this.tileGridXOff = tileGridXOff;
199         this.tileGridYOff = tileGridYOff;
200
201         this.props = new HashMap JavaDoc();
202         if(props != null){
203             this.props.putAll(props);
204         }
205
206         if (cm == null)
207             cm = new ComponentColorModel JavaDoc
208                 (ColorSpace.getInstance(ColorSpace.CS_GRAY),
209                  new int [] { 8 }, false, false, Transparency.OPAQUE,
210                  DataBuffer.TYPE_BYTE);
211
212         this.cm = cm;
213
214         if (sm == null)
215             sm = cm.createCompatibleSampleModel(bounds.width, bounds.height);
216         this.sm = sm;
217
218         // Recompute tileWidth/Height, minTileX/Y, numX/YTiles.
219
updateTileGridInfo();
220     }
221
222     /**
223      * Construct an Abstract Rable from a List of sources a bounds rect
224      * and props (may be null).
225      * @param srcs This is used to initialize the srcs Vector. All
226      * the members of srcs must be CachableRed otherwise an error
227      * will be thrown.
228      * @param bounds this defines the extent of the rendered in pixels
229      * @param props this initializes the props Map.
230      */

231     protected AbstractRed(List JavaDoc srcs, Rectangle JavaDoc bounds, Map JavaDoc props) {
232         init(srcs, bounds, null, null, bounds.x, bounds.y, props);
233     }
234
235     /**
236      * Construct an Abstract RenderedImage from a bounds rect,
237      * ColorModel (may be null), SampleModel (may be null) and props
238      * (may be null). The srcs Vector will be empty.
239      * @param srcs This is used to initialize the srcs Vector. All
240      * the members of srcs must be CachableRed otherwise an error
241      * will be thrown.
242      * @param bounds this defines the extent of the rendered in pixels
243      * @param cm The ColorModel to use. If null it will default to
244      * ComponentColorModel.
245      * @param sm The sample model to use. If null it will construct
246      * a sample model the matches the given/generated ColorModel and is
247      * the size of bounds.
248      * @param props this initializes the props Map.
249      */

250     protected AbstractRed(List JavaDoc srcs, Rectangle JavaDoc bounds,
251                           ColorModel JavaDoc cm, SampleModel JavaDoc sm,
252                           Map JavaDoc props) {
253         init(srcs, bounds, cm, sm, bounds.x, bounds.y, props);
254     }
255
256     /**
257      * Construct an Abstract RenderedImage from a bounds rect,
258      * ColorModel (may be null), SampleModel (may be null), tile grid
259      * offsets and props (may be null). The srcs Vector will be
260      * empty.
261      * @param srcs This is used to initialize the srcs Vector. All
262      * the members of srcs must be CachableRed otherwise an error
263      * will be thrown.
264      * @param bounds this defines the extent of the rable in the
265      * user coordinate system.
266      * @param cm The ColorModel to use. If null it will default to
267      * ComponentColorModel.
268      * @param sm The sample model to use. If null it will construct
269      * a sample model the matches the given/generated ColorModel and is
270      * the size of bounds.
271      * @param tileGridXOff The x location of tile 0,0.
272      * @param tileGridYOff The y location of tile 0,0.
273      * @param props this initializes the props Map.
274      */

275     protected AbstractRed(List JavaDoc srcs, Rectangle JavaDoc bounds,
276                           ColorModel JavaDoc cm, SampleModel JavaDoc sm,
277                           int tileGridXOff, int tileGridYOff,
278                           Map JavaDoc props) {
279         init(srcs, bounds, cm, sm, tileGridXOff, tileGridYOff, props);
280     }
281
282     /**
283      * This is the basic init function.
284      * It is provided so subclasses can compute various values
285      * before initializing all the state in the base class.
286      * You really should call this method before returning from
287      * your subclass constructor.
288      *
289      * @param srcs The list of sources
290      * @param bounds The bounds of the image
291      * @param cm The ColorModel to use. If null it defaults to
292      * ComponentColorModel.
293      * @param sm The Sample modle to use. If this is null it will
294      * construct a sample model that matches the ColorModel
295      * and is the size of the whole image.
296      * @param tileGridXOff The x location of tile 0,0.
297      * @param tileGridYOff The y location of tile 0,0.
298      * @param props Any properties you want to associate with the image.
299      */

300     protected void init(List JavaDoc srcs, Rectangle JavaDoc bounds,
301                         ColorModel JavaDoc cm, SampleModel JavaDoc sm,
302                         int tileGridXOff, int tileGridYOff,
303                         Map JavaDoc props) {
304         this.srcs = new Vector JavaDoc();
305         if(srcs != null){
306             this.srcs.addAll(srcs);
307         }
308
309         if (srcs.size() != 0) {
310             CachableRed src = (CachableRed)srcs.get(0);
311             if (bounds == null) bounds = src.getBounds();
312             if (cm == null) cm = src.getColorModel();
313             if (sm == null) sm = src.getSampleModel();
314         }
315
316         this.bounds = bounds;
317         this.tileGridXOff = tileGridXOff;
318         this.tileGridYOff = tileGridYOff;
319         this.props = new HashMap JavaDoc();
320         if(props != null){
321             this.props.putAll(props);
322         }
323
324         if (cm == null)
325             cm = new ComponentColorModel JavaDoc
326                 (ColorSpace.getInstance(ColorSpace.CS_GRAY),
327                  new int [] { 8 }, false, false, Transparency.OPAQUE,
328                  DataBuffer.TYPE_BYTE);
329
330         this.cm = cm;
331
332         if (sm == null)
333             sm = cm.createCompatibleSampleModel(bounds.width, bounds.height);
334         this.sm = sm;
335
336         // Recompute tileWidth/Height, minTileX/Y, numX/YTiles.
337
updateTileGridInfo();
338     }
339
340     /**
341      * This function computes all the basic information about the tile
342      * grid based on the data stored in sm, and tileGridX/YOff.
343      * It is responsible for updating tileWidth, tileHeight,
344      * minTileX/Y, and numX/YTiles.
345      */

346     protected void updateTileGridInfo() {
347         this.tileWidth = sm.getWidth();
348         this.tileHeight = sm.getHeight();
349
350         int x1, y1, maxTileX, maxTileY;
351
352         // This computes and caches important information about the
353
// structure of the tile grid in general.
354
minTileX = getXTile(bounds.x);
355         minTileY = getYTile(bounds.y);
356
357         x1 = bounds.x + bounds.width-1; // Xloc of right edge
358
maxTileX = getXTile(x1);
359         numXTiles = maxTileX-minTileX+1;
360
361         y1 = bounds.y + bounds.height-1; // Yloc of right edge
362
maxTileY = getYTile(y1);
363         numYTiles = maxTileY-minTileY+1;
364     }
365
366
367     public Rectangle JavaDoc getBounds() {
368         return new Rectangle JavaDoc(getMinX(),
369                              getMinY(),
370                              getWidth(),
371                              getHeight());
372     }
373
374     public Vector JavaDoc getSources() {
375         return srcs;
376     }
377
378     public ColorModel JavaDoc getColorModel() {
379         return cm;
380     }
381
382     public SampleModel JavaDoc getSampleModel() {
383         return sm;
384     }
385
386     public int getMinX() {
387         return bounds.x;
388     }
389     public int getMinY() {
390         return bounds.y;
391     }
392
393     public int getWidth() {
394         return bounds.width;
395     }
396
397     public int getHeight() {
398         return bounds.height;
399     }
400
401     public int getTileWidth() {
402         return tileWidth;
403     }
404
405     public int getTileHeight() {
406         return tileHeight;
407     }
408
409     public int getTileGridXOffset() {
410         return tileGridXOff;
411     }
412
413     public int getTileGridYOffset() {
414         return tileGridYOff;
415     }
416
417     public int getMinTileX() {
418         return minTileX;
419     }
420
421     public int getMinTileY() {
422         return minTileY;
423     }
424
425     public int getNumXTiles() {
426         return numXTiles;
427     }
428
429     public int getNumYTiles() {
430         return numYTiles;
431     }
432
433     public Object JavaDoc getProperty(String JavaDoc name) {
434         Object JavaDoc ret = props.get(name);
435         if (ret != null) return ret;
436         Iterator JavaDoc i = srcs.iterator();
437         while (i.hasNext()) {
438             RenderedImage JavaDoc ri = (RenderedImage JavaDoc)i.next();
439             ret = ri.getProperty(name);
440             if (ret != null) return ret;
441         }
442         return null;
443     }
444
445     public String JavaDoc [] getPropertyNames() {
446         Set JavaDoc keys = props.keySet();
447         Iterator JavaDoc iter = keys.iterator();
448         String JavaDoc [] ret = new String JavaDoc[keys.size()];
449         int i=0;
450         while (iter.hasNext()) {
451             ret[i++] = (String JavaDoc)iter.next();
452         }
453
454         iter = srcs.iterator();
455         while (iter.hasNext()) {
456             RenderedImage JavaDoc ri = (RenderedImage JavaDoc)iter.next();
457             String JavaDoc [] srcProps = ri.getPropertyNames();
458             if (srcProps.length != 0) {
459                 String JavaDoc [] tmp = new String JavaDoc[ret.length+srcProps.length];
460                 System.arraycopy(tmp,0,tmp,0,ret.length);
461                 System.arraycopy(tmp,ret.length,srcProps,0,srcProps.length);
462                 ret = tmp;
463             }
464         }
465
466         return ret;
467     }
468
469     public Shape JavaDoc getDependencyRegion(int srcIndex, Rectangle JavaDoc outputRgn) {
470         if ((srcIndex < 0) || (srcIndex > srcs.size()))
471             throw new IndexOutOfBoundsException JavaDoc
472                 ("Nonexistant source requested.");
473
474         // Return empty rect if they don't intersect.
475
if (outputRgn.intersects(bounds) == false)
476             return new Rectangle JavaDoc();
477
478         // We only depend on our source for stuff that is inside
479
// our bounds...
480
return outputRgn.intersection(bounds);
481     }
482
483     public Shape JavaDoc getDirtyRegion(int srcIndex, Rectangle JavaDoc inputRgn) {
484         if (srcIndex != 0)
485             throw new IndexOutOfBoundsException JavaDoc
486                 ("Nonexistant source requested.");
487
488         // Return empty rect if they don't intersect.
489
if (inputRgn.intersects(bounds) == false)
490             return new Rectangle JavaDoc();
491
492         // Changes in the input region don't propogate outside our
493
// bounds.
494
return inputRgn.intersection(bounds);
495     }
496
497
498     // This is not included but can be implemented by the following.
499
// In which case you _must_ reimplement getTile.
500
// public WritableRaster copyData(WritableRaster wr) {
501
// copyToRaster(wr);
502
// return wr;
503
// }
504

505     public Raster JavaDoc getTile(int tileX, int tileY) {
506         WritableRaster JavaDoc wr = makeTile(tileX, tileY);
507         return copyData(wr);
508     }
509
510     public Raster JavaDoc getData() {
511         return getData(bounds);
512     }
513
514     public Raster JavaDoc getData(Rectangle JavaDoc rect) {
515         SampleModel JavaDoc smRet = sm.createCompatibleSampleModel
516             (rect.width, rect.height);
517
518         Point JavaDoc pt = new Point JavaDoc(rect.x, rect.y);
519         WritableRaster JavaDoc wr = Raster.createWritableRaster(smRet, pt);
520
521         // System.out.println("GD DB: " + wr.getDataBuffer().getSize());
522
return copyData(wr);
523     }
524
525     /**
526      * Returns the x index of tile under xloc.
527      * @param xloc the x location (in pixels) to get tile for.
528      * @return The tile index under xloc (may be outside tile grid).
529      */

530     public final int getXTile(int xloc) {
531         int tgx = xloc-tileGridXOff;
532         // We need to round to -infinity...
533
if (tgx>=0)
534             return tgx/tileWidth;
535         else
536             return (tgx-tileWidth+1)/tileWidth;
537     }
538
539     /**
540      * Returns the y index of tile under yloc.
541      * @param yloc the y location (in pixels) to get tile for.
542      * @return The tile index under yloc (may be outside tile grid).
543      */

544     public final int getYTile(int yloc) {
545         int tgy = yloc-tileGridYOff;
546         // We need to round to -infinity...
547
if (tgy>=0)
548             return tgy/tileHeight;
549         else
550             return (tgy-tileHeight+1)/tileHeight;
551     }
552
553     /**
554      * Copies data from this images tile grid into wr. wr may
555      * extend outside the bounds of this image in which case the
556      * data in wr outside the bounds will not be touched.
557      * @param wr Raster to fill with image data.
558      */

559     public void copyToRaster(WritableRaster JavaDoc wr) {
560         int tx0 = getXTile(wr.getMinX());
561         int ty0 = getYTile(wr.getMinY());
562         int tx1 = getXTile(wr.getMinX()+wr.getWidth() -1);
563         int ty1 = getYTile(wr.getMinY()+wr.getHeight()-1);
564
565         if (tx0 < minTileX) tx0 = minTileX;
566         if (ty0 < minTileY) ty0 = minTileY;
567
568         if (tx1 >= minTileX+numXTiles) tx1 = minTileX+numXTiles-1;
569         if (ty1 >= minTileY+numYTiles) ty1 = minTileY+numYTiles-1;
570
571         final boolean is_INT_PACK =
572             GraphicsUtil.is_INT_PACK_Data(getSampleModel(), false);
573
574         for (int y=ty0; y<=ty1; y++)
575             for (int x=tx0; x<=tx1; x++) {
576                 Raster JavaDoc r = getTile(x, y);
577                 if (is_INT_PACK)
578                     GraphicsUtil.copyData_INT_PACK(r, wr);
579                 else
580                     GraphicsUtil.copyData_FALLBACK(r, wr);
581             }
582     }
583
584
585     // static DataBufferReclaimer reclaim = new DataBufferReclaimer();
586

587     /**
588      * This is a helper function that will create the tile requested
589      * Including properly subsetting the bounds of the tile to the
590      * bounds of the current image.
591      * @param tileX The x index of the tile to be built
592      * @param tileY The y index of the tile to be built
593      * @return The tile requested
594      * @exception IndexOutOfBoundsException if the requested tile index
595      * falles outside of the bounds of the tile grid for the image.
596      */

597     public WritableRaster JavaDoc makeTile(int tileX, int tileY) {
598         if ((tileX < minTileX) || (tileX >= minTileX+numXTiles) ||
599             (tileY < minTileY) || (tileY >= minTileY+numYTiles))
600             throw new IndexOutOfBoundsException JavaDoc
601                 ("Requested Tile (" + tileX + "," + tileY +
602                  ") lies outside the bounds of image");
603
604         Point JavaDoc pt = new Point JavaDoc(tileGridXOff+tileX*tileWidth,
605                              tileGridYOff+tileY*tileHeight);
606
607         WritableRaster JavaDoc wr;
608         wr = Raster.createWritableRaster(sm, pt);
609         // if (!(sm instanceof SinglePixelPackedSampleModel))
610
// wr = Raster.createWritableRaster(sm, pt);
611
// else {
612
// SinglePixelPackedSampleModel sppsm;
613
// sppsm = (SinglePixelPackedSampleModel)sm;
614
// int stride = sppsm.getScanlineStride();
615
// int sz = stride*sppsm.getHeight();
616
//
617
// int [] data = reclaim.request(sz);
618
// DataBuffer db = new DataBufferInt(data, sz);
619
//
620
// reclaim.register(db);
621
//
622
// wr = Raster.createWritableRaster(sm, db, pt);
623
// }
624

625         // System.out.println("MT DB: " + wr.getDataBuffer().getSize());
626

627         int x0 = wr.getMinX();
628         int y0 = wr.getMinY();
629         int x1 = x0+wr.getWidth() -1;
630         int y1 = y0+wr.getHeight()-1;
631
632         if ((x0 < bounds.x) || (x1 >= (bounds.x+bounds.width)) ||
633             (y0 < bounds.y) || (y1 >= (bounds.y+bounds.height))) {
634             // Part of this raster lies outside our bounds so subset
635
// it so it only advertises the stuff inside our bounds.
636
if (x0 < bounds.x) x0 = bounds.x;
637             if (y0 < bounds.y) y0 = bounds.y;
638             if (x1 >= (bounds.x+bounds.width)) x1 = bounds.x+bounds.width-1;
639             if (y1 >= (bounds.y+bounds.height)) y1 = bounds.y+bounds.height-1;
640
641             wr = wr.createWritableChild(x0, y0, x1-x0+1, y1-y0+1,
642                                         x0, y0, null);
643         }
644         return wr;
645     }
646
647     public static void copyBand(Raster JavaDoc src, int srcBand,
648                                 WritableRaster JavaDoc dst, int dstBand) {
649         Rectangle JavaDoc srcR = new Rectangle JavaDoc(src.getMinX(), src.getMinY(),
650                                        src.getWidth(), src.getHeight());
651         Rectangle JavaDoc dstR = new Rectangle JavaDoc(dst.getMinX(), dst.getMinY(),
652                                        dst.getWidth(), dst.getHeight());
653
654         Rectangle JavaDoc cpR = srcR.intersection(dstR);
655
656         int [] samples = null;
657         for (int y=cpR.y; y< cpR.y+cpR.height; y++) {
658             samples = src.getSamples(cpR.x, y, cpR.width, 1, srcBand, samples);
659             dst.setSamples(cpR.x, y, cpR.width, 1, dstBand, samples);
660         }
661     }
662 }
663
664
Popular Tags