Esempio n. 1
0
        public static bool DrawTextImage(
            ITextStrategy strategy,
            System.Drawing.Bitmap image,
            System.Drawing.Point offset,
            TextContext textContext,
            Matrix mat)
        {
            if (strategy == null || image == null || textContext == null)
            {
                return(false);
            }

            bool bRet = false;

            using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(image))
            {
                graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

                graphics.Transform = mat;

                bRet = strategy.DrawString(graphics,
                                           textContext.fontFamily,
                                           textContext.fontStyle,
                                           textContext.nfontSize,
                                           textContext.pszText,
                                           new System.Drawing.Point(textContext.ptDraw.X + offset.X, textContext.ptDraw.Y + offset.Y),
                                           textContext.strFormat);

                graphics.ResetTransform();
            }

            return(bRet);
        }
Esempio n. 2
0
        public static System.Drawing.Bitmap GenMask(
            ITextStrategy strategy,
            int width,
            int height,
            System.Drawing.Point offset,
            TextContext textContext,
            Matrix mat)
        {
            if (strategy == null || textContext == null)
            {
                return(null);
            }

            System.Drawing.Bitmap pBmp = new System.Drawing.Bitmap(width, height, PixelFormat.Format32bppArgb);

            using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(pBmp))
            {
                graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

                graphics.Transform = mat;

                strategy.DrawString(graphics,
                                    textContext.fontFamily,
                                    textContext.fontStyle,
                                    textContext.nfontSize,
                                    textContext.pszText,
                                    new System.Drawing.Point(textContext.ptDraw.X + offset.X, textContext.ptDraw.Y + offset.Y),
                                    textContext.strFormat);

                graphics.ResetTransform();
            }

            return(pBmp);
        }
Esempio n. 3
0
        /// <summary>
        /// Generate mask image of the text strategy.
        /// </summary>
        /// <param name="strategy">is text strategy</param>
        /// <param name="width">is the mask image width</param>
        /// <param name="height">is the mask image height</param>
        /// <param name="offset">offsets the text (typically used for shadows)</param>
        /// <param name="textContext">is text context</param>
        /// <returns>a valid mask image if successful</returns>
        public static System.Windows.Media.Imaging.WriteableBitmap GenMask(
            ITextStrategy strategy,
            int width,
            int height,
            System.Windows.Point offset,
            TextContext textContext)
        {
            if (strategy == null || textContext == null)
            {
                return(null);
            }

            RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);

            DrawingVisual drawingVisual = new DrawingVisual();

            DrawingContext drawingContext = drawingVisual.RenderOpen();

            strategy.DrawString(drawingContext,
                                textContext.fontFamily,
                                textContext.fontStyle,
                                textContext.fontWeight,
                                textContext.nfontSize,
                                textContext.pszText,
                                new System.Windows.Point(textContext.ptDraw.X + offset.X, textContext.ptDraw.Y + offset.Y),
                                textContext.ci);

            drawingContext.Close();

            bmp.Render(drawingVisual);

            return(new System.Windows.Media.Imaging.WriteableBitmap(bmp));
        }
Esempio n. 4
0
 public OutlineText(OutlineText rhs)
 {
     if (rhs.m_pTextStrategy != null) m_pTextStrategy = rhs.m_pTextStrategy.Clone(); else m_pTextStrategy = null;
     if (rhs.m_pShadowStrategy != null) m_pShadowStrategy = rhs.m_pShadowStrategy.Clone(); else m_pShadowStrategy = null;
     if (rhs.m_pFontBodyShadow != null) m_pFontBodyShadow = rhs.m_pFontBodyShadow.Clone(); else m_pFontBodyShadow = null;
     m_pBkgdBitmap = rhs.m_pBkgdBitmap;
     m_clrShadow = rhs.m_clrShadow;
     m_bEnableShadow = rhs.m_bEnableShadow;
     m_bDiffuseShadow = rhs.m_bDiffuseShadow;
     m_nShadowThickness = rhs.m_nShadowThickness;
     disposed = false;
 }
