예제 #1
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;
 }
예제 #2
0
        private Bitmap TextOutline()
        {
            OutlineText outlineText = new OutlineText();
            outlineText.TextOutline(ColorTranslator.FromHtml(modelItem.FontColor), Color.FromArgb(template.OutlineColor1), template.OutlineThickness1);

            outlineText.EnableShadow(template.ShadowEnable);

            if (template.ShadowEnable)
                outlineText.Shadow(Color.FromArgb(template.ShadowColor), template.ShadowThickness, new Point(template.ShadowOffsetX, template.ShadowOffsetY));

            Graphics g = Graphics.FromImage(new Bitmap(1, 1));

            outlineText.MeasureString(g, fontFamily, FontStyle.Regular, modelItem.FontSize, modelItem.Text,
                new Point(0, 0), new StringFormat(), ref fStartX, ref fStartY, ref fDestWidth, ref fDestHeight);

            fDestHeight++;

            Bitmap image = new Bitmap((int)(fStartX + fDestWidth), (int)(fStartY + fDestHeight));

            // FromImage method creates a new Graphics from the specified Image.
            Graphics graphics = Graphics.FromImage(image);
            graphics.SmoothingMode = SmoothingMode.AntiAlias;
            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

            LinearGradientBrush gradientBrush = new LinearGradientBrush(new RectangleF(fStartX, fStartY, fDestWidth - (fStartX - 10), fDestHeight - (fStartY - 10)),
                   ColorTranslator.FromHtml(modelItem.FontColor), Color.FromArgb(template.TextColor2), LinearGradientMode.Vertical);

            if (template.TextGradientEnable)
                outlineText.TextOutline(gradientBrush, Color.FromArgb(template.OutlineColor1), template.OutlineThickness1);

            outlineText.DrawString(graphics, fontFamily, FontStyle.Regular, modelItem.FontSize, modelItem.Text, new Point(0, 0), new StringFormat());

            gradientBrush.Dispose();
            graphics.Dispose();
            g.Dispose();

            return image;
        }