三度网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

文字文件转化为图片文件的简易办法

时间:2024/6/5作者:未知来源:三度网教程人气:


加一个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


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

关键词:  文字文件转化为图片文件的简易办法





Copyright © 2012-2018 三度网教程(http://www.3du8.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版