Class ImageSignature
java.lang.Object
com.nsdev.lettergenerator.signature.ImageSignature
- All Implemented Interfaces:
SignatureContent
Immutable PNG/JPEG/static SVG signature part owning a defensive copy of its image bytes.
Factories decode the image immediately and preserve its aspect ratio within a 40 by 20 mm box.
sizeMm(double, double) creates another fitted part without mutating this one. Placement
within the letter is configured on the letter builder.-
Method Summary
Modifier and TypeMethodDescriptionblocks()Exposes the ordered immutable blocks represented by this signature part.static ImageSignatureof(byte[] data) Copies and decodes image bytes, fitting the aspect ratio inside a 40 by 20 mm box.static ImageSignatureReads and decodes an image immediately, fitting it inside a 40 by 20 mm box.sizeMm(double maxWidth, double maxHeight) Creates a signature refitted from the original image bytes into the given box.
-
Method Details
-
of
Copies and decodes image bytes, fitting the aspect ratio inside a 40 by 20 mm box. The fit can enlarge a small source image as well as reduce a large one.- Parameters:
data- non-null readable PNG, JPEG or static SVG image bytes- Returns:
- a new immutable image signature
- Throws:
IllegalArgumentException- if bytes are null, unreadable, or not PNG/JPEG/static SVG
-
of
Reads and decodes an image immediately, fitting it inside a 40 by 20 mm box. The resulting signature no longer depends on the file.- Parameters:
path- non-null PNG, JPEG or static SVG file path- Returns:
- a new immutable image signature
- Throws:
IOException- if the file cannot be readNullPointerException- ifpathis nullIllegalArgumentException- if file bytes are not a readable PNG, JPEG or static SVG image
-
sizeMm
Creates a signature refitted from the original image bytes into the given box. The aspect ratio is preserved, so at least one resulting dimension may be smaller than the box. This operation may enlarge the image; it does not mutate this signature.- Parameters:
maxWidth- finite positive maximum width in millimetersmaxHeight- finite positive maximum height in millimeters- Returns:
- a new fitted immutable image signature
- Throws:
IllegalArgumentException- if either dimension is nonpositive or nonfinite
-
blocks
Exposes the ordered immutable blocks represented by this signature part. Text parts produce paragraphs; image parts produce one fitted image block.- Specified by:
blocksin interfaceSignatureContent- Returns:
- immutable signature blocks, in display order
-