Click here to Skip to main content
15,744,193 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can't seem to find a good reference or example for writting pbm image.

What I have tried:

Have googled extensively but can't seem to find a way to read/write pbm image. I have created a few classes to read/write ppm and pgm image but the pbm image has me stumped
Updated 14-Nov-22 6:31am

See The PBM Format[^] for details and links to libraries.
Share this answer
charles henington 16-Nov-22 23:36pm    
I have read this. I'm assuming my issue is how to pack the bool values(black or white) to a single byte?
Richard MacCutchan 17-Nov-22 3:34am    
Sorry, I have no idea what you are referring to.
charles henington 17-Nov-22 22:03pm    
From the link you gave?

"A raster of Height rows, in order from top to bottom. Each row is Width bits, packed 8 to a byte, with don't care bits to fill out the last byte in the row. Each bit represents a pixel: 1 is black, 0 is white. The order of the pixels is left to right. The order of their storage within each file byte is most significant bit to least significant bit. The order of the file bytes is from the beginning of the file toward the end of the file.

A row of an image is horizontal. A column is vertical. The pixels in the image are square and contiguous. "
Richard MacCutchan 18-Nov-22 2:34am    
OK, so what now?
charles henington 19-Nov-22 7:16am    
Attempt to write my own version of pbm(already have) but the resulting file isn't a pbm file(run on Linux so these image formats are natively supported). I will continue to look into how to achieve the true pbm output and hopefully someone who understands the packing process may be able to help me understand.
Share this answer
charles henington 16-Nov-22 23:43pm    
Thanks, I should have mentioned that I'd prefer to write the code as opposed to using code. Self taught just looking to learn but also need a C# code example or reference
RickZeeland 17-Nov-22 4:10am    
I understand, but you can look at the Go code to glean how it works and then write your own C# code ...
charles henington 17-Nov-22 22:07pm    
Looked at the code, could not begin to explain what's going on in go.
RickZeeland 18-Nov-22 0:35am    
That's a no-Go then :)
charles henington 19-Nov-22 7:17am    
Unless you may be able to help me understand what the Go code is doing lol

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900