Ejemplo n.º 1
0
        private async Task DrawChatMessageImage(ChatMessageKey keyInfo, Image background)
        {
            using (Bitmap bmp = Tools.GenerateGenericKeyImage(out Graphics graphics))
            {
                int height     = bmp.Height;
                int width      = bmp.Width;
                int textHeight = bmp.Height - 36;


                Font fontChannel = new Font("Verdana", 40, FontStyle.Bold, GraphicsUnit.Pixel);
                using (GraphicsPath gpath = new GraphicsPath())
                {
                    if (background != null)
                    {
                        // Draw background
                        graphics.DrawImage(background, 0, 0, width, textHeight);
                    }
                    else // If no image, put text in middle of key
                    {
                        textHeight = bmp.Height / 2;
                    }

                    // Set Streamer Name
                    gpath.AddString(keyInfo.KeyTitle,
                                    fontChannel.FontFamily,
                                    (int)FontStyle.Bold,
                                    graphics.DpiY * fontChannel.SizeInPoints / width,
                                    new Point(0, textHeight),
                                    new StringFormat());
                    graphics.DrawPath(Pens.Black, gpath);
                    graphics.FillPath(Brushes.White, gpath);

                    await Connection.SetImageAsync(bmp);

                    fontChannel.Dispose();
                    graphics.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        private async Task DrawChatMessageImage(ChatMessageKey keyInfo, Image background)
        {
            Bitmap bmp        = Tools.GenerateGenericKeyImage(out Graphics graphics);
            int    height     = bmp.Height;
            int    width      = bmp.Width;
            int    textHeight = bmp.Height - 36;


            Font         fontChannel     = new Font("Arial", 40, FontStyle.Bold);
            Font         fontViewers     = new Font("Verdana", 22, FontStyle.Bold);
            Font         fontIsStreaming = new Font("Webdings", 18, FontStyle.Regular);
            Font         fontViewerCount = new Font("Webdings", 24, FontStyle.Regular);
            GraphicsPath gpath           = new GraphicsPath();

            if (background != null)
            {
                // Draw background
                graphics.DrawImage(background, 0, 0, width, textHeight);
            }

            // Set Streamer Name
            gpath.AddString(keyInfo.KeyTitle,
                            fontChannel.FontFamily,
                            (int)FontStyle.Bold,
                            graphics.DpiY * fontChannel.SizeInPoints / width,
                            new Point(0, textHeight),
                            new StringFormat());
            graphics.DrawPath(Pens.Black, gpath);
            graphics.FillPath(Brushes.White, gpath);

            await Connection.SetImageAsync(bmp);

            fontChannel.Dispose();
            fontViewers.Dispose();
            fontIsStreaming.Dispose();
            fontViewerCount.Dispose();
            graphics.Dispose();
        }