title: PosPrinter PrintMemoryBitmap throws illegal exception
body: <p>I'm using the <code>Microsoft.PointOfService</code> library to control an Epson POS receipt printer. I'm trying to add logos to the receipts, but I can't seem to get the <code>PrintMemoryBitmap(...)</code> function to work. The <code>PrintBitmap(...)</code> function works just fine, but for my application, it would be much more efficient to print a bitmap from memory, instead of saving the image to the file system.</p>
  <p>My code is:</p>
  <pre><code>printer.PrintMemoryBitmap(PrinterStation.Receipt, logoBitmap, PosPrinter.PrinterBitmapAsIs, PosPrinter.PrinterBitmapCenter);
  </code></pre>
  <p>But when I run this, I get the following error:</p>
  <pre><code>ErrorCode:
  Illegal
  
  ExtendedErrorCode:
  300002
  
  Message:
  Method PrintMemoryBitmap threw an exception.  Attempt was made to perform an illegal or unsupported operation with the device, or an invalid parameter value was used.
  
  StackTrace:
  at Microsoft.PointOfService.Legacy.LegacyProxy.ThrowLegacyMethodException(String methodName, Int32 ResultCode, Exception e)
  at Microsoft.PointOfService.Legacy.LegacyProxy.InvokeMethod(String methodName, Object[]&amp; parameters, Boolean[] byRef)
  at Microsoft.PointOfService.Legacy.LegacyProxy.InvokeMethodAndCheckImpl(String methodName, Object[]&amp; parameters, Boolean[] byRef)
  at Microsoft.PointOfService.Legacy.LegacyProxy.InvokeMethodAndCheck(String methodName, Object param1, Object param2, Object param3, Object param4, Object param5)
  at Microsoft.PointOfService.Legacy.LegacyPosPrinter.PrintMemoryBitmap(PrinterStation station, Bitmap data, Int32 width, Int32 alignment)
  at ReceiptLogoDemo.frmPrinterDemo.btnPrintLogo_Click(Object sender, EventArgs e) in C:\projects\receiptLogoDemo\receiptLogoDemo\frmPrinterDemo.cs:line 138
  </code></pre>
  <p>I have checked the meaning of the <code>Illegal</code> error code (<a href="https://docs.microsoft.com/en-us/previous-versions/windows/embedded/bb404518(v=winembedded.4)#remarks" rel="nofollow noreferrer">here</a>), and I have confirmed that none of the things listed there are the issue. Also, considering that the <code>PrintBitmap(...)</code> function works just fine, this really has me stumped.</p>
  <p>Any ideas or suggestions would be greatly appreciated!</p>