Class DesignerSnapshotCompare
java.lang.Object
com.iizigo.panel.DesignerSnapshotCompare
Pure pixel functions over
ImageData used by the Panel Designer refresh: detection of a failed capture (an image of one color) and the before/after comparison of two captures. No SWT resources are created, so the functions can be unit tested directly.- Author:
- Christopher Mindus
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe result of a comparison.Method Summary
Modifier and TypeMethodDescriptionCompares two captures pixel by pixel.Compares two captures pixel by pixel ascompare(ImageData,ImageData,boolean)does, leaving out the pixels inside the given rectangles: a pixel that differs there is counted inDesignerSnapshotCompare.Result.ignored, not inDesignerSnapshotCompare.Result.differing, and is neither in the box nor in the mask.compareRefresh(ImageData before, Object volatileBefore, ImageData after, Object volatileAfter, int monitorZoom, boolean createMask) Compares the BEFORE and the AFTER capture of a refresh of the Panel Designer, leaving out what the page paints for the pointer or for a moment and not for the panel: the pointer's cross hair and its marks in the rulers, the hover of the component or the mark under the pointer, a flash.static booleanChecks if an image is empty or of one color, which is what a failed capture of a GPU-composited browser produces.
Method Details
isUniform
Checks if an image is empty or of one color, 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
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;
isComparableis false with a reason when a capture is missing or the sizes differ.
compare
public static DesignerSnapshotCompare.Result compare(ImageData a, ImageData b, boolean createMask, Rectangle[] ignore) Compares two captures pixel by pixel ascompare(ImageData,ImageData,boolean)does, leaving out the pixels inside the given rectangles: a pixel that differs there is counted inDesignerSnapshotCompare.Result.ignored, not inDesignerSnapshotCompare.Result.differing, and is neither in the box nor in the mask.- 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.ignore- The rectangles to leave out, in image pixels, null or empty for none.- Returns:
- The result;
isComparableis false with a reason when a capture is missing or the sizes differ.
compareRefresh
public static DesignerSnapshotCompare.Result compareRefresh(ImageData before, Object volatileBefore, ImageData after, Object volatileAfter, int monitorZoom, boolean createMask) Compares the BEFORE and the AFTER capture of a refresh of the Panel Designer, leaving out what the page paints for the pointer or for a moment and not for the panel: the pointer's cross hair and its marks in the rulers, the hover of the component or the mark under the pointer, a flash. The page names those rectangles at each capture (izDesigner.getVolatileRects()ofiz/designer/paint.js). A rectangle named at ONE capture and not, the same, at the other is left out - of either capture: the pointer is somewhere else in each. A rectangle named the same at both is painted the same in both and is compared like everything else, so a pointer that rests in a container does not hide that container from the check. Without this the cross hair alone - two lines across the page in each capture - was several thousand differing pixels of a refresh that changed nothing.- Parameters:
before- The BEFORE image data, may be null.volatileBefore- What the page answered at the BEFORE capture: an array of numbers, four for each rectangle (x, y, width, height in page pixels), or null.after- The AFTER image data, may be null.volatileAfter- What the page answered at the AFTER capture, or null.monitorZoom- The monitor zoom in percent: an image pixel is 100/zoom page pixels.createMask- Flag to build the difference mask image.- Returns:
- The result of the comparison.