Esempio n. 5
0
 public OutlineText()
 {
     m_pTextStrategy = null;
     m_pShadowStrategy = null;
     m_pFontBodyShadow = null;
     m_pBkgdBitmap = null;
     m_clrShadow = System.Drawing.Color.FromArgb(0,0,0);
     m_bEnableShadow = false;
     m_bDiffuseShadow = false;
     m_nShadowThickness = 2;
     disposed = false;
 }
Esempio n. 6
0
        // Draw Faked Beveled effect
        public MainWindow()
        {
            InitializeComponent();

            WriteableBitmap canvas = TextDesignerWpf.CanvasHelper.GenImage((int)(image1.Width), (int)(image1.Height));

            // Text context to store string and font info to be sent as parameter to Canvas methods
            TextContext context = new TextContext();

            // Load a font from resource
            //===============================
            FontFamily fontFamily = new FontFamily(new Uri("pack://application:,,,/resources/"), "./#Segoe Print");

            context.fontFamily = fontFamily;
            context.fontStyle  = FontStyles.Normal;
            context.fontWeight = FontWeights.Regular;
            context.nfontSize  = 38;

            context.pszText = "Love Like Magic";
            context.ptDraw  = new Point(0, 0);

            // Draw the main outline
            //==========================================================
            ITextStrategy mainOutline = TextDesignerWpf.CanvasHelper.TextOutline(Color.FromRgb(235, 10, 230), Color.FromRgb(235, 10, 230), 4);

            TextDesignerWpf.CanvasHelper.DrawTextImage(mainOutline, ref canvas, new Point(4, 4), context);

            // Draw the small bright outline shifted (-2, -2)
            //==========================================================
            ITextStrategy mainBright = TextDesignerWpf.CanvasHelper.TextOutline(Color.FromRgb(252, 173, 250), Color.FromRgb(252, 173, 250), 2);

            TextDesignerWpf.CanvasHelper.DrawTextImage(mainBright, ref canvas, new Point(2, 2), context);

            // Draw the small dark outline shifted (+2, +2)
            //==========================================================
            ITextStrategy mainDark = TextDesignerWpf.CanvasHelper.TextOutline(Color.FromRgb(126, 5, 123), Color.FromRgb(126, 5, 123), 2);

            TextDesignerWpf.CanvasHelper.DrawTextImage(mainDark, ref canvas, new Point(6, 6), context);

            // Draw the smallest outline (color same as main outline)
            //==========================================================
            ITextStrategy mainInner = TextDesignerWpf.CanvasHelper.TextOutline(Color.FromRgb(235, 10, 230), Color.FromRgb(235, 10, 230), 2);

            TextDesignerWpf.CanvasHelper.DrawTextImage(mainInner, ref canvas, new Point(4, 4), context);

            // Finally blit the rendered canvas onto the window by assigning the canvas to the image control
            image1.Source = canvas;
        }
