public Bitmap LoadPPMImage(string fileName) { using (var ppmReader = new PPMReader(fileName)) { try { _image = ppmReader.ReadFile(); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } } Bitmap bitmap; if (_image.Type == PPMImageType.P6) { int maxR = 0, maxG = 0, maxB = 0; bitmap = PPM_P6Parser.Parse(_image, ref maxR, ref maxG, ref maxB); _image.MaxR = maxR; _image.MaxG = maxG; _image.MaxB = maxB; } else { bitmap = PPM_P3Parser.Parse(_image); } return(bitmap); }
public void Scale(PPMImage image) { Bitmap bitmap; if (image.Type == PPMImageType.P3) { bitmap = PPM_P3Parser.Scale(image); } else { bitmap = PPM_P6Parser.Scale(image); } ImageCanvas.Source = BitmapConverter.GetBitmapSource(bitmap); }