I am developing an app using the itext library.
When I access one of my images located in the drawable folder, it is not copied correctly. It is a logo, and it has a transparent part. By including it in the document, the background (which is transparent) becomes black. So the image does include it, but with a black background.
This is my code:
Drawable d = getResources ().getDrawable (R.drawable.logopeq223);
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] bitmapData = stream.toByteArray();
Image imageLogo = Image.getInstance(bitmapData);
imageLogo.scaleAbsolute(70,40);
imageLogo.setAlignment(Element.ALIGN_RIGHT);
document.add(imageLogo);
Look at this line, in it you tell him that you change the format to .jpeg with 100% quality.
That is, it is no longer the png with transparency
Sergio, if you really want to use iText it should be like this:
or similar to your code, loading an image from /assets:
Here you can see more examples.