示例#1
0
        private void Pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            try
            {
                e.Graphics.DrawImage(c_ImgGen.createPng(fs, fs.Limages, new object[] { fs.getDrawnPoints(), null }), new Point(100, 10));
                c_returnGraphicSettings cg = new c_returnGraphicSettings();

                e.Graphics.SmoothingMode     = cg.getSM();
                e.Graphics.InterpolationMode = cg.getIM();
                e.Graphics.PixelOffsetMode   = cg.getPOM();
                pd_PrintDialog.Document      = pd;
            }
            catch
            {
            }
        }
示例#2
0
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            try
            {
                e.Graphics.DrawImage(c_ImgGen.createPng(f_EditorScreen, f_EditorScreen.Limages, new object[] { f_EditorScreen.getDrawnPoints(), null }), new Point(10, 10));
                c_returnGraphicSettings cg = new c_returnGraphicSettings();

                e.Graphics.SmoothingMode     = cg.getSM();
                e.Graphics.InterpolationMode = cg.getIM();
                e.Graphics.PixelOffsetMode   = cg.getPOM();
                printPreviewDialog1.Document = printDocument1;
            }
            catch
            {
            }
        }
示例#3
0
        public void createScaledImage()
        {
            var cr = new c_returnGraphicSettings();

            if (getWidth() > 20 && getHeight() > 20)
            {
                scaledImage = new Bitmap(getWidth(), getHeight());
                using (Graphics g = Graphics.FromImage(scaledImage))
                {
                    g.InterpolationMode = cr.getIM();
                    g.PixelOffsetMode   = cr.getPOM();
                    g.SmoothingMode     = cr.getSM();

                    g.DrawImage(image, new Rectangle(new Point(0, 0), scaledImage.Size), new Rectangle(new Point(0, 0), image.Size), GraphicsUnit.Pixel);
                }
            }
        }
示例#4
0
        //DrawTBG => Draw with Transparent Background checkered pattern
        public static Bitmap createImage(System.Drawing.Rectangle rec, List <c_ImageHolder> cutouts, bool drawTBG)
        {
            int border = 0;

            if (Properties.Settings.Default.s_hasBorder)
            {
                border = Properties.Settings.Default.s_borderWidth;
            }

            Bitmap bm = null;

            try
            {
                bm = new Bitmap(rec.Width + (border * 2), rec.Height + (border * 2));

                using (Graphics g = Graphics.FromImage(bm))
                {
                    c_returnGraphicSettings cg = new c_returnGraphicSettings();

                    g.SmoothingMode     = cg.getSM();
                    g.InterpolationMode = cg.getIM();
                    g.PixelOffsetMode   = cg.getPOM();

                    //g.Clear(Color.Transparent);

                    if (Properties.Settings.Default.s_hasBgColor)
                    {
                        g.Clear(Properties.Settings.Default.s_bgColor);
                    }
                    else
                    {
                        g.Clear(Color.Transparent);
                    }

                    if (drawTBG)
                    {
                        int x = 0;
                        int y = 0;
                        while (y < bm.Height)
                        {
                            while (x < bm.Width)
                            {
                                g.DrawImageUnscaled(Properties.Resources.transparentBG, new Point(x, y));
                                x += Properties.Resources.transparentBG.Width;
                            }

                            y += Properties.Resources.transparentBG.Height;
                            x  = 0;
                        }
                    }

                    foreach (c_ImageHolder c in cutouts)
                    {
                        c_ImageHolder k = c;
                        g.DrawImage(k.Image, new System.Drawing.Rectangle(k.Left - rec.Left + border, k.Top - rec.Top + border, k.Width, k.Height), new System.Drawing.Rectangle(0, 0, k.Image.Width, k.Image.Height), GraphicsUnit.Pixel);
                    }

                    if (Properties.Settings.Default.s_hasBorder)
                    {
                        Brush b = new SolidBrush(Properties.Settings.Default.s_borderColor);

                        g.FillRectangle(b, new RectangleF(0, 0, bm.Width, border));
                        g.FillRectangle(b, new RectangleF(0, bm.Height - border, bm.Width, border));
                        g.FillRectangle(b, new RectangleF(0, 0, border, bm.Height));
                        g.FillRectangle(b, new RectangleF(bm.Width - border, 0, border, bm.Height));
                    }
                }
            }
            catch
            {
            }

            return(bm);
        }