PdfImage.jpeg constructor
PdfImage.jpeg(
- PdfDocument pdfDocument, {
- required Uint8List image,
- PdfImageOrientation? orientation,
Create an image from a jpeg file
Implementation
factory PdfImage.jpeg(
PdfDocument pdfDocument, {
required Uint8List image,
PdfImageOrientation? orientation,
}) {
final info = PdfJpegInfo(image);
final im = PdfImage._(
pdfDocument,
info.width!,
info.height,
orientation ?? info.orientation,
);
assert(() {
im.startStopwatch();
im.debugFill('Jpeg Image ${info.width}x${info.height}');
return true;
}());
im.params['/BitsPerComponent'] = const PdfNum(8);
im.params['/Name'] = PdfName(im.name);
im.params['/Intent'] = const PdfName('/RelativeColorimetric');
im.params['/Filter'] = const PdfName('/DCTDecode');
if (info.isRGB) {
im.params['/ColorSpace'] = const PdfName('/DeviceRGB');
} else {
im.params['/ColorSpace'] = const PdfName('/DeviceGray');
}
im.buf.putBytes(image);
assert(() {
im.stopStopwatch();
return true;
}());
return im;
}