java.lang.ArrayIndexOutOfBoundsException: 17
helcat opened this issue · 3 comments
I downloaded your folk and built the jar file, the error did not appear but it still did not render the pdf to an image. I Got another error.
java.lang.ArrayIndexOutOfBoundsException: 17
at com.sun.pdfview.PDFImage.biColorToGrayscale(Unknown Source)
at com.sun.pdfview.PDFImage.parseData(Unknown Source)
at com.sun.pdfview.PDFImage.getImage(Unknown Source)
at com.sun.pdfview.PDFImage.parseData(Unknown Source)
at com.sun.pdfview.PDFImage.getImage(Unknown Source)
at com.sun.pdfview.PDFRenderer.drawImage(Unknown Source)
at com.sun.pdfview.PDFImageCmd.execute(Unknown Source)
at com.sun.pdfview.PDFRenderer.iterate(Unknown Source)
at com.sun.pdfview.BaseWatchable.run(Unknown Source)
at com.sun.pdfview.BaseWatchable.execute(Unknown Source)
at com.sun.pdfview.BaseWatchable.go(Unknown Source)
at com.sun.pdfview.PDFPage.getImage(Unknown Source)
I tried other pdfs but anything with layers or shading seems to stacktrace.
Any help would be appreciated.
Your responce :
the issue that you mentioned is a problem with my fork and not related to this bug, since the method "biColorToGrayscale" was introduced by me to speed up the handling of black and white images. Hence, can you please open an new issue on the forks page and attach an example, then I can look at this bug.
Code
byte[] buffer = ((DataBufferByte) converted.getRaster().getDataBuffer()).getData();
int i = 0;
final int height = converted.getHeight();
final int width = converted.getWidth();
for (int y = 0; y < height; y++) {
int base = y_width + 7;
if ((y+1)_width < buffer.length) {
for (int x = 0; x < width; x += 8) {
final byte bits = bufferO[i];
i++;
if (base > buffer.length -1) break; <= ** Added by me just to stop it from crashing I know this is wrong.
buffer[base - 7] = ncc[((bits >>> 7) & 1)];
buffer[base - 6] = ncc[((bits >>> 6) & 1)];
buffer[base - 5] = ncc[((bits >>> 5) & 1)];
buffer[base - 4] = ncc[((bits >>> 4) & 1)];
buffer[base - 3] = ncc[((bits >>> 3) & 1)];
buffer[base - 2] = ncc[((bits >>> 2) & 1)];
buffer[base - 1] = ncc[((bits >>> 1) & 1)];
buffer[base] = ncc[(bits & 1)];
base += 8;
}
}
else {
for (int x = 0; x < width; x += 8) {
final byte bits = bufferO[i];
i++;
for (byte j=7; j>=0; j--) {
if (base - j >= buffer.length) break;
buffer[base - j] = ncc[((bits >>> j) & 1)];
}
base += 8;
}
}
}
I know this is wrong but i wanted it yo stop crashing.
if (base > buffer.length -1) break;
With this it renders the image but the colors are wrong.
I dont know how to submit an example.
Hi,
the bug you describe was fixed. Furthermore the handling of colorspaces was improved and most parts of your example are rendered correctly. There is still an issue (the gray shapes) which I have not figured out.
Thanks for fixing the bug, how do you add attchments to comments.
I would like to show you some other defects. Its not crashing it just seems to be some images that are layered that are either not appering or washed out.
Fonts seem to be fine on must of the pdfs.
I think your doing a great job thank you.
Attaching files to github issues is not possible, I hope they will add
this feature soon. Until then you can upload the pdf file to a
sharehoster and post the link.
On Wed, Apr 18, 2012 at 19:37, helcat
reply@reply.github.com
wrote:
Thanks for fixing the bug, how do you add attchments to comments.
I would like to show you some other defects. Its not crashing it just seems to be some images that are layered that are either not appering or washed out.Fonts seem to be fine on must of the pdfs.
I think your doing a great job thank you.
Reply to this email directly or view it on GitHub:
#1 (comment)