I have a JPEG image on the device which I want to draw on a canvas to compose a simple PDF (just the image) using (PdfDocument).
The only way that the Canvas api seems to offer to draw an image, is to give it a Bitmap, to decode my JPEG into a Birmap and have all its date accessible the image size will largly increase. (Would look like this)
val imageStream = contentResolver.openInputStream(it)
val selectedImage = BitmapFactory.decodeStream(imageStream, null, options)!!
pdfDocPage.canvas.drawBitmap(scaledImage, 0f, 0f, Paint())
Since the only way to use PdfDocument is through a Canvas, is there a way to draw an image on a Canvas without decoding it, so the PDF won't end up being 10x larger than the image's size as a JPEG?