Class DesignerSnapshotCompare

java.lang.Object
com.iizigo.panel.DesignerSnapshotCompare

public final class DesignerSnapshotCompare extends Object
Pure pixel functions over ImageData used by the Panel Designer refresh: detection of a failed capture (an image of one colour) and the before/after comparison of two captures. No SWT resources are created, so the functions can be unit tested directly.
Author:
Christopher Mindus
  • Method Details

    • isUniform

      public static boolean isUniform(ImageData d)
      Checks if an image is empty or of one colour, which is what a failed capture of a GPU-composited browser produces. A grid of at most 64 by 64 sample points is inspected.
      Parameters:
      d - The image data, may be null.
      Returns:
      true when the image is null, empty or all sampled pixels are equal.
    • compare

      public static DesignerSnapshotCompare.Result compare(ImageData a, ImageData b, boolean createMask)
      Compares two captures pixel by pixel. The captures must have the same size; when their pixel formats differ the comparison is made on the RGB values, otherwise on the raw pixel values. Alpha is ignored.
      Parameters:
      a - The "before" image data, may be null.
      b - The "after" image data, may be null.
      createMask - Flag to build the difference mask image.
      Returns:
      The result; isComparable is false with a reason when a capture is missing or the sizes differ.