Class ImageStitch
java.lang.Object
cloud.opencode.base.image.ImageStitch
Image Stitching Utility
图片拼接工具类
Provides static methods for stitching multiple images together horizontally, vertically, or in a grid layout.
提供静态方法用于将多张图片水平拼接、垂直拼接或按网格排列。
Features | 主要功能:
- Horizontal stitching with auto vertical centering - 水平拼接,自动垂直居中
- Vertical stitching with auto horizontal centering - 垂直拼接,自动水平居中
- Grid layout stitching by column count - 按列数网格拼接
- Gap and background color support - 支持间距和背景色
Usage Examples | 使用示例:
// Horizontal stitch
Raster result = ImageStitch.horizontal(List.of(r1, r2, r3));
// Vertical stitch with gap and white background
Raster result = ImageStitch.vertical(List.of(r1, r2), 10, 0xFFFFFFFF);
// Grid layout
Raster result = ImageStitch.gridRaster(List.of(r1, r2, r3, r4), 2);
Security | 安全性:
- Thread-safe: Yes (stateless utility) - 线程安全: 是(无状态工具)
- Null-safe: No (throws on null input) - 空值安全: 否(null 输入抛异常)
- Since:
- JDK 25, opencode-base-image V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic RastergridRaster(List<Raster> rasters, int columns) StitchRasters in a grid layout with the specified column count.static Rasterhorizontal(List<Raster> rasters) StitchRasters horizontally; height is the maximum, smaller rasters are vertically centered.static Rasterhorizontal(List<Raster> rasters, int gap, int bgArgb) StitchRasters horizontally with gap and background ARGB color.static RasterStitchRasters vertically; width is the maximum, smaller rasters are horizontally centered.static RasterStitchRasters vertically with gap and background ARGB color.
-
Method Details
-
horizontal
StitchRasters horizontally; height is the maximum, smaller rasters are vertically centered. 水平拼接Raster;高度取最大,较小项垂直居中。- Parameters:
rasters- the rasters to stitch | 要拼接的 raster- Returns:
- stitched
RGBA_8raster | 拼接后的RGBA_8raster - Throws:
IllegalArgumentException- if list is null or empty | 列表为 null/空时抛出- Since:
- opencode-base-image V1.0.4
-
horizontal
- Parameters:
rasters- the rasters to stitch | 要拼接的 rastergap- gap between items in pixels | 间距(像素)bgArgb- background fill color (ARGB; use 0 for transparent) | 背景颜色(ARGB;0 为透明)- Returns:
- stitched
RGBA_8raster | 拼接后的RGBA_8raster - Throws:
IllegalArgumentException- if invalid | 不合法时抛出- Since:
- opencode-base-image V1.0.4
-
vertical
-
vertical
- Parameters:
rasters- the rasters to stitch | 要拼接的 rastergap- gap between items in pixels | 间距(像素)bgArgb- background fill color (ARGB; use 0 for transparent) | 背景颜色(ARGB;0 为透明)- Returns:
- stitched
RGBA_8raster | 拼接后的RGBA_8raster - Since:
- opencode-base-image V1.0.4
-
gridRaster
StitchRasters in a grid layout with the specified column count. 按指定列数将Raster排成网格拼接。The method is named
gridRasterfor symmetry with other Raster APIs.- Parameters:
rasters- the rasters to stitch | 要拼接的 rastercolumns- the number of columns (must be >= 1) | 列数(>= 1)- Returns:
- stitched
RGBA_8raster | 拼接后的RGBA_8raster - Since:
- opencode-base-image V1.0.4
-