图片上通过gidp画文字上去,图片上添加文字
By
admin
at 2018-10-22 • 1人收藏 • 1229人看过
感谢 @undefined 分享
import inet.http; import gdip; import gdip.bitmap; import process; var baiduLogo = inet.http().get("https://www.baidu.com/img/bd_logo1.png"); var bmp = gdip.bitmap( baiduLogo ); var graphics = bmp.getGraphics(); //创建刷子 var brush = gdip.solidBrush(0xFFFF0000); //创建FontFamily var family = gdip.family("宋体"); //创建stringFormat var strformat = gdip.stringformat ( ); //设置样式 strformat.align = 0/*_GdipStringAlignmentNear*/; //创建Font var curFont = family.createFont( 15,2/*_GdipFontStyleItalic*/, 2/*_GdipUnitPixel*/) //设置文字抗据齿 graphics.smoothingMode = 4/*_GdipSmoothingModeAntiAlias*/ ; //消除走样,且边作平滑处理 graphics.textRenderingHint = 3/*_GdipTextRenderingHintAntiAliasGridFit*/; //设置文字区域 rclayout = gdip.RECTF(); rclayout.x = 15 rclayout.y = 15 rclayout.width = 500 //在这里指的是宽度 rclayout.height = 150 //在这里指的是高度 graphics.drawString( "Hellow world! 这是我们第一个GDI+文字~!!" , curFont , rclayout, strformat,brush); //删除所有GDI+对象 brush.delete() curFont.delete() strformat.delete(); family.delete(); bmp.save("\drawSring.bmp"); process.exploreSelect("\drawSring.bmp")
登录后方可回帖