欢迎光临
我们一直在努力

文字文件转化为图片文件的简易方法-.NET教程,评论及其它

建站超值云服务器,限时71元/月

加一个picture控件 , 一个text控件, 一个按扭控件, 名字默认

先把你要加载的文字加到text控件之中,控件高度调整恰当使文字容纳并显示完全,并且把text控件和picture控件宽度大小调整一样!!!如果不一样,那么图象就有可能放大或缩小(如果不需要这样,你可以在下面的代码中自行修改)

如果想要其他花样 , 可以修改text控件的文字属性, 比如fontname等等

如果想要多花样,可以加入richtextbox控件(代码只要把text的改成richtextbox的即可),这样就可以显示rtf文件了.

加入以下代码到窗体:

private declare function releasedc lib "user32" (byval hwnd as long, byval hdc as long) as long

private declare function getdc lib "user32" (byval hwnd as long) as long

private declare function stretchblt lib "gdi32" (byval hdc as long, byval x as long, byval y as long, byval nwidth as long, byval nheight as long, byval hsrcdc as long, byval xsrc as long, byval ysrc as long, byval nsrcwidth as long, byval nsrcheight as long, byval dwrop as long) as long

private const srccopy = &hcc0020

private sub command1_click()

dim i as long

dim wtext as long

dim htext as long

dim w as long

dim h as long

dim hdctext as long

picture1.autoredraw = true

picture1.cls

wtext = text1.width

htext = text1.height

w = picture1.width

h = picture1.height

hdctext = getdc(text1.hwnd)

i = stretchblt(picture1.hdc, 0, 0, w, h, hdctext, 0, 0, wtext, htext, vbsrccopy)

picture1.refresh

savepicture picture1.image, "d:\1.bmp"

releasedc text1.hwnd,hdctext

end sub

这是简单的方法,当然更复杂的还有

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 文字文件转化为图片文件的简易方法-.NET教程,评论及其它
分享到: 更多 (0)

相关推荐

  • 暂无文章