Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

qz.appendImage() Hard crash on Mac #75

Closed
tresf opened this issue Aug 15, 2015 · 2 comments
Closed

qz.appendImage() Hard crash on Mac #75

tresf opened this issue Aug 15, 2015 · 2 comments

Comments

@tresf
Copy link
Contributor

tresf commented Aug 15, 2015

The attached image crashes QZ Tray out completely with a Mac stacktrace when printed using qz.appendImage().

image_sample_orig_broken

* Image used with written permission from bug submitter.

@tresf
Copy link
Contributor Author

tresf commented Aug 23, 2015

The bugs seems to be specific to Java, Mac and the image format, which is a 1-bit Grayscale PNG image.

A work-around is to use ImageMagic to perform image conversion and forcing the PNG color-type property to zero, which bumps the 1-bit to 8-bit and prevents the crash from occurring via -define png:color-type=0. This has the benefit of maintaining the grayscale palette, but a downside of doubling the image size (e.g. 13KB to 26KB)

convert original-1-bit.png -define png:color-type=0 fixed-8-bit.png

@Vzor-
Copy link
Contributor

Vzor- commented Aug 28, 2015

This issue was with OS X 10.10 but not 10.9.5. It only happens with images that had a palette smaller than 16 colors, or a 4 bit pixel data size.

The fix was to take the palette out and putting it in a 256 color buffered image we can pad out the palette to 8 bits without introducing dithering. Note: If any dithering DOES happen it is due to the strangeness of Java and not the palette.

After the fix we had a similar issue with a full ARBG image that had a BufferedImage.getType() of TYPE_CUSTOM, crash. If any more images crash, log their type, look up the enum in the constant-values section of JavaDocs, then add it to the badTypes array.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants