View Issue Details

IDProjectCategoryView StatusLast Update
0035080FPCFCLpublic2020-08-02 15:47
Reporterhan Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
PlatformWindows 
Fixed in Version3.3.1 
Summary0035080: FCL-image, FPwritePNM can't write 16bit and FPreadPNM reads wrongly 16 bit images
DescriptionThe package FCL-image is in general 16 bit.

Exporting via FPwritePNM is in 8 bit format only. Many software package (PhotoShop, DRRAW can write 16 bit files. Suggest to extend the PNM read and write routine to 16 bit.(RGB48 or Gray16)

Reading of a 16 bit file (.PPM .PGM) looks it is supported in the reader but the the result is wrong. I suspect the HI and LOW bytes are swapped against the semi standard (as by PhotoShop, DCRAW, ASTAP). Suggest to correct this.

And as last suggestion in the writer code is an inefficient test for dataabove 255. Suggest to provide a boolean to set 8 or 16 bit output format.

Note a 16 bit header looks like this (without comments}:

P6 {type P6}
185 {width}
272 {height}
65535 {<==16 bit}

So 65535 rather then 255.


Attached several test files.

Steps To ReproduceUse attached 16 bit file with the reader
TagsNo tags attached.
Fixed in Revision43642
FPCOldBugId
FPCTarget3.2.0
Attached Files

Activities

han

2019-02-13 23:55

reporter  

NETPBM test files.zip (553,440 bytes)

Michael Van Canneyt

2019-12-05 13:52

administrator   ~0119624

Fixed reading, (endianness was to blame) Implemented writing. FullWidth property now enabled16-bit writing.

han

2020-08-02 15:45

reporter   ~0124495

Thanks for the change. I found one bug in fpwritepnm.pp, line 237. For the gray format P5, the big-endian is not applied making the resulting file worthless. I have correct the code and will attach it to the next note.

[code]

- dLine[Coulumn]:=Word(Round(Red*0.299+Green*0.587+Blue*0.114))

+ dLine[Coulumn]:=NToBe(Word(Round(Red*0.299+Green*0.587+Blue*0.114))) {write in big-endian format}
[/code]

han

2020-08-02 15:47

reporter   ~0124496

Update version of fpwritepnm.pp, Corrected for P5 big-endian and updated some comments.
fpwritepnm.zip (2,961 bytes)

Issue History

Date Modified Username Field Change
2019-02-13 23:55 han New Issue
2019-02-13 23:55 han File Added: NETPBM test files.zip
2019-02-14 00:23 Maxim Ganetsky Project Packages => FPC
2019-02-15 13:52 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-02-15 13:52 Michael Van Canneyt Status new => assigned
2019-12-05 13:52 Michael Van Canneyt Status assigned => resolved
2019-12-05 13:52 Michael Van Canneyt Resolution open => fixed
2019-12-05 13:52 Michael Van Canneyt Fixed in Version => 3.3.1
2019-12-05 13:52 Michael Van Canneyt Fixed in Revision => 43642
2019-12-05 13:52 Michael Van Canneyt FPCTarget => 3.2.0
2019-12-05 13:52 Michael Van Canneyt Note Added: 0119624
2020-08-02 15:45 han Status resolved => feedback
2020-08-02 15:45 han Resolution fixed => open
2020-08-02 15:45 han Note Added: 0124495
2020-08-02 15:47 han Note Added: 0124496
2020-08-02 15:47 han File Added: fpwritepnm.zip
2020-08-02 15:47 han Status feedback => assigned