Exemplo n.º 1
0
 private IEnumerable <IEnumerable <TPixelFormat> > ReadPAMData <TPixelFormat>(Stream stream, NetpbmHeader <TPixelFormat> header, IImageFactory <TPixelFormat> imageFactory)
 {
     // read the data!
     for (int r = 0; r < header.Height; ++r)
     {
         yield return(imageFactory.ReadRow(stream, header.Width, header.Components.Count, header.HighestComponentValue));
     }
 }
Exemplo n.º 2
0
 private IEnumerable <IEnumerable <TPixelFormat> > ReadPGMOrPPMData <TPixelFormat>(Stream stream,
                                                                                   NetpbmHeader <TPixelFormat> header, IImageFactory <TPixelFormat> imageFactory)
 {
     // read the bits!
     if (header.ImageType == ImageType.PGM || header.ImageType == ImageType.PPM)
     {
         for (int r = 0; r < header.Height; ++r)
         {
             yield return(imageFactory.ReadRow(stream, header.Width, header.Components.Count, header.HighestComponentValue));
         }
     }
     else if (header.ImageType == ImageType.PlainPGM || header.ImageType == ImageType.PlainPPM)
     {
         for (int r = 0; r < header.Height; ++r)
         {
             yield return(ReadPlainRow(stream, header.Width * header.Components.Count, r == header.Height - 1, imageFactory));
         }
     }
     else
     {
         throw new ArgumentOutOfRangeException("header.ImageType", header.ImageType, "image type unsupported by this method");
     }
 }