Package 

Class Clip


  • 
    public class Clip
    
                        

    Extract rectangular regions.

    • Method Summary

      Modifier and Type Method Description
      static Pix clipRectangle(Pix source, Box box) Extract a region from a Pix.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • clipRectangle

         static Pix clipRectangle(Pix source, Box box)

        Extract a region from a Pix.

        Notes:

        This should be simple, but there are choices to be made. The box isdefined relative to the pix coordinates. However, if the box is notcontained within the pix, we have two choices:

        (1) clip the box to the pix

        (2) make a new pix equal to the full box dimensions,but let rasterop do the clipping and positioningof the src with respect to the dest

        Choice (2) immediately brings up the problem of what pixel valuesto use that were not taken from the src. For example, on a grayscaleimage, do you want the pixels not taken from the src to be blackor white or something else? To implement choice 2, one needs tospecify the color of these extra pixels.

        So we adopt (1), and clip the box first, if necessary,before making the dest pix and doing the rasterop. But thereis another issue to consider. If you want to paste theclipped pix back into pixs, it must be properly aligned, andit is necessary to use the clipped box for alignment.

        Parameters:
        source - Source pix
        box - Requested clipping region