Esempio n. 7
0
        /// <summary>
        /// Draw outline on image
        /// </summary>
        /// <param name="strategy">is text strategy</param>
        /// <param name="image">is the image to be draw upon</param>
        /// <param name="offset">offsets the text (typically used for shadows)</param>
        /// <param name="textContext">is text context</param>
        /// <returns>true if successful</returns>
        public static bool DrawTextImage(
            ITextStrategy strategy,
            ref System.Windows.Media.Imaging.WriteableBitmap image,
            System.Windows.Point offset,
            TextContext textContext,
            System.Windows.Media.Matrix mat)
        {
            if (strategy == null || image == null || textContext == null)
            {
                return(false);
            }

            RenderTargetBitmap bmp = new RenderTargetBitmap((int)(image.Width), (int)(image.Height), 96, 96, PixelFormats.Pbgra32);

            DrawingVisual drawingVisual = new DrawingVisual();

            DrawingContext drawingContext = drawingVisual.RenderOpen();

            MatrixTransform mat_trans = new MatrixTransform();

            mat_trans.Matrix = mat;

            drawingContext.PushTransform(mat_trans);

            drawingContext.DrawImage(image, new Rect(0.0, 0.0, image.Width, image.Height));

            bool bRet = strategy.DrawString(drawingContext,
                                            textContext.fontFamily,
                                            textContext.fontStyle,
                                            textContext.fontWeight,
                                            textContext.nfontSize,
                                            textContext.pszText,
                                            new System.Windows.Point(textContext.ptDraw.X + offset.X, textContext.ptDraw.Y + offset.Y),
                                            textContext.ci);

            drawingContext.Pop();

            drawingContext.Close();

            bmp.Render(drawingVisual);

            image = new System.Windows.Media.Imaging.WriteableBitmap(bmp);

            return(bRet);
        }
        public static bool DrawTextImage(
            ITextStrategy strategy,
            CanvasRenderTarget image,
            Point offset,
            CanvasTextLayout text_layout)
        {
            if (strategy == null || image == null || text_layout == null)
            {
                return(false);
            }

            using (CanvasDrawingSession ds = image.CreateDrawingSession())
            {
                strategy.DrawString(ds, text_layout, (float)offset.X, (float)offset.Y);
            }

            return(true);
        }
        public async Task <Size> DrawOutlineTextWithLibrary(int dim, string font, string text, string saved_file)
        {
            Size         size   = new Size();
            CanvasDevice device = CanvasDevice.GetSharedDevice();

            using (CanvasRenderTarget offscreen = new CanvasRenderTarget(device, dim, dim, 96, Windows.Graphics.DirectX.DirectXPixelFormat.B8G8R8A8UIntNormalized,
                                                                         CanvasAlphaMode.Premultiplied))
            {
                using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
                {
                    ds.Clear(Colors.White);
                }
                Color text_color = Colors.White;

                CanvasSolidColorBrush brush  = new CanvasSolidColorBrush(device, text_color);
                CanvasTextFormat      format = new CanvasTextFormat();
                format.FontFamily = font;
                format.FontStyle  = Windows.UI.Text.FontStyle.Normal;
                format.FontSize   = 60;
                format.FontWeight = Windows.UI.Text.FontWeights.Bold;

                float            layoutWidth  = dim;
                float            layoutHeight = dim;
                CanvasTextLayout textLayout   = new CanvasTextLayout(device, text, format, layoutWidth, layoutHeight);

                ITextStrategy strat = CanvasHelper.TextOutline(Colors.Blue, Colors.Black, 10);
                CanvasHelper.DrawTextImage(strat, offscreen, new Point(10.0, 10.0), textLayout);

                Windows.Storage.StorageFolder storageFolder =
                    Windows.Storage.ApplicationData.Current.TemporaryFolder;
                string saved_file2 = "\\";
                saved_file2 += saved_file;
                await offscreen.SaveAsync(storageFolder.Path + saved_file2);

                imgOutlineText.Source = new BitmapImage(new Uri(storageFolder.Path + saved_file2));

                using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
                {
                    ds.Clear(Colors.White);
                }

                return(size);
            }
        }
Esempio n. 10
0
        public void DiffusedShadow(
            System.Drawing.Color color,
            int nThickness,
            System.Drawing.Point ptOffset)
        {
            DiffusedShadowStrategy pStrat = new DiffusedShadowStrategy();
            pStrat.Init(System.Drawing.Color.FromArgb(0,0,0,0),color,nThickness,true);

            m_clrShadow = color;

            DiffusedShadowStrategy pFontBodyShadow = new DiffusedShadowStrategy();
            pFontBodyShadow.Init(System.Drawing.Color.FromArgb(color.A, 255, 255), System.Drawing.Color.FromArgb(0, 0, 0, 0), 0, true);
            m_pFontBodyShadow = pFontBodyShadow;

            m_ptShadowOffset = ptOffset;
            m_pShadowStrategy = pStrat;
            m_bDiffuseShadow = true;
            m_bExtrudeShadow = false;
            m_nShadowThickness = nThickness;
        }
