Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }