首页 新闻 赞助 找找看

微信回图片想把文字浮在图片上怎么做的?

0
悬赏园豆:10 [待解决问题]

微信回复图片想把文字浮在图片上怎么做的?还有文字和图片左右排列对齐怎么做?

snjsunyan的主页 snjsunyan | 初学一级 | 园豆:55
提问于:2013-01-16 14:54
< >
分享
所有回答(1)
0
// This is the CreateImage() function body.
private static Bitmap CreateImage( string sImageText ) { Bitmap bmpImage = new Bitmap( 1, 1 );

    int iWidth = 0;
    int iHeight = 0;

    // Create the Font object for the image text drawing.
    Font MyFont = new Font( "Verdana", 24, 
                       System.Drawing.FontStyle.Bold, 
                       System.Drawing.GraphicsUnit.Point );


    // Create a graphics object to measure the text's width and height.
    Graphics MyGraphics = Graphics.FromImage( bmpImage );

    // This is where the bitmap size is determined.
    iWidth = (int)MyGraphics.MeasureString( sImageText, MyFont ).Width;
    iHeight = (int)MyGraphics.MeasureString( sImageText, MyFont ).Height;

    // Create the bmpImage again with the correct size for the text and font.
    bmpImage = new Bitmap( bmpImage, new Size( iWidth, iHeight ) );

    // Add the colors to the new bitmap.
    MyGraphics = Graphics.FromImage( bmpImage );
    MyGraphics.Clear( Color.Navy );
    MyGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
    MyGraphics.DrawString( sImageText, MyFont, 
                        new SolidBrush( Color.Red ), 0, 0 );
    MyGraphics.Flush();

    return( bmpImage );
}

http://www.codeproject.com/Articles/6322/Another-Dynamic-ASP-NET-Text-Image

这个也是的:http://www.codeproject.com/Articles/2927/Creating-a-Watermarked-Photograph-with-GDI-for-NET

并且有源代码。

悟行 | 园豆:12559 (专家六级) | 2013-01-16 14:58
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册