Am 05.03.2019 um 09:54 schrieb Matteo Gamboz:
I must yet fix the image parameters to correctly represent the new
image data, but it seems feasible.
operator.getImageParameters():
COSDictionary{COSName{IM}:true;COSName{W}:COSInt{114};COSName{H}:COSInt{73};COSName{BPC}:COSInt{1};COSName{F}:COSName{CCF};COSName{DP}:COSDictionary{COSName{K}:COSInt{-1};COSName{Columns}:114;};}
helper_img:
COSDictionary{COSName{Length}:COSInt{23};COSName{Type}:COSName{XObject};COSName{Subtype}:COSName{Image};COSName{Filter}:COSName{FlateDecode};COSName{BitsPerComponent}:COSInt{8};COSName{Width}:COSInt{31};COSName{Height}:COSInt{20};COSName{ColorSpace}:COSName{DeviceRGB};COSName{DecodeParms}:COSDictionary{COSName{BitsPerComponent}:8;COSName{Predictor}:COSInt{15};COSName{Columns}:31;COSName{Colors}:COSInt{3};};COSName{SMask}:COSDictionary{COSName{Length}:COSInt{26};COSName{Type}:-1148588617;COSName{Subtype}:70760763;COSName{Filter}:1578622202;COSName{BitsPerComponent}:8;COSName{Width}:31;COSName{Height}:20;COSName{ColorSpace}:COSName{DeviceGray};}COSStream{-856922952};}COSStream{-84829761}
You are running this:
newBIoperator.setImageParameters(operator.getImageParameters());
So you're taking the parameter of the old image to the new image. This
is problematic (may be my fault!), the size isn't the same, the filter
isn't the same, the bitspercomponent isn't the same. And then there's
the problem that your original image is a mask, so the new one should be
too, so the new one should also be a bitonal image but it isn't.
I made two changes:
//InputStream img_data_stream =
helper_img.createInputStream();
InputStream img_data_stream =
helper_img.getCOSObject().createRawInputStream();
This is because the raw stream is when the filter have been applied.
...
//newBIoperator.setImageParameters(operator.getImageParameters());
newBIoperator.setImageParameters(helper_img.getCOSObject());
Another thing you should fix yourself. If the image is a stencil, create
a TYPE_BYTE_BINARY BufferredImage (and later call setStencil()). If the
image is of colorspace DeviceGray, create a TYPE_BYTE_GRAY
BufferedImage. I not, then RGB, NOT ARGB.
Please fix that also try finding a PDF that has an inline image where
something can be seen, the current one is white.
After all these are done, please upload your code and source PDF again.
Tilman
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]