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

From Rosetta Code
Content added Content deleted
(added userids to the comments (much later, after the fact).)
m (fixed two HTML tags.)
 
Line 2: Line 2:
== '''Haskell''' code is 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. &nbsp   -- Issam
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.     -- Issam




Line 8: Line 8:


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. &nbsp   -- Avillen
if Environment.NewLine is substituted with " " (Space), it works.     -- Avillen

Latest revision as of 22:08, 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.     -- 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.     -- Avillen