Class ImagePlanner
java.lang.Object
dev.despical.pixelpainter.image.ImagePlanner
Resizes decoded images and selects block materials independently of Bukkit worlds.
Output height is measured in actual block rows, and width preserves aspect ratio within a checked pixel budget. Transparent pixels may preserve terrain; opaque rendering composites the source over the configured background. Optional Floyd-Steinberg diffusion improves detail with a limited palette.
Planning allocates task-local buffers and checks interruption at each image row. The palette already contains server-resolved block-data strings.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PaintPlanplan(BufferedImage source, int height, int maxBlocks, BlockPalette palette, boolean transparent, int alphaThreshold, boolean dither, int background) Produces a copied row-major block plan and material counts on an image worker.static intwidth(int sourceWidth, int sourceHeight, int height, int maxBlocks) Calculates aspect-preserving width before allocating output buffers.
-
Method Details
-
width
public static int width(int sourceWidth, int sourceHeight, int height, int maxBlocks) Calculates aspect-preserving width before allocating output buffers.- Parameters:
sourceWidth- positive source widthsourceHeight- positive source heightheight- requested positive output rowsmaxBlocks- permitted output area- Returns:
- rounded width, with a minimum of one
- Throws:
IllegalArgumentException- if dimensions are invalid or exceed the budget
-
plan
public static PaintPlan plan(BufferedImage source, int height, int maxBlocks, BlockPalette palette, boolean transparent, int alphaThreshold, boolean dither, int background) throws InterruptedException Produces a copied row-major block plan and material counts on an image worker.- Parameters:
source- decoded source imageheight- requested output block rowsmaxBlocks- maximum output areapalette- previously resolved, non-empty palettetransparent- whether low-alpha pixels preserve terrainalphaThreshold- skip pixels below this cutoff; zero-alpha pixels are always skippeddither- whether to diffuse color error into neighboring pixelsbackground- packed sRGB compositing background when transparency is disabled- Returns:
- prepared materials without world mutation
- Throws:
InterruptedException- if the worker is interrupted between rowsIllegalArgumentException- if output dimensions exceed the budget
-