private void CoursePrintingTest(string basename, CoursePrintSettings coursePrintSettings, CourseAppearance appearance, float dpi = 200) { GC.Collect(); // Get the map display MapDisplay mapDisplay = new MapDisplay(); mapDisplay.MapIntensity = 0.6F; mapDisplay.AntiAlias = true; mapDisplay.SetMapFile(controller.MapType, controller.MapFileName); if (controller.MapType == MapType.Bitmap) { mapDisplay.Dpi = controller.MapDpi; } mapDisplay.OcadOverprintEffect = appearance.useOcadOverprint; // Get the pages of the printing. CoursePrinting coursePrinter = new CoursePrinting(controller.GetEventDB(), ui.symbolDB, controller, mapDisplay.CloneToFullIntensity(), coursePrintSettings, appearance); Bitmap[] bitmaps = coursePrinter.PrintBitmaps(); // Check all the pages against the baseline. for (int page = 0; page < bitmaps.Length; ++page) { Bitmap bm = bitmaps[page]; string baseFileName = basename + "_page" + (page + 1).ToString(); TestUtil.CheckBitmapsBase(bm, baseFileName); bm.Dispose(); } #if XPS_PRINTING // Only OCAD maps can be printed in XPS mode. if (controller.MapType == MapType.OCAD) { // Get the pages of the printing in XPS/WPF mode System.Windows.Media.Imaging.BitmapSource[] xpsBitmaps = coursePrinter.PrintXpsBitmaps(dpi); // Check all the pages against the baseline. for (int page = 0; page < xpsBitmaps.Length; ++page) { var bm = xpsBitmaps[page]; string baseFileName = basename + "_xps_page" + (page + 1).ToString(); string newFileName = TestUtil.GetTestFile(basename + "_xps_page" + (page + 1).ToString() + "_new"); WritePng(bm, newFileName); Bitmap newBitmap = (Bitmap)Image.FromFile(newFileName); // For some reason, the XPS anti-aliasing varies slightly. Allow pixel difference to account. TestUtil.CheckBitmapsBase(newBitmap, baseFileName, 25); } } #endif // XPS_PRINTING }
public void AdjustDpi() { float result; result = CoursePrinting.AdjustDpi(300); Assert.AreEqual(600, result); result = CoursePrinting.AdjustDpi(600); Assert.AreEqual(600, result); result = CoursePrinting.AdjustDpi(720); Assert.AreEqual(720, result); result = CoursePrinting.AdjustDpi(1800); Assert.AreEqual(900, result); result = CoursePrinting.AdjustDpi(100); Assert.AreEqual(400, result); result = CoursePrinting.AdjustDpi(300); Assert.AreEqual(600, result); }
private void CoursePrintingTest(string basename, CoursePrintSettings coursePrintSettings, CourseAppearance appearance, float dpi = 200) { GC.Collect(); // Get the map display MapDisplay mapDisplay = new MapDisplay(); mapDisplay.MapIntensity = 0.6F; mapDisplay.AntiAlias = true; mapDisplay.SetMapFile(controller.MapType, controller.MapFileName); if (controller.MapType == MapType.Bitmap) mapDisplay.Dpi = controller.MapDpi; mapDisplay.OcadOverprintEffect = appearance.useOcadOverprint; // Get the pages of the printing. CoursePrinting coursePrinter = new CoursePrinting(controller.GetEventDB(), ui.symbolDB, controller, mapDisplay.CloneToFullIntensity(), coursePrintSettings, appearance); Bitmap[] bitmaps = coursePrinter.PrintBitmaps(); // Check all the pages against the baseline. for (int page = 0; page < bitmaps.Length; ++page) { Bitmap bm = bitmaps[page]; string baseFileName = basename + "_page" + (page + 1).ToString(); TestUtil.CheckBitmapsBase(bm, baseFileName); bm.Dispose(); } // Only OCAD maps can be printed in XPS mode. if (controller.MapType == MapType.OCAD) { // Get the pages of the printing in XPS/WPF mode System.Windows.Media.Imaging.BitmapSource[] xpsBitmaps = coursePrinter.PrintXpsBitmaps(dpi); // Check all the pages against the baseline. for (int page = 0; page < xpsBitmaps.Length; ++page) { var bm = xpsBitmaps[page]; string baseFileName = basename + "_xps_page" + (page + 1).ToString(); string newFileName = TestUtil.GetTestFile(basename + "_xps_page" + (page + 1).ToString() + "_new"); WritePng(bm, newFileName); Bitmap newBitmap = (Bitmap)Image.FromFile(newFileName); // For some reason, the XPS anti-aliasing varies slightly. Allow pixel difference to account. TestUtil.CheckBitmapsBase(newBitmap, baseFileName, 19); } } }