public async static Task GetTicketImage(string ticketID) { WebClient wc = new WebClient(); byte[] data = await wc.DownloadDataTaskAsync(new Uri(baseURI + "api/games/getUserTicketPrintForPOS?ticketid=" + ticketID)); MemoryStream memstream = new MemoryStream(data); if (memstream.Length < 100) { MessageBox.Show("Could not get image for ticket " + ticketID, "Error", MessageBoxButtons.OK); return; } Image img = Image.FromStream(memstream); float aspect = (float)img.Height / (float)img.Width; Bitmap bmp = ResizeImage(img, Configuration.ImagePrintWidth, (int)(Configuration.ImagePrintWidth * aspect)); bmp = BitmapTo1Bpp(bmp); MemoryStream ms = new MemoryStream(); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); bmp.Save(path + "\\temp.bmp", ImageFormat.Bmp); //img = resize(img, new System.Drawing.Size(100, 100)); Epic3000.InitializePrinter(); Epic3000.SetCenterJustify(); Epic3000.AppendBufferRaw(new byte[] { 27, 64, 27, 116, 0 }); Epic3000.DrawImage(path + "\\temp.bmp"); Epic3000.AppendBufferRaw(new byte[] { 13, 12 }); Epic3000.LineFeed(8); Epic3000.CutPaper(); Epic3000.LineFeed(3); Epic3000.SendBufferAndClear(); }
public async static Task GetTicketImageFromPath(string imagePath) //TEMPORARY I HOPE { //WebClient wc = new WebClient(); //byte[] data = wc.DownloadData(new Uri("http://dev-tribal-api.shoutz.com/getticketimg2.php?ticketid=" + ticketID)); System.IO.FileStream data = new System.IO.FileStream(imagePath, System.IO.FileMode.Open, System.IO.FileAccess.Read); Image img = Image.FromStream(data); float aspect = (float)img.Height / (float)img.Width; Bitmap bmp = ResizeImage(img, Configuration.ImagePrintWidth, (int)(Configuration.ImagePrintWidth * aspect)); bmp = BitmapTo1Bpp(bmp); MemoryStream ms = new MemoryStream(); string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); bmp.Save(path + "\\temp.bmp", ImageFormat.Bmp); //img = resize(img, new System.Drawing.Size(100, 100)); Epic3000.InitializePrinter(); Epic3000.SetCenterJustify(); Epic3000.AppendBufferRaw(new byte[] { 27, 64, 27, 116, 0 }); Epic3000.DrawImage(path + "\\temp.bmp"); Epic3000.AppendBufferRaw(new byte[] { 13, 12 }); Epic3000.LineFeed(5); Epic3000.CutPaper(); Epic3000.SendBufferAndClear(); }
static void Main(string[] args) { e3kdrv.Epic3000.InitializePrinter(); Epic3000.LineFeed(3); Epic3000.SetCenterJustify(); Epic3000.DrawImage("c://f9.bmp"); string barcode = "[00]123456789101112133"; byte[] bytes = Encoding.GetEncoding(1252).GetBytes(barcode); Epic3000.LineFeed(3); Epic3000.DrawBarcode(bytes, 3, 3); Epic3000.WriteAlignCenter("1 2 3 4 5 6 7 8 9 10 11 12 13"); Epic3000.LineFeed(15); Epic3000.CutPaper(); Epic3000.SendBuffer(); }