public void ResizeWidthTest() { // Input are expected are provided as resources, dithered is what // we are testing Bitmap input = Properties.Resources.white_bitmap; using (var logo = new PrinterImage(input)) { // Use the RoundUp method since that is done internally // in PrinterImage. This is to allow for Assert.AreEqual tests // First scale down by 50% var shrink = (input.Width / 2).RoundUp(8); var expectedH = (input.Height / 2).RoundUp(8); logo.Resize(shrink, 0, true); Assert.AreEqual(shrink, logo.Width); Assert.AreEqual(expectedH, logo.Height); // Now double in size var grow = (input.Width * 2).RoundUp(8); expectedH = (input.Height * 2).RoundUp(8); logo.Resize(grow, 0, true); Assert.AreEqual(grow, logo.Width); Assert.AreEqual(expectedH, logo.Height); }; }
public void ApplyColorInversionTest() { // Input are expected are provided as resources, dithered is what // we are testing Bitmap input, inverted, expected; input = Properties.Resources.white_bitmap; var path = Path.Combine(baseDir, "white_inverse_test.bmp"); input.Save(path); using (var logo = new PrinterImage(path)) { logo.Resize(input.Width, 0, true); Assert.IsFalse(logo.IsInverted); logo.ApplyColorInversion(); inverted = logo.ImageData.ToBitmap(); expected = Properties.Resources.black_bitmap; // White should ivnert to black Assert.IsTrue(ImageTestHelpers.CompareMemCmp(expected, inverted)); Assert.True(logo.IsInverted); // Flip back to white, test that the inversion flag is cleared logo.ApplyColorInversion(); Assert.IsFalse(logo.IsInverted); }; }
/// <inheritdoc /> public override void SetImage(PrinterImage image, IDocument doc, int index) { while (index > doc.Sections.Count) { doc.Sections.Add(new Placeholder()); } doc.Sections[index] = new RelianceImageSection() { Image = image, }; }
public void ResizeZeroExceptionTest() { Bitmap input = Properties.Resources.white_bitmap; using (var logo = new PrinterImage(input)) { Assert.Throws <ImagingException>(() => logo.Resize(0, 0, true)); } using (var logo = new PrinterImage(input)) { Assert.Throws <ImagingException>(() => logo.Resize(0, 0, false)); } }
public void ResizeNoneTest() { // Input are expected are provided as resources, dithered is what // we are testing Bitmap input = Properties.Resources.white_bitmap; using (var logo = new PrinterImage(input)) { var oldW = logo.Width.RoundUp(8); var oldH = logo.Height.RoundUp(8); logo.Resize(logo.Width, logo.Height, false); Assert.AreEqual(oldW, logo.Width); Assert.AreEqual(oldH, logo.Height); } }
/// <summary> /// Phoenix does not currently supports ESC/POS images at this time. /// </summary> /// <param name="image"></param> /// <param name="doc"></param> /// <param name="index"></param> public override void SetImage(PrinterImage image, IDocument doc, int index) { while (index > doc.Sections.Count) { doc.Sections.Add(new Placeholder()); } doc.Sections[index] = new StandardSection() { Content = "\nImage section is not supported on Phoenix\n", Effects = FontEffects.Bold, HeightScalar = FontHeighScalar.h2, WidthScalar = FontWidthScalar.w2, Justification = FontJustification.JustifyCenter, AutoNewline = true, }; }
/// <inheritdoc /> public abstract void SetImage(PrinterImage image, IDocument doc, int index);