Esempio n. 11
0
        public static CanvasRenderTarget GenMask(
            ITextStrategy strategy,
            int width,
            int height,
            Point offset,
            CanvasTextLayout text_layout)
        {
            if (strategy == null || text_layout == null)
            {
                return(null);
            }

            CanvasRenderTarget offscreen = GenImage(width, height, Color.FromArgb(0, 0, 0, 0));

            using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
            {
                strategy.DrawString(ds, text_layout, (float)offset.X, (float)offset.Y);
            }

            return(offscreen);
        }
Esempio n. 12
0
        public void TextGlow(
            System.Drawing.Color clrText,
            System.Drawing.Color clrOutline,
            int nThickness)
        {
            TextGlowStrategy pStrat = new TextGlowStrategy();
            pStrat.Init(clrText,clrOutline,nThickness);

            m_pTextStrategy = pStrat;
        }
Esempio n. 13
0
        public void Shadow(
            System.Drawing.Color color,
            int nThickness,
            System.Drawing.Point ptOffset)
        {
            TextOutlineStrategy pStrat = new TextOutlineStrategy();
            pStrat.Init(System.Drawing.Color.FromArgb(0,0,0,0),color,nThickness);

            m_clrShadow = color;

            TextOutlineStrategy pFontBodyShadow = new TextOutlineStrategy();
            pFontBodyShadow.Init(System.Drawing.Color.FromArgb(255, 255, 255), System.Drawing.Color.FromArgb(0, 0, 0, 0), 0);
            m_pFontBodyShadow = pFontBodyShadow;

            m_ptShadowOffset = ptOffset;
            m_pShadowStrategy = pStrat;
            m_bDiffuseShadow = false;
        }
Esempio n. 14
0
        /// <summary>
        /// Draw outline on image
        /// </summary>
        /// <param name="strategy">is text strategy</param>
        /// <param name="image">is the image to be draw upon</param>
        /// <param name="offset">offsets the text (typically used for shadows)</param>
        /// <param name="textContext">is text context</param>
        /// <returns>true if successful</returns>
        public static bool DrawTextImage(
            ITextStrategy strategy,
            ref System.Windows.Media.Imaging.WriteableBitmap image,
            System.Windows.Point offset,
            TextContext textContext,
            System.Windows.Media.Matrix mat)
        {
            if (strategy == null || image == null || textContext == null)
                return false;

            RenderTargetBitmap bmp = new RenderTargetBitmap((int)(image.Width), (int)(image.Height), 96, 96, PixelFormats.Pbgra32);

            DrawingVisual drawingVisual = new DrawingVisual();

            DrawingContext drawingContext = drawingVisual.RenderOpen();

            MatrixTransform mat_trans = new MatrixTransform();
            mat_trans.Matrix = mat;

            drawingContext.PushTransform(mat_trans);

            drawingContext.DrawImage(image, new Rect(0.0, 0.0, image.Width, image.Height));

            bool bRet = strategy.DrawString(drawingContext,
                textContext.fontFamily,
                textContext.fontStyle,
                textContext.fontWeight,
                textContext.nfontSize,
                textContext.pszText,
                new System.Windows.Point(textContext.ptDraw.X + offset.X, textContext.ptDraw.Y + offset.Y),
                textContext.ci);

            drawingContext.Pop();

            drawingContext.Close();

            bmp.Render(drawingVisual);

            image = new System.Windows.Media.Imaging.WriteableBitmap(bmp);

            return bRet;
        }
