You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2016/02/24 20:14:18 UTC

[jira] [Commented] (PDFBOX-3246) Rendering PDF containing Jpeg2000 with red color

    [ https://issues.apache.org/jira/browse/PDFBOX-3246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15163546#comment-15163546 ] 

Tilman Hausherr commented on PDFBOX-3246:
-----------------------------------------

The size of the raster that is returned is 1087480 bytes. The content are 00 and FF bytes. The image size is 2480 x 3508 = 8699840 pixels. 

bitsPerComponent is 1 (from the dictionary), and numComponents is 3 (from the awt colorspace) so the created raster in SampleImageReader.Raster.createBandedRaster() is 3x too large. The 3 is wrong, there's really just one component as seen by raster size.

Using 1 for numComponents doesn't work (brings error later).

What does work is this "desperate" solution, copying the actual colors into a clean RGB image object with a byte raster:
{code}
// extract embedded color space
if (!parameters.containsKey(COSName.COLORSPACE))
{
	//result.setColorSpace(new PDJPXColorSpace(image.getColorModel().getColorSpace()));
	int w = image.getWidth();
	int h = image.getHeight();
	BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_3BYTE_BGR);
	for (int x = 0; x < w; ++x)
		for (int y = 0; y < h; ++y)
		{
			int rgb = image.getRGB(x, y);
			bim.setRGB(x, y, (rgb << 16) & 0xFF0000 | (rgb >> 16) & 0xFF | rgb & 0xFF00);
		}
	parameters.setInt(COSName.BITS_PER_COMPONENT, 8);
	result.setColorSpace(new PDJPXColorSpace(ColorSpace.getInstance(ColorSpace.CS_sRGB)));
	return bim;
}
{code}
However I won't commit because the other error (the spots) doesn't go away.

> Rendering PDF containing Jpeg2000 with red color
> ------------------------------------------------
>
>                 Key: PDFBOX-3246
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3246
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Rendering
>    Affects Versions: 2.0.0
>            Reporter: Tilman Hausherr
>              Labels: JPG2000, JPXDecode, JPXFilter
>         Attachments: LI_Eingangsrechnung_ERX2388_2016_02_11_133551 v1_0.pdf
>
>
> From Manfred P. from the mailing list
> {quote}
> enclosed a pdf which is rendered incorrect, wrong background-color, different black squares on the page, where no one should be. 
> {quote}
> The spots are the problem mentioned in PDFBOX-1752. The red background is something different.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org