Bug 98537 - pdftoppm -tiff -gray/-mono generates wrong image
Summary: pdftoppm -tiff -gray/-mono generates wrong image
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: utils (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-02 03:39 UTC by kenjiuno
Modified: 2016-11-29 00:41 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description kenjiuno 2016-11-02 03:39:51 UTC
Hi.

pdftoppm -tiff -gray generates horizontally 3x stretched image.
pdftoppm -tiff -mono generates a kind of messed up image.

TiffWriter::writePointers and
TiffWriter::writeRow seem to accept native rowData (1bpp and 8bpp) rather than 24bpp RGB pixel format.

I have fixed it by adding supportNativeMonoRowData to ImgWriter.

My commit/patch is here. This can be used to fix the problem! However the branch pdftoppm-pdftotif also contains my extra stuff like -singletiff option.

https://github.com/HiraokaHyperTools/poppler_mirror/commit/6716c91ce2b84ad2b44745e4b5efafd9443fb675

kenjiuno
Comment 1 Adrian Johnson 2016-11-02 11:45:33 UTC
The format parameter to the image writers defines the pixel format so there is no need to add the supportNativeMonoRowData() function.

I would suggest adding the data:

 SplashColorMode imageWriterFormat;

to SplashBitmap.h.

In writeImgFile() (line 353), set imageWriterFormat to the format to supply to writeRow().

ie splashModeMono8 for TiffWriter(TiffWriter::GRAY),
   splashModeMono1 for TiffWriter(TiffWriter::MONO), and 
   splashModeRGB8 for everything else.

Then use imageWriterFormat in writeImgFile() (line 620) to determine the data format to use for mode = splashModeMono8 or splashModeMono1.
Comment 2 kenjiuno 2016-11-03 01:24:07 UTC
Ok, it should be better way. I have rewritten according to your advice!

https://github.com/HiraokaHyperTools/poppler_mirror/commit/ec4fcfc4a30adce1795aaf6ccc2dea8936ab4a3c
Comment 3 Albert Astals Cid 2016-11-25 10:06:57 UTC
Adrian will you review the patch or should I?
Comment 4 Adrian Johnson 2016-11-25 11:15:54 UTC
patch looks good
Comment 5 Albert Astals Cid 2016-11-25 16:21:57 UTC
Pushed with slight changes.
Comment 6 kenjiuno 2016-11-29 00:41:38 UTC
Thank you, it works with no problem!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.