extractSvsImageAsJpeg function
Extracts an associated image (e.g. 'thumbnail', 'label', or 'macro') from an SVS file and returns it as encoded JPEG bytes.
Handles decompression (JPEG strips with JPEGTables, JPEG 2000, LZW with predictor, uncompressed RGB, Deflate) and stitches multi-strip images into a unified JPEG image.
svs is the open SvsFile.
type is the image type identifier to extract ('thumbnail', 'label', or 'macro').
quality is the JPEG encoding quality (1 to 100, default is 90).
applyColorScheme if true, applies the appropriate color scheme interpretation.
applyDisplayColor if true, applies the DisplayColor color tinting/mapping if present in metadata or passed explicitly.
displayColor optional explicit display color override (e.g., 0xRRGGBB).
Returns the JPEG encoded byte data, or null if the requested image type was not found or failed to decode.
Implementation
Future<Uint8List?> extractSvsImageAsJpeg(
SvsFile svs,
String type, {
int quality = 90,
bool applyColorScheme = true,
bool applyDisplayColor = true,
int? displayColor,
}) async {
final image = await extractSvsImageAsImage(
svs,
type,
applyColorScheme: applyColorScheme,
applyDisplayColor: applyDisplayColor,
displayColor: displayColor,
);
if (image == null) return null;
return Uint8List.fromList(img.encodeJpg(image, quality: quality));
}