Talk:Bitmap/Write a PPM file: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
(added userids to the comments (much later, after the fact).)
Line 1: Line 1:

'''Haskell code wrong?'''
== '''Haskell''' code is wrong? ==
Binary PPM files should have the header "P6", and PPM files in plain ASCII should have the header "P3". However, the Haskell code reads a file in ASCII but checks if its header is "P6", and complains if the file data is raw bytes. That should be corrected.

Binary PPM files should have the header "P6", and PPM files in plain ASCII should have the header "P3". However, the Haskell code reads a file in ASCII but checks if its header is "P6", and complains if the file data is raw bytes. That should be corrected. &nbsp   -- Issam


== Code in '''C#''' is wrong? ==


Code in C# is wrong. using Environment.NewLine will cause the data section to be shifted in a way that the first few RGBRGBRGB... will be lost, and what will be written actually starts with "G", so the output data section will be GBR instead of RGB. this is because Environment.NewLine will write CR+LF (Windows) which is not a single whitespace as the PPM specification says, but in fact two whitespaces.
Code in C# is wrong. using Environment.NewLine will cause the data section to be shifted in a way that the first few RGBRGBRGB... will be lost, and what will be written actually starts with "G", so the output data section will be GBR instead of RGB. this is because Environment.NewLine will write CR+LF (Windows) which is not a single whitespace as the PPM specification says, but in fact two whitespaces.
if Environment.NewLine is substituted with " " (Space), it works.
if Environment.NewLine is substituted with " " (Space), it works. &nbsp   -- Avillen

Revision as of 22:07, 8 July 2020

Haskell code is wrong?

Binary PPM files should have the header "P6", and PPM files in plain ASCII should have the header "P3". However, the Haskell code reads a file in ASCII but checks if its header is "P6", and complains if the file data is raw bytes. That should be corrected. &nbsp   -- Issam


Code in C# is wrong?

Code in C# is wrong. using Environment.NewLine will cause the data section to be shifted in a way that the first few RGBRGBRGB... will be lost, and what will be written actually starts with "G", so the output data section will be GBR instead of RGB. this is because Environment.NewLine will write CR+LF (Windows) which is not a single whitespace as the PPM specification says, but in fact two whitespaces. if Environment.NewLine is substituted with " " (Space), it works. &nbsp   -- Avillen