Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void PPMImageReader_correctly_parses_P6_file()
        {
            var reader = new PPMReader("test1.ppm");
            var file   = reader.ReadFile();

            Assert.AreEqual(1, file.BytesPerColor);
            Assert.AreEqual(PPMImageType.P6, file.Type);
            Assert.AreEqual(610, file.Columns);
            Assert.AreEqual(460, file.Rows);
        }