Example #1
0
 public Track ParseTrack(string filePath)
 {
     using (Stream stream = MapImageIO.LoadImgToStream(filePath))
     {
         return(ParseTrack(stream));
     }
 }
Example #2
0
        private static bool TestBitMapSaving()
        {
            string jpgPath =
                Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                              @"..\..\..\PV178.Homeworks.HW05\Content\Map\map.jpg"));

            using (var bitmapStream = MapImageIO.LoadImgToStream(jpgPath))
            {
                Bitmap       bmp       = new Bitmap(bitmapStream);
                BitmapDrawer bmpDrawer = new BitmapDrawer(bitmapStream);

                using (var resultStream = bmpDrawer.SaveBitmapToStream())
                    using (var expectedStream = new MemoryStream())
                    {
                        bmp.Save(expectedStream, bmp.RawFormat);

                        if (resultStream.Length != expectedStream.Length)
                        {
                            return(false);
                        }

                        int resultByte, expectedByte;

                        do
                        {
                            resultByte   = resultStream.ReadByte();
                            expectedByte = expectedStream.ReadByte();

                            if (resultByte != expectedByte)
                            {
                                return(false);
                            }
                        } while (resultByte != -1 && expectedByte != -1);

                        return(true);
                    }
            }
        }