Support for PAM P7 4 byte TUPLTYPE GRAYSCALE_ALPHA

Ideas for improvements and requests for new features in XnView MP

Moderators: XnTriq, xnview

Post Reply
brianp
Posts: 4
Joined: Sun Oct 06, 2019 3:21 pm

Support for PAM P7 4 byte TUPLTYPE GRAYSCALE_ALPHA

Post by brianp » Sun Oct 06, 2019 4:44 pm

I am running 64 bit Linux and need a viewer for 4 byte per pixel grayscale with Alpha images. 64k grayscale with 64k alpha.

LodePNG works, but takes forever. By "works" I mean that it creates files which display correctly in Photoshop CS6, GIMP, Gwenview and ShowFOTO.

I hand rolled a PNG creator from scratch based on the PNG spec and it is much faster but still calculates the CRC (not necessary) and runs through zlib which adds 11kB and is unnecessary.

I found the PAM, P7 format which seems to be ideal and which is supposed to be supported by XnView. It has a very simple header followed by uint16 pairs for the gray value and the opacity.

The file has the exact size and the above header: Size = 4 bytes/quantum * 7360 xres * 4912 yres + 79 header_bytes =
lsr -s *.pam -> pf-269367.blu.alp.lp.pam 144609359

head -n7 pf-269367.blu.alp.lp.pam
P7
WIDTH 7360
HEIGHT 4912
DEPTH 4
MAXVAL 65535
TUPLTYPE GRAYSCALE_ALPHA
ENDHDR

When I open it in XnView MP Linux Version 0.93.1 64bits (Mar 7 2019) Libformat version 7.25, It pops up Firefox and asks me to save the file.

Png indexed files show in the XnView GUI.

The PAM file extension is not shown in the about -> formats, nor is it listed in portable grayscale* or image*

Is it possible to add grayscale-alpha support with 16 bits of each to XnView?

When I open the PNG files with 16 bit grayscale and 16 bit Alpha in XnView, it asks me to confirm "convert to RGB with 8 bits". It appears to discard the opacity entirely and show the 16 bit image data noticeably downgraded to 8 bit quanta.

Is 8 bits/channel, RGB/24 the maximum quantum depth XnView will show?

User avatar
xnview
Author of XnView
Posts: 33425
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Support for PAM P7 4 byte TUPLTYPE GRAYSCALE_ALPHA

Post by xnview » Fri Nov 22, 2019 11:08 am

could you send me some sample files?
Pierre.

brianp
Posts: 4
Joined: Sun Oct 06, 2019 3:21 pm

Re: Support for PAM P7 4 byte TUPLTYPE GRAYSCALE_ALPHA

Post by brianp » Fri Jan 31, 2020 8:57 pm

Pierre,
The P7 files are made from a uint16_t channel from a camera raw file and another uint16_t OPACity channel, 0 -> invisible, 65535 -> fully opaque. 4 bytes per pixel. The Opacity is intended to make poorly exposed areas invisible while keeping the good parts. The Opacity is 16 bits to match the Grayscale value and to ensure smooth translations between the well exposed parts on each layer. The goal is an HDR product with smooth transitions between many frames.

The full size PAM images are 36 MPix and 144 MBytes. ImageMagick takes 12 seconds to convert the pam to a png. And, it always seems to compress the bitmap as the size (and md5sum) is the same with or without the convert '-compress None' option.

The 7 line PAM header: #> head -n7 pf-269369.red.div5_sin.0.5_1.03.pam
P7
WIDTH 1476
HEIGHT 985
DEPTH 2
MAXVAL 65535
TUPLTYPE GRAYSCALE_ALPHA
ENDHDR

Here is the .PAM file: pf-269369.red.div5_sin.0.5_1.03.pam
https://www.sendspace.com/file/0t80zw

PAM file converted to PNG: pf-269369.red.div5_sin.0.5_1.03.png
https://www.sendspace.com/file/d0u7y3

PAM grayscale, same as original raw .pgm file: pf-269369.red.div5_sin.0.5_1.03.pam.n.pgm
https://www.sendspace.com/file/y78kjq

PAM Alpha channel as PGM: pf-269369.red.div5_sin.0.5_1.03.pam.a.pgm
https://www.sendspace.com/file/3pfscb

Top 3 rows are the PAM file flattened against black, white and gray checkerboard backgrounds
The middle 2 are the Gray and Opacity (Alpha) channels as uint16 PGM files split from the .PAM
The 3 bottom rows are the same as the top row with the Opacity and Grayscale values swapped
pf-269369.red.div5_sin.0.5_1.03.pam.mos.pgm
pf-269369.red.div5_sin.0.5_1.03.pam.mos.jpg

Post Reply