Esempio n. 15
0
        /// <summary>
        /// Generate mask image of the text strategy.
        /// </summary>
        /// <param name="strategy">is text strategy</param>
        /// <param name="width">is the mask image width</param>
        /// <param name="height">is the mask image height</param>
        /// <param name="offset">offsets the text (typically used for shadows)</param>
        /// <param name="textContext">is text context</param>
        /// <returns>a valid mask image if successful</returns>
        public static System.Windows.Media.Imaging.WriteableBitmap GenMask(
            ITextStrategy strategy,
            int width,
            int height,
            System.Windows.Point offset,
            TextContext textContext,
            System.Windows.Media.Matrix mat)
        {
            if (strategy == null || textContext == null)
                return null;

            RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);

            DrawingVisual drawingVisual = new DrawingVisual();

            DrawingContext drawingContext = drawingVisual.RenderOpen();

            MatrixTransform mat_trans = new MatrixTransform();
            mat_trans.Matrix = mat;

            drawingContext.PushTransform(mat_trans);

            strategy.DrawString(drawingContext,
                textContext.fontFamily,
                textContext.fontStyle,
                textContext.fontWeight,
                textContext.nfontSize,
                textContext.pszText,
                new System.Windows.Point(textContext.ptDraw.X + offset.X, textContext.ptDraw.Y + offset.Y),
                textContext.ci);

            drawingContext.Pop();

            drawingContext.Close();

            bmp.Render(drawingVisual);

            return new System.Windows.Media.Imaging.WriteableBitmap(bmp);
        }
Esempio n. 16
0
        public void TextGradOutline(
            System.Drawing.Color clrText,
            System.Drawing.Color clrOutline1,
            System.Drawing.Color clrOutline2,
            int nThickness)
        {
            TextGradOutlineStrategy pStrat = new TextGradOutlineStrategy();
            pStrat.Init(clrText, clrOutline1, clrOutline2, nThickness);

            m_pTextStrategy = pStrat;
        }
Esempio n. 17
0
        // Create rainbow Text Effect in Aquarion EVOL anime
        public MainWindow()
        {
            InitializeComponent();

            // Create the outline strategy which is used later on for measuring
            // the size of text in order to generate a correct sized gradient image
            var strategyOutline2 = TextDesignerWpf.Canvas.TextOutline(MaskColor.Blue, MaskColor.Blue, 6);

            WriteableBitmap canvas = TextDesignerWpf.Canvas.GenImage((int)(image1.Width), (int)(image1.Height));

            // Text context to store string and font info to be sent as parameter to Canvas methods
            TextContext context = new TextContext();

            // Load a font from its resource,
            // instead of from system font collection
            //=============================================================
            FontFamily fontFamily = new FontFamily(new Uri("pack://application:,,,/resources/"), "./#Ruzicka Freehand LT Std");

            context.fontFamily = fontFamily;
            context.fontStyle  = FontStyles.Normal;
            context.fontWeight = FontWeights.Regular;
            context.nfontSize  = 46;

            context.pszText = "I cross over the deep blue void";
            context.ptDraw  = new Point(0, 0);

            // Generate the mask image for measuring the size of the text image required
            //============================================================================
            WriteableBitmap maskOutline2 = TextDesignerWpf.Canvas.GenMask(strategyOutline2, (int)(image1.Width), (int)(image1.Height), new Point(0, 0), context);

            uint top    = 0;
            uint bottom = 0;
            uint left   = 0;
            uint right  = 0;

            TextDesignerWpf.Canvas.MeasureMaskLength(maskOutline2, MaskColor.Blue, ref top, ref left, ref bottom, ref right);
            bottom += 2;
            right  += 2;

            // Generate the gradient image
            //=============================
            WriteableBitmap bmpGrad = new WriteableBitmap((int)(right - left), (int)(bottom - top), 96.0, 96.0, PixelFormats.Pbgra32, null);
            List <Color>    list    = new List <Color>();

            list.Add(Color.FromRgb(255, 0, 0));
            list.Add(Color.FromRgb(0, 0, 255));
            list.Add(Color.FromRgb(0, 255, 0));
            DrawGradient.Draw(ref bmpGrad, list, true);

            // Because Canvas::ApplyImageToMask requires the all images to have equal dimension,
            // we need to blit our new gradient image onto a larger image to be same size as canvas image
            //==============================================================================================
            WriteableBitmap bmpGrad2 = new WriteableBitmap((int)(image1.Width), (int)(image1.Height), 96.0, 96.0, PixelFormats.Pbgra32, null);

            byte[] pixels = new byte[bmpGrad.PixelHeight * bmpGrad.PixelWidth * bmpGrad.Format.BitsPerPixel / 8];
            bmpGrad.CopyPixels(pixels, bmpGrad.BackBufferStride, 0);
            bmpGrad2.WritePixels(new Int32Rect((int)left, (int)top, (int)(right - left), (int)(bottom - top)), pixels, bmpGrad.BackBufferStride, 0);

            // Apply the rainbow text against the blue mask onto the canvas
            TextDesignerWpf.Canvas.ApplyImageToMask(bmpGrad2, maskOutline2, canvas, MaskColor.Blue, false);

            // Draw the (white body and black outline) text onto the canvas
            //==============================================================
            ITextStrategy strategyOutline1 = TextDesignerWpf.Canvas.TextOutline(Color.FromRgb(255, 255, 255), Color.FromRgb(0, 0, 0), 1);

            TextDesignerWpf.Canvas.DrawTextImage(strategyOutline1, ref canvas, new Point(0, 0), context);

            // Finally blit the rendered image onto the window by assigning canvas to the image control
            image1.Source = canvas;
        }
