< prev index next >

src/java.desktop/share/classes/java/awt/image/LookupOp.java

Print this page




 455      *         corresponds to the specified point in the source.
 456      */
 457     public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) {
 458         if (dstPt == null) {
 459             dstPt = new Point2D.Float();
 460         }
 461         dstPt.setLocation(srcPt.getX(), srcPt.getY());
 462 
 463         return dstPt;
 464     }
 465 
 466     /**
 467      * Returns the rendering hints for this op.
 468      * @return the {@code RenderingHints} object associated
 469      *         with this op.
 470      */
 471     public final RenderingHints getRenderingHints() {
 472         return hints;
 473     }
 474 
 475     private final void byteFilter(ByteLookupTable lookup, Raster src,
 476                                   WritableRaster dst,
 477                                   int width, int height, int numBands) {
 478         int[] srcPix = null;
 479 
 480         // Find the ref to the table and the offset
 481         byte[][] table = lookup.getTable();
 482         int offset = lookup.getOffset();
 483         int tidx;
 484         int step=1;
 485 
 486         // Check if it is one lookup applied to all bands
 487         if (table.length == 1) {
 488             step=0;
 489         }
 490 
 491         int x;
 492         int y;
 493         int band;
 494         int len = table[0].length;
 495 


 502 
 503                 for ( x=0; x < width; x++) {
 504                     int index = srcPix[x]-offset;
 505                     if (index < 0 || index > len) {
 506                         throw new
 507                             IllegalArgumentException("index ("+index+
 508                                                      "(out of range: "+
 509                                                      " srcPix["+x+
 510                                                      "]="+ srcPix[x]+
 511                                                      " offset="+ offset);
 512                     }
 513                     // Do the lookup
 514                     srcPix[x] = table[tidx][index];
 515                 }
 516                 // Put it back
 517                 dst.setSamples(0, y, width, 1, band, srcPix);
 518             }
 519         }
 520     }
 521 
 522     private final void shortFilter(ShortLookupTable lookup, Raster src,
 523                                    WritableRaster dst,
 524                                    int width, int height, int numBands) {
 525         int band;
 526         int[] srcPix = null;
 527 
 528         // Find the ref to the table and the offset
 529         short[][] table = lookup.getTable();
 530         int offset = lookup.getOffset();
 531         int tidx;
 532         int step=1;
 533 
 534         // Check if it is one lookup applied to all bands
 535         if (table.length == 1) {
 536             step=0;
 537         }
 538 
 539         int x = 0;
 540         int y = 0;
 541         int index;
 542         int maxShort = (1<<16)-1;




 455      *         corresponds to the specified point in the source.
 456      */
 457     public final Point2D getPoint2D (Point2D srcPt, Point2D dstPt) {
 458         if (dstPt == null) {
 459             dstPt = new Point2D.Float();
 460         }
 461         dstPt.setLocation(srcPt.getX(), srcPt.getY());
 462 
 463         return dstPt;
 464     }
 465 
 466     /**
 467      * Returns the rendering hints for this op.
 468      * @return the {@code RenderingHints} object associated
 469      *         with this op.
 470      */
 471     public final RenderingHints getRenderingHints() {
 472         return hints;
 473     }
 474 
 475     private void byteFilter(ByteLookupTable lookup, Raster src,
 476                                   WritableRaster dst,
 477                                   int width, int height, int numBands) {
 478         int[] srcPix = null;
 479 
 480         // Find the ref to the table and the offset
 481         byte[][] table = lookup.getTable();
 482         int offset = lookup.getOffset();
 483         int tidx;
 484         int step=1;
 485 
 486         // Check if it is one lookup applied to all bands
 487         if (table.length == 1) {
 488             step=0;
 489         }
 490 
 491         int x;
 492         int y;
 493         int band;
 494         int len = table[0].length;
 495 


 502 
 503                 for ( x=0; x < width; x++) {
 504                     int index = srcPix[x]-offset;
 505                     if (index < 0 || index > len) {
 506                         throw new
 507                             IllegalArgumentException("index ("+index+
 508                                                      "(out of range: "+
 509                                                      " srcPix["+x+
 510                                                      "]="+ srcPix[x]+
 511                                                      " offset="+ offset);
 512                     }
 513                     // Do the lookup
 514                     srcPix[x] = table[tidx][index];
 515                 }
 516                 // Put it back
 517                 dst.setSamples(0, y, width, 1, band, srcPix);
 518             }
 519         }
 520     }
 521 
 522     private void shortFilter(ShortLookupTable lookup, Raster src,
 523                                    WritableRaster dst,
 524                                    int width, int height, int numBands) {
 525         int band;
 526         int[] srcPix = null;
 527 
 528         // Find the ref to the table and the offset
 529         short[][] table = lookup.getTable();
 530         int offset = lookup.getOffset();
 531         int tidx;
 532         int step=1;
 533 
 534         // Check if it is one lookup applied to all bands
 535         if (table.length == 1) {
 536             step=0;
 537         }
 538 
 539         int x = 0;
 540         int y = 0;
 541         int index;
 542         int maxShort = (1<<16)-1;


< prev index next >