diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2010-01-23 22:16:50 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2010-01-23 22:16:50 +0000 |
commit | 651d68f5652c36fbb260334f1a46a2705d8a0de8 (patch) | |
tree | 38e2dc4e32f6083d70543f10bde17a3531ea8691 /converter/other/pnmtopalm/palmtopnm.c | |
parent | d87a19306b69fa7e537b265983b54071805a5eb5 (diff) | |
download | netpbm-mirror-651d68f5652c36fbb260334f1a46a2705d8a0de8.tar.gz netpbm-mirror-651d68f5652c36fbb260334f1a46a2705d8a0de8.tar.xz netpbm-mirror-651d68f5652c36fbb260334f1a46a2705d8a0de8.zip |
Release 10.35.73
git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@1103 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other/pnmtopalm/palmtopnm.c')
-rw-r--r-- | converter/other/pnmtopalm/palmtopnm.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/converter/other/pnmtopalm/palmtopnm.c b/converter/other/pnmtopalm/palmtopnm.c index 9cd695e3..f2febef1 100644 --- a/converter/other/pnmtopalm/palmtopnm.c +++ b/converter/other/pnmtopalm/palmtopnm.c @@ -321,10 +321,13 @@ interpretHeader(struct palmHeader * const palmHeaderP, palmHeaderP->transparentValue = transparentValue; palmHeaderP->transparentIndex = transparentIndex; - if (palmHeaderP->version == 3 && (flags & PALM_DIRECT_COLOR_FLAG)) - /* There's no directColorInfoType section in a version 3 Palm Bitmap */ - pm_error("PALM_DIRECT_COLOR_FLAG is not valid for version 3 " - "encoding type."); + if (palmHeaderP->version == 3 && ((flags & PALM_DIRECT_COLOR_FLAG) && + (pixelFormat != PALM_FORMAT_565))) + /* There's no directColorInfoType section in a version 3 Palm Bitmap + so we also need PALM_FORMAT_565 for this flag to make sense + */ + pm_error("PALM_DIRECT_COLOR_FLAG is set but pixelFormat is not" + "PALM_FORMAT_565."); palmHeaderP->directColor = ((flags & PALM_DIRECT_COLOR_FLAG) || palmHeaderP->pixelFormat == PALM_FORMAT_565); @@ -629,11 +632,18 @@ getColorInfo(struct palmHeader const palmHeader, directColorInfoP->pixelFormat.redbits = 5; directColorInfoP->pixelFormat.greenbits = 6; directColorInfoP->pixelFormat.bluebits = 5; - /* FIXME Just guessing here ... */ directColorInfoP->transparentColor = - (((palmHeader.transparentValue >> 11) & 0x1F) << 16) | - (((palmHeader.transparentValue >> 5) & 0x3F) << 8) | - (((palmHeader.transparentValue >> 0) & 0x1F) << 0); + /* See convertRowToPnmDirect for this trick + + This will break once maxval isn't always set 255 for + directColor + */ + ((((palmHeader.transparentValue >> 11) & 0x1F) * 255 / 0x1F) + << 16) | + ((((palmHeader.transparentValue >> 5) & 0x3F) * 255 / 0x3F) + << 8) | + ((((palmHeader.transparentValue >> 0) & 0x1F) * 255 / 0x1F) + << 0); } else if (palmHeader.directColor) { *colormapP = NULL; *directColorInfoP = directInfoType; |