Images
图片处理核心接口,提供屏幕截图录取证、图像裁剪、模板匹配、颜色识别等图像处理功能。
该接口封装了一系列图像处理操作,支持从文件或屏幕中进行图像分析, 包括模板匹配、颜色比较、特征点识别等高级功能,适用于自动化测试、图像识别等场景。
所有方法均提供异常处理机制,当参数无效或操作失败时会抛出相应异常, 建议调用时进行适当的异常捕获。
Author
M8Test, contact@m8test.com, https://m8test.com
Functions
Link copied to clipboard
通过系统截屏权限截取物理屏幕内容保存到 outputPath 中
Link copied to clipboard
通过系统截屏权限截取物理屏幕内容并返回 Bitmap
Link copied to clipboard
捕获指定屏幕并保存为图像文件。
Link copied to clipboard
捕获指定屏幕的完整内容并返回 Bitmap 对象。
Link copied to clipboard
abstract fun compareBitmapColors(image: Bitmap, firstColor: String, x: Int, y: Int, similarity: Int?, config: CompareColorsConfig.() -> Unit): Boolean
比较 Bitmap 中指定坐标的颜色是否匹配目标颜色。
Link copied to clipboard
abstract fun compareColors(imagePath: String, firstColor: String, x: Int, y: Int, similarity: Int?, config: CompareColorsConfig.() -> Unit): Boolean
比较图像中指定坐标的颜色是否匹配目标颜色。
Link copied to clipboard
abstract fun compareColorsInDisplay(displayId: Int, firstColor: String, x: Int, y: Int, similarity: Int?, config: CompareColorsConfig.() -> Unit): Boolean
比较屏幕中指定坐标的颜色是否匹配目标颜色(自动申请权限)。
Link copied to clipboard
裁剪 Bitmap , 在 src 中裁剪 regionBuilder 指定的矩形区域并返回该区域对应的 Bitmap 对象
Link copied to clipboard
Link copied to clipboard
裁剪屏幕指定区域并保存为图像文件(自动申请权限)。
Link copied to clipboard
abstract fun findBitmapColors(image: Bitmap, firstColor: String, similarity: Int?, limit: Int?, config: FindColorsConfig.() -> Unit): Results<CoordinateResult>
在 Bitmap 中查找匹配指定颜色的所有点。
Link copied to clipboard
abstract fun findColors(imagePath: String, firstColor: String, similarity: Int?, limit: Int?, config: FindColorsConfig.() -> Unit): Results<CoordinateResult>
在图像中查找匹配指定颜色的所有点。
Link copied to clipboard
abstract fun findColorsInDisplay(displayId: Int, firstColor: String, similarity: Int?, limit: Int?, config: FindColorsConfig.() -> Unit): Results<CoordinateResult>
在屏幕中查找匹配指定颜色的所有点(自动申请权限)。
Link copied to clipboard
获取 Bitmap 对象的尺寸信息。
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract fun matchBitmapTemplates(src: Bitmap, template: Bitmap, similarity: Int?, limit: Int?, config: MatchTemplatesConfig.() -> Unit): Results<RegionResult>
Link copied to clipboard
abstract fun matchBitmapTemplatesInDisplay(displayId: Int, template: Bitmap, similarity: Int?, limit: Int?, config: MatchTemplatesConfig.() -> Unit): Results<RegionResult>
在屏幕中查找匹配的模板 Bitmap(自动申请权限)。
Link copied to clipboard
abstract fun matchTemplates(srcPath: String, templatePath: String, similarity: Int?, limit: Int?, config: MatchTemplatesConfig.() -> Unit): Results<RegionResult>
在图像中查找匹配的模板(多目标支持)。
Link copied to clipboard
abstract fun matchTemplatesInDisplay(displayId: Int, templatePath: String, similarity: Int?, limit: Int?, config: MatchTemplatesConfig.() -> Unit): Results<RegionResult>
在屏幕中查找匹配的模板(自动申请权限)。
Link copied to clipboard
请求截屏权限,如果在 waitTime 内没有获得权限,那么就会抛出异常