Hack Forums
[C#] [SOLVED] Saving picture to PGM format doesn't work properly - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] [SOLVED] Saving picture to PGM format doesn't work properly (/showthread.php?tid=5784850)



[SOLVED] Saving picture to PGM format doesn't work properly - Electron - Jan 14, 2018

Edit: Problem solved!
Anyone who might use this, here is a working link: https://pastebin.com/dHkcwbDH

Hello,

I have a problem with saving an image to .PGM P2 format. Opening a picture works fine but saving it doesn't work. It makes the picture somehow messy. I'm trying to convert the Bitmap to byte[] and then save the byte[] to .PGM file. Note that there will be some processing with the image after opening it, so it should be saved as Bitmap to .PGM in the end.

Code:
https://pastebin.com/1Yt8H072

Usage:
Code
PGM pgm = new PGM(filePath);
toolStripContainer1.ContentPanel.BackgroundImage = pgm.Image;
pgm.Save(filePath);