Class ImagePlanner

java.lang.Object
dev.despical.pixelpainter.image.ImagePlanner

public final class ImagePlanner extends Object
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 Type
    Method
    Description
    static PaintPlan
    plan(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 int
    width(int sourceWidth, int sourceHeight, int height, int maxBlocks)
    Calculates aspect-preserving width before allocating output buffers.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 width
      sourceHeight - positive source height
      height - requested positive output rows
      maxBlocks - 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 image
      height - requested output block rows
      maxBlocks - maximum output area
      palette - previously resolved, non-empty palette
      transparent - whether low-alpha pixels preserve terrain
      alphaThreshold - skip pixels below this cutoff; zero-alpha pixels are always skipped
      dither - whether to diffuse color error into neighboring pixels
      background - packed sRGB compositing background when transparency is disabled
      Returns:
      prepared materials without world mutation
      Throws:
      InterruptedException - if the worker is interrupted between rows
      IllegalArgumentException - if output dimensions exceed the budget