public class ImageUtils
extends java.lang.Object
Robot
,
Dec 23, 2008 (LeiWang) Add method saveImageToFile(): If the file format is JPG, use the compression quality to save file.
Sep 25, 2009 (JunwuMa) Update getStoredImage() to use JAI API to open image file. It is supposed to recognize
all JAI supported image types including compressed TIFF.
Oct 29, 2009 (Carl Nagle) Added BitTolerance support.
Nov 03, 2009 (Carl Nagle) Draft Prep for multi-threaded algorithm.
Nov 19, 2009 (Carl Nagle) Removing default of multi-threading BitTolerance searches.
Also attempted to isolate more multi-threading code out of primary routines.
Jan 18, 2010 (JunwuMa) Update saveImageToFile() to support tif, gif, png and pnm.
It requires JAI Imageio installed.
http://java.sun.com/products/java-media/jai/INSTALL-jai_imageio_1_0_01.html#Windows
https://jai-imageio.dev.java.net/binary-builds.html
MAR 14, 2010 (JunwuMa) Adding "ImageText=" mode, which is only used to define a non top Window in IBT
for TOCR to search in the snapshot of the top Window.
Apr 07, 2010 (LeiWang) Add "ImageRect=" or "ImageRectangle=" mode, which is used to define a top Window.
For now, it is generated internally by RJ engine side (@see org.safs.rational.CFTIDComponent)
Of course user can use it directly to represent a Top window.
Modify method extractImagePath(), findComponentRectangle().
Remove method getImageRecognition(), move this functionality to TestRecordHelper's method getRecognitionString()
Apr 20, 2010 (LeiWang) Modify method findComponentRectangle():use static method of OCREngine to get
an OCR engine to use.
May 26, 2010 (JunwuMa) Updates to make ImageText= work with Index= and SearchRect=
Jul 13, 2010 (LeiWang) Add method findImageWithXYBTThread(),findSmallImageWithXYBTThread(),findBigImageWithXYBTThread()
Modify method findBufferedImageOnScreen(),modifyLocWidthHeight(),extractImageIndex()
Do these modifications for applying multi-thread to search an image.
Oct 26, 2010 (Carl Nagle) Large refactoring to fix implementation for SearchRect and new usePerImageModifiers feature.
Oct 28, 2010 (Carl Nagle) Added support for UsePerImageModifiers on Index= and BitTolerance=
DEC 22, 2010 (LeiWang) Added methods getCopiedImage(), paintOnImage() and getImageFileFilter() etc.
DEC 27, 2010 (LeiWang) Added methods paintOnImage(): add one boolean parameter to decide if paint on the original image.
Add some image filter operations like blur, sharpen, edge, etc.
AUG 25, 2014 (LeiWang) Fix problem of saving image as .bmp and .jpg file.
SEP 30, 2014 (LeiWang) Add method copy().
SEP 30, 2014 (LeiWang) Modify method getSubAreaRectangle(): move common code to calculateAbsoluteCoordinate().
Add class SubArea: user write string subarea may contain "error", such as "0, 0, 50%, 60%", "0;0;50;90;"
these are correct for human-being, but can not be accepted by our program. Use SubArea will reduce error.
DEC 12, 2014 (LeiWang) Move filterImage (cover certain area with black) functinality from DCDriverFileCommands to here.
FEB 18, 2016 (Carl Nagle) Support Comp search of whole screen when WinRec is ImageRect or SearchRect.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ImageUtils.ModifiedRectInfo |
static class |
ImageUtils.SubArea
Represent an SubArea by 2 coordiantes (TopLeft, BottomRight).
The x/y of coordinate can be number or a percentage-number, number means absolute coordinate, percentage-number means relative width/height. This SubArea is used to get a sub Rectangle from a Rectangle. |
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String[] |
_imagerec |
(package private) static java.lang.String[] |
_imagerec_alone |
(package private) static long |
closestMatchCount |
(package private) static long |
closestMatchesOf |
(package private) static float |
closestPercentage |
(package private) static int |
closestX |
(package private) static int |
closestY |
static boolean |
debug
for messaging and GenericEngine.saveTestRecordScreenToTestDirectory
|
static int |
default_percent_bits_tolerance
1-100, acquired from non-recognition string settings like an INI file.
|
static boolean |
default_useBitsTolerance
true or false, acquired from non-recognition string settings like an INI file.
|
static int |
DIVIDE_PIECES
When USE_MULTIPLE_THREADS is true, DIVIDE_PIECES will be used.
|
static java.lang.String |
EXT_GIF |
static java.lang.String |
EXT_JPEG |
static java.lang.String |
EXT_JPG |
static java.lang.String |
EXT_PNG |
static java.lang.String |
EXT_TIF |
static java.lang.String |
EXT_TIFF |
static int |
IMAGE_SIZE_PIXEL_THREADSHOLD
'100*100' if the image size is bigger than this threadshold, we will use multiple threads to compare
|
static int |
INT_BOTTOMCENTER |
static int |
INT_BOTTOMLEFT |
static int |
INT_BOTTOMRIGHT |
static int |
INT_CENTER |
static int |
INT_LEFTCENTER |
static int |
INT_RIGHTCENTER |
static int |
INT_TOPCENTER |
static int |
INT_TOPLEFT |
static int |
INT_TOPRIGHT |
(package private) static JAIImagingListener |
jailistener |
static int |
MAX_PERCENT_BITS_TOLERANCE
100
|
static java.lang.String |
MOD_BC |
static java.lang.String |
MOD_BITTOLERANCE |
static java.lang.String |
MOD_BL |
static java.lang.String |
MOD_BOTTOMCENTER |
static java.lang.String |
MOD_BOTTOMLEFT |
static java.lang.String |
MOD_BOTTOMRIGHT |
static java.lang.String |
MOD_BR |
static java.lang.String |
MOD_BT |
static java.lang.String |
MOD_C |
static java.lang.String |
MOD_CENTER |
static java.lang.String |
MOD_COMMA |
static java.lang.String |
MOD_EQ |
static java.lang.String |
MOD_HOTSPOT |
static java.lang.String |
MOD_HS |
static java.lang.String |
MOD_IMAGE |
static java.lang.String |
MOD_IMAGE_RECT
"ImageRect=", "SearchRect", "ImageRectangle=", or "SearchRectangle" support a new image mode to define a
top Window only.
|
static java.lang.String |
MOD_IMAGE_RECTANGLE |
static java.lang.String |
MOD_IMAGEB |
static java.lang.String |
MOD_IMAGEBOTTOM |
static java.lang.String |
MOD_IMAGEH |
static java.lang.String |
MOD_IMAGEHEIGHT |
static java.lang.String |
MOD_IMAGER |
static java.lang.String |
MOD_IMAGERIGHT |
static java.lang.String |
MOD_IMAGETEXT
"ImageText=", a new image mode to define a non top Window only.
|
static java.lang.String |
MOD_IMAGEW |
static java.lang.String |
MOD_IMAGEWIDTH |
static java.lang.String |
MOD_IND |
static java.lang.String |
MOD_INDEX |
static java.lang.String |
MOD_INS |
static java.lang.String |
MOD_INSETS |
static java.lang.String |
MOD_LC |
static java.lang.String |
MOD_LEFTCENTER |
static java.lang.String |
MOD_OUTS |
static java.lang.String |
MOD_OUTSETS |
static java.lang.String |
MOD_PERCENT |
static java.lang.String |
MOD_POINTRELATIVE |
static java.lang.String |
MOD_PR |
static java.lang.String |
MOD_RC |
static java.lang.String |
MOD_RIGHTCENTER |
static java.lang.String |
MOD_SEARCH_RECT |
static java.lang.String |
MOD_SEARCH_RECTANGLE |
static java.lang.String |
MOD_SEARCHMASK |
static java.lang.String |
MOD_SEARCHRECT |
static java.lang.String |
MOD_SEMICOLON |
static java.lang.String |
MOD_SEP |
static java.lang.String |
MOD_SM |
static java.lang.String |
MOD_SPACE |
static java.lang.String |
MOD_SR |
static java.lang.String |
MOD_TC |
static java.lang.String |
MOD_TL |
static java.lang.String |
MOD_TOPCENTER |
static java.lang.String |
MOD_TOPLEFT |
static java.lang.String |
MOD_TOPRIGHT |
static java.lang.String |
MOD_TR |
(package private) static int |
percentBitsTolerance
current tolerance for percent of image pixels that must match
|
(package private) static int |
screenBands |
(package private) static java.awt.image.DataBuffer |
screenBuffer |
(package private) static java.awt.image.ColorModel |
screenColor |
(package private) static int |
screenHeight |
(package private) static java.awt.image.BufferedImage |
screenImage |
(package private) static int |
screenImageType |
(package private) static java.awt.image.SampleModel |
screenModel |
(package private) static java.awt.image.Raster |
screenRaster |
(package private) static java.awt.Rectangle |
screenRect |
(package private) static java.awt.Dimension |
screenSize |
(package private) static int |
screenWidth |
(package private) static java.awt.Toolkit |
toolkit |
static boolean |
USE_FUZZY_MATCHING
true if we can add fuzzy pixel matching to the normal match algorithm
|
static boolean |
USE_MULTIPLE_THREADS
Set true if image searches using BitTolerance
should attempt to use parallel threading.
|
static boolean |
USE_PER_IMAGE_MODIFIERS
Allow enhanced use of SearchRect=, Index=, and BitTolerance= on all Window
definition components like Image=, ImageR= and ImageH= instead of just for
the Image= portion.
|
(package private) static boolean |
useBitsTolerance
true if percentBitsTolerance should be used when evaluating image matches
|
Constructor and Description |
---|
ImageUtils() |
Modifier and Type | Method and Description |
---|---|
protected static java.awt.Rectangle |
adjustImageBRect(java.awt.image.BufferedImage pic,
java.awt.Rectangle searchRec) |
static java.awt.image.BufferedImage |
blurImage(java.awt.image.BufferedImage image) |
static java.awt.Point |
calcHotspotPoint(java.awt.Point relativehs,
java.awt.Rectangle area,
int pointrelative) |
static double |
calculateAbsoluteCoordinate(double xOrY,
double wOrH,
java.lang.String offset)
Caculate an absolute coordinate according to (x, width)/(y, height) and offset.
|
static java.awt.image.BufferedImage |
captureScreenArea(java.awt.Rectangle screenRect)
Retrieve a BufferedImage of an area of the screen.
|
static boolean |
compareImage(java.awt.image.BufferedImage sourceImage,
java.awt.image.BufferedImage targetImage,
int percentBitsTolerance)
Compare the sourceImage and targetImage.
|
static boolean |
compareImage(java.awt.image.BufferedImage sourceImage,
java.awt.image.BufferedImage targetImage,
java.awt.Rectangle sourceRect,
java.awt.Rectangle targetRect,
int percentBitsTolerance)
Compare the sourceImage and targetImage, or compare a certain area of them.
|
static java.awt.Rectangle[] |
convertAreas(java.awt.Rectangle basedRect,
java.lang.String areas,
java.util.List<java.lang.String> warnings)
Convert a set of area into an array of Rectangle
|
static java.awt.image.BufferedImage |
convertImage(java.awt.image.BufferedImage image,
int type)
Convert the BufferedImage to another type of BufferedImage.
Some types cannot convert to, for example BufferedImage.TYPE_CUSTOM |
static java.awt.image.BufferedImage |
convertToRGBImage(java.awt.image.BufferedImage image)
If the image contains alpha value, then remove it and create a new RGB Image.
|
static java.awt.image.BufferedImage |
copy(java.awt.image.BufferedImage image)
Make a deep copy of original BufferedImage.
Do NOT copy the Raster. But paint the original image on a new BufferedImage of the same size and type, so the Raster has the same size as image (will not contain more data with an offset). |
static java.awt.image.BufferedImage |
copyRaster(java.awt.image.BufferedImage bi)
Make a deep copy of original BufferedImage, copy the Raster.
This method is not very reliable, sometimes it fail. |
static java.awt.image.BufferedImage |
createDiffImage(java.awt.image.BufferedImage buffimg,
java.awt.image.BufferedImage benchimg)
With the assumption that the two provided images are NOT matching, we will
create a Diff image composite from the two images.
|
static javax.swing.ImageIcon |
createImageIcon(java.lang.String path)
Returns an ImageIcon, or null if the path is invalid.
|
static java.awt.image.BufferedImage |
edgeImage(java.awt.image.BufferedImage image) |
static int |
extractBitsTolerance(java.lang.String[] recognition)
Extract the BitTolerance=N; or BT=N; modifier of an Image-Based Testing recognition string.
|
static int |
extractBitsTolerance(java.lang.String imagetype,
java.lang.String[] recognition)
Extract the BitTolerance=N; or BT=N; modifier of an Image-Based Testing recognition string.
|
static java.awt.Point |
extractHotspot(java.lang.String[] recognition)
Attempt to extract the Hotspot=; portion of an Image-Based Testing recognition string.
|
static int |
extractImageIndex(java.lang.String[] recognition)
Extract the Index=N; modifier of an Image-Based Testing recognition string.
|
static int |
extractImageIndex(java.lang.String imagetype,
java.lang.String[] recognition)
Extract the Index=N; modifier of an Image-Based Testing recognition string.
|
static java.lang.String |
extractImagePath(java.lang.String imagex,
java.lang.String[] recognition)
Attempt to extract the Image=path; portion of an Image-Based Testing recognition string.
This can also be an ImageRect or SearchRect "path". |
static int |
extractPointRelative(java.lang.String[] recognition)
Extract the PointRelative= info of the recognition string.
|
static java.awt.Rectangle |
extractSearchRect(java.lang.String winimagetype,
java.lang.String[] recognition)
Attempt to extract the SearchRect=; portion of an Image-Based Testing recognition string.
|
static java.awt.Rectangle |
extractSearchRect(java.lang.String winimagetype,
java.lang.String[] recognition,
java.awt.Rectangle relative)
Attempt to extract the SearchRect=; portion of an Image-Based Testing recognition string.
|
static java.awt.image.BufferedImage |
filterImage(java.awt.image.BufferedImage image,
java.awt.image.BufferedImageOp op)
Purpose: Use provided BufferedImageOp to convert image
|
static java.awt.image.BufferedImage |
filterImage(java.awt.image.BufferedImage image,
java.lang.String filteredAreas,
java.util.List<java.lang.String> warnings)
Cover an image by black color on a set of area.
|
static java.awt.Rectangle |
findBufferedImageOnScreen(java.awt.image.BufferedImage image)
Call the main findBufferedImageOnScreen with null searchRect and nthindex of 1.
|
static java.awt.Rectangle |
findBufferedImageOnScreen(java.awt.image.BufferedImage image,
java.awt.Rectangle searchRect)
Call the main findBufferedImageOnScreen with searchRect and nthindex of 1.
|
static java.awt.Rectangle |
findBufferedImageOnScreen(java.awt.image.BufferedImage image,
java.awt.Rectangle searchRect,
int nth)
Attempts to locate the provided image within the latest screenshot and return
its location and size, if found.
|
(package private) static java.awt.Rectangle |
findCompImageInRectangle(TestRecordHelper trd,
java.lang.String imagepath,
int imageindex,
java.lang.String[] modifiers,
java.awt.Rectangle rect)
Called by findComponentRectangle.
|
static java.awt.Rectangle |
findComponentRectangle(TestRecordHelper trd)
Calls findComponentRectangle with a timeout of 0.
|
static java.awt.Rectangle |
findComponentRectangle(TestRecordHelper trd,
long timeout)
Locate the final Window:Component Rectangle specified by the test record.
|
static java.awt.Rectangle |
findImageLocation(TestRecordHelper trd,
boolean imageBR,
java.lang.String imagepath,
java.awt.Rectangle searchRec,
int nthindex)
Routine to find an image on the screen.
|
(package private) static java.awt.Rectangle |
findImageTextInRectangle(java.lang.String imagetext,
int imageindex,
STAFHelper staf,
java.lang.String[] modifiers,
java.awt.Rectangle rect)
Called by findComponentRectangle.
|
protected static java.awt.Rectangle |
findImageWithXYBTThread(int startx,
int starty,
int searchWidth,
int searchHeight,
int maxPixelErrors,
java.awt.image.BufferedImage image,
java.awt.image.DataBuffer imageBuffer,
java.awt.image.SampleModel imageModel)
Generally called from findBufferedImageOnScreen and not normally called directly.
|
protected static java.awt.Rectangle |
findImageWithXYBTThreadPool(int startx,
int starty,
int searchWidth,
int searchHeight,
int maxPixelErrors,
java.awt.image.DataBuffer imageBuffer,
java.awt.image.SampleModel imageModel,
int nth)
Generally called from findBufferedImageOnScreen and not normally called directly.
|
static java.awt.Rectangle |
getClippedSubAreaRectangle(java.awt.Rectangle compRect,
java.awt.Rectangle subRect)
Helper function for getSubAreaRectangle().
|
static java.awt.image.BufferedImage |
getCopiedImage(java.awt.image.BufferedImage srcImage,
int destWidth,
int destHeight,
java.awt.Color initialColor)
Purpose Create a new BufferedImage object, its size is destWidth*destHeight
If the size is samller than the source image, copy that part from source image to this new image; While if the size is bigger, copy the whole source image to this new image, and the part beyond will be filled by initialColor This method is used when drag to resize an image in ImageManager2 |
static java.awt.image.BufferedImage |
getCopiedImage(java.awt.image.BufferedImage srcImage,
int srcOffsetX,
int srcOffsetY,
int destOffsetX,
int destOffsetY,
int destWidth,
int destHeight,
java.awt.Color initialColor)
Purpose Copy the source image to a new image, whose width and height are given
by destWidth and destHeight; The area of new image outside of the source image will be filled with the color provided by parameter. |
static javax.swing.filechooser.FileFilter |
getImageFileFilter() |
static int |
getScreenHeight() |
static java.awt.image.BufferedImage |
getScreenImage()
Return the latest BufferedImage captured for the screen.
|
static java.awt.Rectangle |
getScreenSize()
Return the rectangle of the whole screen.
|
static int |
getScreenWidth() |
static java.awt.image.BufferedImage |
getStoredImage(java.lang.String fullpath)
Attempts to create\load a BufferedImage from an image stored in the File system.
|
static java.awt.Dimension |
getStoredImageDimension(java.lang.String fullpath)
Attempts to determine the width and height of the stored image.
|
static java.awt.Rectangle |
getSubAreaRectangle(java.awt.Rectangle compRect,
java.lang.String subarea)
Given the compRect Rectangle and
the subarea string, return a new, valid Rectangle that represents the SubArea.
|
static java.awt.image.BufferedImage |
getVoidBufferImage(int width,
int height,
int defaultType,
int altType)
Purpose Create a new BufferedImage Object with a certain type.
|
static boolean |
hasAlpha(java.awt.Image image) |
static boolean |
isImageBasedRecognition(java.lang.String recognition)
Attempt to determine if recognition string is for image-based testing
|
static boolean |
isImageFormatSupported(java.lang.String fileName) |
(package private) static boolean |
isImageType(java.lang.String imagetype,
java.lang.String modifier)
See if the recognition string modifier maps to the imagetype passed in.
|
static boolean |
isScreenXYFuzzyMatch(java.awt.image.DataBuffer sBuffer,
java.awt.image.SampleModel smodel,
int screencenterX,
int screencenterY,
java.awt.image.DataBuffer tBuffer,
java.awt.image.SampleModel tmodel,
int targetX,
int targetY)
This is a time expensive match seeking to match 1 pixel with any one of 8 adjacent pixels.
|
static void |
main(java.lang.String[] args) |
static ImageUtils.ModifiedRectInfo |
modifyLocWidthHeight(TestRecordHelper trd,
java.awt.Rectangle winloc,
java.lang.String[] modifiers)
Attempt to expand the winloc Rectangle based on locating IMAGEW and IMAGEH
images specified in the recognition string.
|
static java.awt.image.BufferedImage |
negativeImage(java.awt.image.BufferedImage image) |
static java.lang.String |
normalizeFileNameSuffix(java.lang.String filename)
Check the suffix of filename, if it is not supported then append '.bmp' as suffix.
|
static java.lang.String |
normalizeSubAreas(java.lang.String areas)
Normalize a subareas string.
Replace all ";" by ",". |
static void |
outputImageData(java.awt.image.BufferedImage image)
Needs Enhancement API subject to change.
|
static java.awt.image.BufferedImage |
paintOnImage(java.awt.image.BufferedImage image,
int offsetX,
int offsetY,
int width,
int height,
java.awt.Color initialColor,
boolean paintOnNewImage)
Purpose Modify the source image by painting a simple color on an area, this
area is defined by offsetX,offsetY,width,height This method is used when cut an area from an image in ImageManager2 |
static java.awt.image.BufferedImage |
paintOnImage(java.awt.image.BufferedImage srcImage,
int srcOffsetX,
int srcOffsetY,
int width,
int height,
int destOffsetX,
int destOffsetY,
java.awt.image.BufferedImage destImage,
java.awt.Color initialColor,
boolean paintOnNewImage)
Purpose Get an area from the source image, this area is defined by
srcOffsetX,srcOffsetY,width,height; Then copy this area to the destImage, the point to start to paint is (destOffsetX,destOffsetY) If the area is too big, beyond the source image, then the souce image will be enlarged, the extra part will be painted with initColor. This method is used when copy an image to the panel in ImageManager2 |
(package private) static int |
processBitsToleranceModifier(java.lang.String value)
Called internally from extractBitTolerance.
|
(package private) static java.awt.Rectangle |
processSearchRectModifier(java.lang.String modifier,
java.awt.Rectangle rectangle,
boolean isRelative)
Called internally by extractSearchRect
|
static void |
recaptureScreen()
Recaptures certain properties and the graphical contents of the screen.
|
static void |
resetBitsTolerance()
Resets the class to use the default_percent_bits_tolerance
and the default_useBitsTolerance.
|
static void |
resetMatchData()
Clear\Reset all internally stored search match data like:
closestX, closestY, closestMatchCount, closestMatchesOf, closestPercentage
|
static void |
resetScreenData()
Clear\Reset all internally stored screen data like:
screenWidth, screenHeight, screenBands, screenImage, screenModel, screenBuffer, and screenColor.
|
static java.io.File |
retrieveAbsoluteFileOrDirectory(TestRecordHelper trd,
java.lang.String path)
path must not be null or 0-length
|
static java.awt.image.BufferedImage |
rotateImage(java.awt.image.BufferedImage bufferedimage,
int angle)
Rotate the Image with 90, 180 or 270 degree.
|
static void |
saveImageToFile(java.awt.image.BufferedImage image,
java.io.File file)
Store our BufferedImage into a File.
|
static void |
saveImageToFile(java.awt.image.BufferedImage image,
java.io.File file,
float quality)
Store our BufferedImage into a File;
If the format is JPG, the third parameter indicate the compression quality.
|
static java.awt.image.BufferedImage |
sharpenImage(java.awt.image.BufferedImage image) |
static java.lang.String[] |
splitRecognition(java.lang.String recognition)
Split the image recognition info at each MOD_SEP to form the String[] recognition
needed by most routines.
|
public static boolean debug
public static final java.lang.String MOD_EQ
public static final java.lang.String MOD_COMMA
public static final java.lang.String MOD_SEMICOLON
public static final java.lang.String MOD_SPACE
public static final java.lang.String MOD_PERCENT
public static final java.lang.String MOD_SEP
public static final java.lang.String MOD_IMAGE
public static final java.lang.String MOD_IMAGER
public static final java.lang.String MOD_IMAGERIGHT
public static final java.lang.String MOD_IMAGEW
public static final java.lang.String MOD_IMAGEWIDTH
public static final java.lang.String MOD_IMAGEB
public static final java.lang.String MOD_IMAGEBOTTOM
public static final java.lang.String MOD_IMAGEH
public static final java.lang.String MOD_IMAGEHEIGHT
public static final java.lang.String MOD_INDEX
public static final java.lang.String MOD_IND
public static final java.lang.String MOD_HOTSPOT
public static final java.lang.String MOD_HS
public static final java.lang.String MOD_SEARCHRECT
public static final java.lang.String MOD_SR
public static final java.lang.String MOD_SEARCHMASK
public static final java.lang.String MOD_SM
public static final java.lang.String MOD_POINTRELATIVE
public static final java.lang.String MOD_PR
public static final java.lang.String MOD_INSETS
public static final java.lang.String MOD_INS
public static final java.lang.String MOD_OUTSETS
public static final java.lang.String MOD_OUTS
public static final java.lang.String MOD_BITTOLERANCE
public static final java.lang.String MOD_BT
public static final java.lang.String MOD_TOPLEFT
public static final java.lang.String MOD_TL
public static final int INT_TOPLEFT
public static final java.lang.String MOD_TOPCENTER
public static final java.lang.String MOD_TC
public static final int INT_TOPCENTER
public static final java.lang.String MOD_TOPRIGHT
public static final java.lang.String MOD_TR
public static final int INT_TOPRIGHT
public static final java.lang.String MOD_LEFTCENTER
public static final java.lang.String MOD_LC
public static final int INT_LEFTCENTER
public static final java.lang.String MOD_CENTER
public static final java.lang.String MOD_C
public static final int INT_CENTER
public static final java.lang.String MOD_RIGHTCENTER
public static final java.lang.String MOD_RC
public static final int INT_RIGHTCENTER
public static final java.lang.String MOD_BOTTOMLEFT
public static final java.lang.String MOD_BL
public static final int INT_BOTTOMLEFT
public static final java.lang.String MOD_BOTTOMCENTER
public static final java.lang.String MOD_BC
public static final int INT_BOTTOMCENTER
public static final java.lang.String MOD_BOTTOMRIGHT
public static final java.lang.String MOD_BR
public static final int INT_BOTTOMRIGHT
public static final java.lang.String EXT_JPEG
public static final java.lang.String EXT_JPG
public static final java.lang.String EXT_GIF
public static final java.lang.String EXT_TIFF
public static final java.lang.String EXT_TIF
public static final java.lang.String EXT_PNG
public static final java.lang.String MOD_IMAGETEXT
public static final java.lang.String MOD_IMAGE_RECT
A traditional IBT-defined top window is like "Image=
Now we can profit from a special Engine (ex. RJ) to get the top window object, this object can give us it's
location on the screen, then we can create a new RS like "ImageRect=x,y,width,height" and send it back to
IBT (@see org.safs.tools.engines.TIDComponent), IBT can deduce the Anchor from this RS directly.
It will be a great complement for a special Engine in case that the engine can't find some components.
Take RFT as example,
If this feature is used with feature "ImageText=", that will be great. We don't need to store ANY one
image.
We can also support this just by allowing an IBT Window Recognition string in the appmap to contain ImageRect
or SearchRect recognition information without specifying any real images.
Examples:
Recognition Strings:
topWin="Type=JavaWindow;Caption={Swing*}"
Comp="IBT_Recognization_String"
IBT script:
T,topWin,Comp,Click
Explain:
1. RS topWin="Type=JavaWindow;Caption={Swing*}" is treated in a special Engine, the top window object
is got.
2. From the top window object, we generate a new RS "ImageRect=x,y,w,h" for top window. And we send the test
record to IBT.
3. IBT will parse RS "ImageRect=x,y,w,h" and get the Anchor, and it will find the component location
within that Anchor, and perform the action Click on that location.
public static final java.lang.String MOD_IMAGE_RECTANGLE
public static final java.lang.String MOD_SEARCH_RECT
public static final java.lang.String MOD_SEARCH_RECTANGLE
static java.awt.Toolkit toolkit
static java.awt.Dimension screenSize
static java.awt.Rectangle screenRect
static java.awt.image.BufferedImage screenImage
static int screenImageType
static java.awt.image.Raster screenRaster
static java.awt.image.SampleModel screenModel
static java.awt.image.DataBuffer screenBuffer
static java.awt.image.ColorModel screenColor
static int screenWidth
static int screenHeight
static int screenBands
static int closestX
static int closestY
static long closestMatchCount
static long closestMatchesOf
static float closestPercentage
public static final int MAX_PERCENT_BITS_TOLERANCE
public static int default_percent_bits_tolerance
static int percentBitsTolerance
public static boolean default_useBitsTolerance
public static boolean USE_PER_IMAGE_MODIFIERS
true or false, acquired from non-recognition string settings like an INI file. Defaults to false.
static boolean useBitsTolerance
public static boolean USE_FUZZY_MATCHING
static JAIImagingListener jailistener
public static boolean USE_MULTIPLE_THREADS
SmallPieceComparator
,
ScreenXYBTComparator
public static int DIVIDE_PIECES
SmallPieceComparator
public static final int IMAGE_SIZE_PIXEL_THREADSHOLD
static final java.lang.String[] _imagerec_alone
static final java.lang.String[] _imagerec
public static void resetScreenData()
public static void resetMatchData()
public static int getScreenWidth()
public static int getScreenHeight()
public static javax.swing.ImageIcon createImageIcon(java.lang.String path)
path
- String path suitable for getResource() to create\locate a valid java.net.URL.Class.getResource(String)
,
URL
public static java.awt.Rectangle getClippedSubAreaRectangle(java.awt.Rectangle compRect, java.awt.Rectangle subRect)
Rectangle
- compRect; the portion of the window that holds the component.Rectangle
- subRect; the the portion of compRect in question.public static java.awt.Rectangle getSubAreaRectangle(java.awt.Rectangle compRect, java.lang.String subarea)
Rectangle
- compRect; the source Rectangle to get the subarea from.String
- subarea; the portion of compRect in question.
subarea coors can be semi-colon delimited (x;2;3;4) or comma-delimited (1,2,3,4).
subarea must be in the format of a top-left and bottom-right pair, and can be either absolute
coordinates or percentages ("x1,y1,x2,y2" or "x1%,y1%,x2%,y2%"). Coordinates are relative to
compRect, i.e. (0,0) and (0%,0%) are the minimum, and (compRect.width, compRect.height)
and (100%,100%) are the maximum. Values exceeding the minimun/ maximum are forced to the nearest
limiting value. Absolute and percent values can be mixed, so "0,0,50%,50%" is valid.public static double calculateAbsoluteCoordinate(double xOrY, double wOrH, java.lang.String offset) throws java.lang.Exception
xOrY
- double, the x/y of a rectangle.wOrH
- double, the width/height of a rectangle.offset
- String, the offsetjava.lang.Exception
public static void recaptureScreen() throws java.awt.AWTException
java.awt.AWTException
- if instantiation of the java.awt.Robot throws it.getScreenImage()
,
screenHeight
,
screenWidth
public static java.awt.image.BufferedImage captureScreenArea(java.awt.Rectangle screenRect) throws java.awt.AWTException
screenRect
- java.awt.AWTException
- if java.awt.Robot AWTException occurspublic static java.awt.Rectangle getScreenSize()
public static java.awt.image.BufferedImage getScreenImage() throws java.awt.AWTException
java.awt.AWTException
- if instantiating the java.awt.Robot throws itrecaptureScreen()
public static java.awt.image.BufferedImage getStoredImage(java.lang.String fullpath) throws java.io.FileNotFoundException, java.io.IOException
fullpath
- case-insensitive absolute path to the image on file.java.io.FileNotFoundException
- if the file does not exist or cannot be read.java.io.IOException
- if ImageIO has a problem reading the file or file format.BufferedImage
,
ImageIO.read(File)
public static java.awt.Dimension getStoredImageDimension(java.lang.String fullpath) throws java.io.FileNotFoundException, java.io.IOException
fullpath
- case-insensitive absolute path to the image on file.java.io.FileNotFoundException
- if the file does not exist or cannot be read.java.io.IOException
- if ImageIO has a problem reading the file or file format.BufferedImage
,
ImageIO.read(File)
public static boolean compareImage(java.awt.image.BufferedImage sourceImage, java.awt.image.BufferedImage targetImage, int percentBitsTolerance)
sourceImage
- BufferedImage, the bench imagetargetImage
- BufferedImage, the test imagepercentBitsTolerance
- int, the percentage of bits need to be the same. it is between 0 and 100.
100 means only 100% match, 2 images will be considered matched;
0 means even no bits match, 2 images will be considered matched.compareImage(BufferedImage, BufferedImage, Rectangle, Rectangle, int)
public static boolean compareImage(java.awt.image.BufferedImage sourceImage, java.awt.image.BufferedImage targetImage, java.awt.Rectangle sourceRect, java.awt.Rectangle targetRect, int percentBitsTolerance)
sourceImage
- BufferedImage, the bench imagetargetImage
- BufferedImage, the test imagesourceRect
- Rectangle, the area on source image to compare; if null, compare whole imagetargetRect
- Rectangle, the area on target image to compare; if null, compare whole imagepercentBitsTolerance
- int, the percentage of bits need to be the same. it is between 0 and 100.
100 means only 100% match, 2 images will be considered matched;
0 means even no bits match, 2 images will be considered matched.compareImage(BufferedImage, BufferedImage, int)
,
_compareImageWithThread(BufferedImage, BufferedImage, int, int)
public static java.awt.Rectangle findBufferedImageOnScreen(java.awt.image.BufferedImage image, java.awt.Rectangle searchRect, int nth) throws java.lang.IllegalArgumentException, java.awt.image.ImagingOpException, java.awt.AWTException
image
- -- BufferedImage to locate within the latest screenshot.searchRect
- --limit the search area. Should be null to search the whole screen.nth
- -- the nth instance of a match. (1) first, by default.
It may be -1, which means user specify "Index=any" and he wants to use multi-thread-search;
It may be 0, which means user don't give "Index=N", SAFS will decide to use multi or single
thread according to value of USE_MULTIPLE_THREADS.
This parameter should be assigned to 0 when calling by other method
without knowing the real index, so that the multi-thread-search can be
profited when USE_MULTIPLE_THREADS is true.java.lang.IllegalArgumentException
- if the searchRect is not valid. (null will not throw this)java.awt.image.ImagingOpException
java.awt.AWTException
protected static java.awt.Rectangle findImageWithXYBTThreadPool(int startx, int starty, int searchWidth, int searchHeight, int maxPixelErrors, java.awt.image.DataBuffer imageBuffer, java.awt.image.SampleModel imageModel, int nth) throws java.lang.IllegalArgumentException, java.awt.image.ImagingOpException, java.awt.AWTException
Initial testing seems to suggest that using one thread per pixel anchor on the screen is too fine grained. The overhead of thread maintenance appears to be too great--making the performance poorer than simply using a single-threaded algorithm. For this reason, the use of the algorithm is presently discouraged and is disabled, by default.
startx
- - x-coord on screen to start the searchstarty
- - y-coord on screen to start the searchsearchWidth
- - width of area from startx to searchsearchHeight
- - height of area from starty to searchmaxPixelErrors
- - max number of pixels that can fail comparisonimageBuffer
- - DataBuffer of the target imageimageModel
- - SampleModel of the target imagenth
- - normally 1. Find the nth match of the image on screen.java.lang.IllegalArgumentException
java.awt.image.ImagingOpException
java.awt.AWTException
#findBufferedImageOnScreen(BufferedImage, Rectangle, int)}
,
DataBuffer
,
SampleModel
protected static java.awt.Rectangle findImageWithXYBTThread(int startx, int starty, int searchWidth, int searchHeight, int maxPixelErrors, java.awt.image.BufferedImage image, java.awt.image.DataBuffer imageBuffer, java.awt.image.SampleModel imageModel) throws java.lang.IllegalArgumentException, java.awt.image.ImagingOpException, java.awt.AWTException
startx
- - x-coord on screen to start the searchstarty
- - y-coord on screen to start the searchsearchWidth
- - width of area from startx to searchsearchHeight
- - height of area from starty to searchmaxPixelErrors
- - max number of pixels that can fail comparisonimage
- - BufferedImage of the target imageimageBuffer
- - DataBuffer of the target imageimageModel
- - SampleModel of the target imagejava.lang.IllegalArgumentException
java.awt.image.ImagingOpException
java.awt.AWTException
#findBufferedImageOnScreen(BufferedImage, Rectangle, int)}
,
DataBuffer
,
SampleModel
,
SharedLock
,
SmallPieceComparator
public static boolean isScreenXYFuzzyMatch(java.awt.image.DataBuffer sBuffer, java.awt.image.SampleModel smodel, int screencenterX, int screencenterY, java.awt.image.DataBuffer tBuffer, java.awt.image.SampleModel tmodel, int targetX, int targetY)
screenshotBuffer
- screenshot
- screencenterX
- screencenterY
- targetBuffer
- target
- targetX
- targetY
- public static java.awt.Rectangle findBufferedImageOnScreen(java.awt.image.BufferedImage image) throws java.lang.IllegalArgumentException, java.awt.image.ImagingOpException, java.awt.AWTException
image
- java.lang.IllegalArgumentException
java.awt.image.ImagingOpException
java.awt.AWTException
public static java.awt.Rectangle findBufferedImageOnScreen(java.awt.image.BufferedImage image, java.awt.Rectangle searchRect) throws java.lang.IllegalArgumentException, java.awt.image.ImagingOpException, java.awt.AWTException
image
- java.lang.IllegalArgumentException
java.awt.image.ImagingOpException
java.awt.AWTException
public static void outputImageData(java.awt.image.BufferedImage image) throws java.io.IOException
image
- java.io.IOException
public static java.lang.String[] splitRecognition(java.lang.String recognition)
recognition
- String containing all image recognition information.java.lang.NullPointerException
- if String recognition is null.static boolean isImageType(java.lang.String imagetype, java.lang.String modifier)
imagetype
- MOD_IMAGE, MOD_IMAGEW, MOD_IMAGEH, MOD_IMAGETEXT, MOD_IMAGE_RECTmodifier
- actual recognition string modifierpublic static java.lang.String extractImagePath(java.lang.String imagex, java.lang.String[] recognition)
imagex
- should be either MOD_IMAGE, MOD_IMAGEW, MOD_IMAGEH, MOD_IMAGE_RECT, MODE_SEARCH_RECTrecognition
- String [] of recognition modifiers. should not be null;public static int extractImageIndex(java.lang.String[] recognition)
recognition
- String [] of recognition modifiers. should not be null;public static int extractImageIndex(java.lang.String imagetype, java.lang.String[] recognition)
imagetype
- must be MOD_IMAGE, MOD_IMAGEW, MOD_IMAGEH, or MOD_IMAGETEXTrecognition
- String [] of recognition modifiers. should not be null;public static java.awt.Rectangle extractSearchRect(java.lang.String winimagetype, java.lang.String[] recognition)
which
- type of image is being modified: MOD_IMAGE, MOD_IMAGER, MOD_IMAGEH, MOD_IMAGE_RECT, MOD_IMAGETEXT.
can be null to default to ANY instance of SearchRect.recognition
- String [] of recognition modifiers. should not be null;USE_PER_IMAGE_MODIFIERS
static java.awt.Rectangle processSearchRectModifier(java.lang.String modifier, java.awt.Rectangle rectangle, boolean isRelative)
modifier
- The value already extracted from ;sr=value;rectangle
- The rectangle to modifyisRelative
- true if the modifications are "relative" instead of "absolute".extractSearchRect(String, String[], Rectangle)
public static java.awt.Rectangle extractSearchRect(java.lang.String winimagetype, java.lang.String[] recognition, java.awt.Rectangle relative)
which
- type of image is being modified: MOD_IMAGE, MOD_IMAGER, MOD_IMAGEH, MOD_IMAGE_RECT, MOD_IMAGETEXT
if null then MOD_IMAGE is used by default.recognition
- String [] of recognition modifiers. should not be null;relative
- Rectangle. If not null, the SearchRect is considered relative to this
Rectangle and not the entire screen.public static java.awt.Point extractHotspot(java.lang.String[] recognition)
recognition
- String [] of recognition modifiers. should not be null;public static int extractPointRelative(java.lang.String[] recognition)
recognition
- String [] of recognition modifiers. should not be null;public static void resetBitsTolerance()
static int processBitsToleranceModifier(java.lang.String value)
value
- should not be null;public static int extractBitsTolerance(java.lang.String[] recognition)
If not present, the routine resets the class to use the default_percent_bits_tolerance and the default_useBitsTolerance. If present and the tolerance is less than 100% then the useBitsTolerance boolean is forced to true, as well. If the tolerance is set to 100% then we expect an exact match and the useBitsTolerance boolean is set to false.
recognition
- String [] of recognition modifiers. should not be null;public static int extractBitsTolerance(java.lang.String imagetype, java.lang.String[] recognition)
If not present, the routine resets the class to use the default_percent_bits_tolerance and the default_useBitsTolerance. If present and the tolerance is less than 100% then the useBitsTolerance boolean is forced to true, as well. If the tolerance is set to 100% then we expect an exact match and the useBitsTolerance boolean is set to false.
imagetype
- should be MOD_IMAGE, MOD_IMAGEW, or MOD_IMAGEHrecognition
- String [] of recognition modifiers. should not be null;public static java.awt.Point calcHotspotPoint(java.awt.Point relativehs, java.awt.Rectangle area, int pointrelative)
relative
- Point retrieved from extractHotspot. may be null.area
- Rectangle found for image on screenpointrelative
- int value retrieved from extractPointRelative. -1=none or centerpublic static boolean isImageBasedRecognition(java.lang.String recognition)
recognition
- -- recognition, usually from App Mappublic static java.io.File retrieveAbsoluteFileOrDirectory(TestRecordHelper trd, java.lang.String path)
TestRecordHelper
- containing STAFHelper, AppMapName, WinName, and CompName info
returns the absolute path to the file or directory.
relative paths seek PROJECTDIR then DATAPOOLDIR to complete the absolute path.
Only returns if the File exists. null otherwise.protected static java.awt.Rectangle adjustImageBRect(java.awt.image.BufferedImage pic, java.awt.Rectangle searchRec)
public static java.awt.Rectangle findImageLocation(TestRecordHelper trd, boolean imageBR, java.lang.String imagepath, java.awt.Rectangle searchRec, int nthindex) throws java.io.FileNotFoundException, java.lang.IllegalArgumentException, java.io.IOException, java.awt.AWTException, java.awt.image.ImagingOpException
TestRecordHelper
- containing STAFHelper, AppMapName, WinName, and CompName infoimageBR
- -- set true ONLY if the search is for a bottom-right image below a top-right image.imagepath
- searchRec
- nthindex
- -- If it is 0, when USE_MULTIPLE_THREADS is true, SAFS will use multi-thread to search image;
when USE_MULTIPLE_THREADS is false, SAFS will use single-thread to search image;
If it is -1, SAFS will use multi-thread to search image;
If it is >0, SAFS will use single-thread to search image;java.io.FileNotFoundException
- if the specified image file cannot be foundjava.lang.IllegalArgumentException
- if searchRec is not validjava.io.IOException
- if there is a problem opening or reading filesjava.awt.image.ImagingOpException
- if ImageIO cannot process the image filejava.awt.AWTException
- if there is a problem with the java.awt.Robotpublic static ImageUtils.ModifiedRectInfo modifyLocWidthHeight(TestRecordHelper trd, java.awt.Rectangle winloc, java.lang.String[] modifiers) throws java.io.FileNotFoundException
For any given image, first tries to find it by exact match, then tries to find it according to any BitTolerance settings specified in the recognition modifiers.
TestRecordHelper
- containing STAFHelper, AppMapName, WinName, and CompName infowinloc
- -- Rectangle for the found anchor IMAGEmodifiers
- -- String[] split from the winrecjava.io.FileNotFoundException
public static java.awt.Rectangle findComponentRectangle(TestRecordHelper trd) throws java.io.IOException, java.awt.AWTException, SAFSException
trd
- java.io.IOException
java.awt.AWTException
SAFSException
- findComponentRectangle(TestRecordHelper, long)
public static java.awt.Rectangle findComponentRectangle(TestRecordHelper trd, long timeout) throws java.io.IOException, java.awt.AWTException, SAFSException
For any and all images, we try to find an exact match first, then try to use any BitsTolerance that might be supplied in the recognition strings.
TestRecordHelper
- containing STAFHelper, AppMapName, WinName, and CompName infotimeout
- in seconds to loop the search until found. <=0 means check only once.java.io.IOException
- if we cannot open or read specified filesjava.awt.AWTException
- if we cannot use the java.awt.RobotSAFSException
- if we cannot extract valid data from TestRecordHelper or STAFstatic java.awt.Rectangle findCompImageInRectangle(TestRecordHelper trd, java.lang.String imagepath, int imageindex, java.lang.String[] modifiers, java.awt.Rectangle rect) throws java.io.IOException, java.awt.AWTException, SAFSException
imagepath
- imageindex
- modifiers
- should not be nullrect
- screen area to search.java.io.IOException
java.awt.AWTException
SAFSException
- findComponentRectangle(TestRecordHelper, long)
static java.awt.Rectangle findImageTextInRectangle(java.lang.String imagetext, int imageindex, STAFHelper staf, java.lang.String[] modifiers, java.awt.Rectangle rect) throws java.io.IOException, java.awt.AWTException, SAFSException
imagetext
- imageindex
- staf
- modifiers
- should not be nullrect
- area on screen to searchjava.io.IOException
java.awt.AWTException
SAFSException
- findComponentRectangle(TestRecordHelper, long)
public static void saveImageToFile(java.awt.image.BufferedImage image, java.io.File file) throws java.lang.SecurityException, java.lang.IllegalArgumentException, java.io.IOException, java.lang.NoClassDefFoundError
image
- - BufferedImage for ImageIO to write to filefile
- -- valid full absolute File to write tojava.lang.SecurityException
- thrown if permission to write to the location is deniedjava.lang.IllegalArgumentException
- if ImageIO doesn't like our invocationjava.io.IOException
- if an error occurs while writing.java.lang.NoClassDefFoundError
- if support for ImageIO is not found (Java Advanced Imaging)public static java.awt.image.BufferedImage copy(java.awt.image.BufferedImage image)
bi
- BufferedImage, the image to copy.public static java.awt.image.BufferedImage copyRaster(java.awt.image.BufferedImage bi)
bi
- BufferedImage, the image to copy.public static java.awt.image.BufferedImage convertImage(java.awt.image.BufferedImage image, int type)
image
- BufferedImage, the image to convert.type
- int, the type to convert to.public static java.awt.image.BufferedImage convertToRGBImage(java.awt.image.BufferedImage image)
image
- BufferedImage, the image to convertpublic static boolean hasAlpha(java.awt.Image image) throws java.io.IOException
image
- Image, the image to detectjava.io.IOException
public static boolean isImageFormatSupported(java.lang.String fileName)
fileName
- public static java.lang.String normalizeFileNameSuffix(java.lang.String filename) throws SAFSException
filename,
- String, the filename to checkSAFSException
public static javax.swing.filechooser.FileFilter getImageFileFilter()
isImageFormatSupported(String)
or directories.public static java.awt.image.BufferedImage getVoidBufferImage(int width, int height, int defaultType, int altType)
width
- height
- defaultType
- The type of the new BufferedImagealtType
- If the default type can not be used to create a BufferedImage,public static java.awt.image.BufferedImage getCopiedImage(java.awt.image.BufferedImage srcImage, int destWidth, int destHeight, java.awt.Color initialColor)
srcImage
- BufferedImage, The source image to be copied.destWidth
- int, the destination image widthdestHeight
- int, the destination image heightinitialColor
- Color, the color to paint on the destination image as initial colorpublic static java.awt.image.BufferedImage getCopiedImage(java.awt.image.BufferedImage srcImage, int srcOffsetX, int srcOffsetY, int destOffsetX, int destOffsetY, int destWidth, int destHeight, java.awt.Color initialColor)
srcImage
- BufferedImage, The source image to be copied.srcOffsetX
- int, the x coordination in source image to begin copysrcOffsetY
- int, the y coordination in source image to begin copydestOffsetX
- int, the x coordination in destination image to begin pastedestOffsetY
- int, the y coordination in destination image to begin pastedestWidth
- int, the destination image widthdestHeight
- int, the destination image heightinitialColor
- Color, the color to paint on the destination image as initial colorpublic static java.awt.image.BufferedImage paintOnImage(java.awt.image.BufferedImage image, int offsetX, int offsetY, int width, int height, java.awt.Color initialColor, boolean paintOnNewImage)
image
- offsetX
- offsetY
- width
- height
- initialColor
- paintOnNewImage
- false, paint on original image; true, paint on a new buffered image.public static java.awt.image.BufferedImage paintOnImage(java.awt.image.BufferedImage srcImage, int srcOffsetX, int srcOffsetY, int width, int height, int destOffsetX, int destOffsetY, java.awt.image.BufferedImage destImage, java.awt.Color initialColor, boolean paintOnNewImage)
public static java.awt.image.BufferedImage blurImage(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage sharpenImage(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage edgeImage(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage negativeImage(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage rotateImage(java.awt.image.BufferedImage bufferedimage, int angle)
bufferedimage
- angle
- int, the angle the image will be rotated, in 360 degree
only 90, 180 or 270 degree are supported.public static java.awt.image.BufferedImage filterImage(java.awt.image.BufferedImage image, java.awt.image.BufferedImageOp op)
image
- op
- public static java.awt.image.BufferedImage filterImage(java.awt.image.BufferedImage image, java.lang.String filteredAreas, java.util.List<java.lang.String> warnings) throws SAFSException
image
- BufferedImage, the image to filter.filteredAreas
- String, a set of area delimited by space, such as "0,0,10,10 40;40;5%;5%"warnings
- ListSAFSException
- passed along from convertAreas(Rectangle, String, List)
.public static java.awt.Rectangle[] convertAreas(java.awt.Rectangle basedRect, java.lang.String areas, java.util.List<java.lang.String> warnings) throws SAFSException
basedRect
- Rectangle, the based rectangle.areas
- String, a set of area delimited by space, such as "0,0,10,10 40;40;5%;5%"warnings
- ListSAFSException
- if the basedRect is null or if any of the provided areas are completely outside the bounds of basedRect.public static java.lang.String normalizeSubAreas(java.lang.String areas)
areas
- String, a set of area delimited by space, such as "0, 0,10 ,10 40;40;5%; 5%"public static void saveImageToFile(java.awt.image.BufferedImage image, java.io.File file, float quality) throws SAFSException
image
- - BufferedImage for ImageIO to write to filefile
- - valid full absolute File to write toquality
- - If the file format is JPG, it indicates the compression quality.
It's value should be between 0.0 and 1.0;SAFSException
public static void main(java.lang.String[] args)
public static java.awt.image.BufferedImage createDiffImage(java.awt.image.BufferedImage buffimg, java.awt.image.BufferedImage benchimg) throws java.lang.IllegalArgumentException
buffimg
- benchimg
- java.lang.IllegalArgumentException
- if either of the images provided is null.Copyright © SAS Institute. All Rights Reserved.