Esempio n. 18
0
        public void TextNoOutline(System.Drawing.Brush brushText)
        {
            TextNoOutlineStrategy pStrat = new TextNoOutlineStrategy();
            pStrat.Init(brushText);

            m_pTextStrategy = pStrat;
        }
Esempio n. 19
0
        public void TextNoOutline(System.Drawing.Color clrText)
        {
            TextNoOutlineStrategy pStrat = new TextNoOutlineStrategy();
            pStrat.Init(clrText);

            m_pTextStrategy = pStrat;
        }
Esempio n. 20
0
        public void TextOnlyOutline(
            System.Drawing.Color clrOutline,
            int nThickness,
            bool bRoundedEdge)
        {
            TextOnlyOutlineStrategy pStrat = new TextOnlyOutlineStrategy();
            pStrat.Init(clrOutline, nThickness, bRoundedEdge);

            m_pTextStrategy = pStrat;
        }
Esempio n. 21
0
        // Draw Faked Beveled effect
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode     = SmoothingMode.AntiAlias;
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

            Bitmap canvas = Canvas.GenImage(ClientSize.Width, ClientSize.Height);

            // Text context to store string and font info to be sent as parameter to Canvas methods
            TextContext context = new TextContext();

            // Load a font from its file into private collection,
            // instead of from system font collection
            //=============================================================
            PrivateFontCollection fontcollection = new PrivateFontCollection();

            string szFontFile = "..\\..\\..\\CommonFonts\\Segoe Print.TTF";

            fontcollection.AddFontFile(szFontFile);
            if (fontcollection.Families.Count() > 0)
            {
                context.fontFamily = fontcollection.Families[0];
            }

            context.fontStyle = FontStyle.Regular;
            context.nfontSize = 38;

            context.pszText = "Love Like Magic";
            context.ptDraw  = new Point(0, 0);

            // Draw the main outline
            //==========================================================
            ITextStrategy mainOutline = Canvas.TextOutline(Color.FromArgb(235, 10, 230), Color.FromArgb(235, 10, 230), 4);

            Canvas.DrawTextImage(mainOutline, canvas, new Point(4, 4), context);

            // Draw the small bright outline shifted (-2, -2)
            //==========================================================
            ITextStrategy mainBright = Canvas.TextOutline(Color.FromArgb(252, 173, 250), Color.FromArgb(252, 173, 250), 2);

            Canvas.DrawTextImage(mainBright, canvas, new Point(2, 2), context);

            // Draw the small dark outline shifted (+2, +2)
            //==========================================================
            ITextStrategy mainDark = Canvas.TextOutline(Color.FromArgb(126, 5, 123), Color.FromArgb(126, 5, 123), 2);

            Canvas.DrawTextImage(mainDark, canvas, new Point(6, 6), context);

            // Draw the smallest outline (color same as main outline)
            //==========================================================
            ITextStrategy mainInner = Canvas.TextOutline(Color.FromArgb(235, 10, 230), Color.FromArgb(235, 10, 230), 2);

            Canvas.DrawTextImage(mainInner, canvas, new Point(4, 4), context);

            // Finally blit the rendered canvas onto the window
            e.Graphics.DrawImage(canvas, 0, 0, ClientSize.Width, ClientSize.Height);

            // Release all the resources
            //============================
            canvas.Dispose();

            mainOutline.Dispose();
            mainBright.Dispose();
            mainDark.Dispose();
            mainInner.Dispose();
        }
Esempio n. 22
0
        public void TextDblOutline(
            System.Drawing.Brush brushText,
            System.Drawing.Color clrOutline1,
            System.Drawing.Color clrOutline2,
            int nThickness1,
            int nThickness2)
        {
            TextDblOutlineStrategy pStrat = new TextDblOutlineStrategy();
            pStrat.Init(brushText, clrOutline1, clrOutline2, nThickness1, nThickness2);

            m_pTextStrategy = pStrat;
        }
Esempio n. 23
0
        public void TextOutline(
            System.Drawing.Brush brushText,
            System.Drawing.Color clrOutline,
            int nThickness)
        {
            TextOutlineStrategy pStrat = new TextOutlineStrategy();
            pStrat.Init(brushText, clrOutline, nThickness);

            m_pTextStrategy = pStrat;
        }
Esempio n. 24
0
        public static bool DrawTextImage(
            ITextStrategy strategy,
            System.Drawing.Bitmap image,
            System.Drawing.Point offset,
            TextContext textContext,
            Matrix mat)
        {
            if (strategy == null || image == null || textContext == null)
                return false;

            bool bRet = false;
            using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(image))
            {
                graphics.SmoothingMode = SmoothingMode.AntiAlias;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

                graphics.Transform = mat;

                bRet = strategy.DrawString(graphics,
                    textContext.fontFamily,
                    textContext.fontStyle,
                    textContext.nfontSize,
                    textContext.pszText,
                    new System.Drawing.Point(textContext.ptDraw.X + offset.X, textContext.ptDraw.Y + offset.Y),
                    textContext.strFormat);

                graphics.ResetTransform();
            }

            return bRet;
        }
Esempio n. 25
0
 public void SetNullTextEffect()
 {
     m_pTextStrategy = null;
 }
Esempio n. 26
0
 public void SetNullShadow()
 {
     m_pFontBodyShadow = null;
     m_pShadowStrategy = null;
 }
Esempio n. 27
0
        public static System.Drawing.Bitmap GenMask(
            ITextStrategy strategy,
            int width,
            int height,
            System.Drawing.Point offset,
            TextContext textContext,
            Matrix mat)
        {
            if (strategy == null || textContext == null)
                return null;

            System.Drawing.Bitmap pBmp = new System.Drawing.Bitmap(width, height, PixelFormat.Format32bppArgb);

            using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(pBmp))
            {
                graphics.SmoothingMode = SmoothingMode.AntiAlias;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

                graphics.Transform = mat;

                strategy.DrawString(graphics,
                    textContext.fontFamily,
                    textContext.fontStyle,
                    textContext.nfontSize,
                    textContext.pszText,
                    new System.Drawing.Point(textContext.ptDraw.X + offset.X, textContext.ptDraw.Y + offset.Y),
                    textContext.strFormat);

                graphics.ResetTransform();
            }

            return pBmp;
        }
Esempio n. 28
0
        public void TextDblGlow(
            System.Drawing.Color clrText,
            System.Drawing.Color clrOutline1,
            System.Drawing.Color clrOutline2,
            int nThickness1,
            int nThickness2)
        {
            TextDblGlowStrategy pStrat = new TextDblGlowStrategy();
            pStrat.Init(clrText, clrOutline1, clrOutline2, nThickness1, nThickness2);

            m_pTextStrategy = pStrat;
        }