请问如何在picture控件中载入一个文本文件,然后转化成图片输出?

leochou213 2008-03-31 10:30:06
RT,要用print在picture中载入txt文本后,转化成bmp格式保存,要怎么写?
我这样写的
Private Sub Form_Load()
Picture1.FontSize = 20
Picture1.BackColor = &H0&
Picture1.ForeColor = &HFF&
End Sub

Private Sub Command1_Click()
Picture1.CurrentX = 2000
Picture1.CurrentY = 1500
Picture1.Print "欢迎光临"
Picture1.AutoRedraw = True
SavePicture Picture1.Image, "e:\temp.bmp"
End Sub

不过好像有点问题,而且文本载入也没写进去.
高手们帮忙完善下吧!
...全文
71 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
cbm6666 2008-04-07
9F 不是说了吗? 90000的高度不够你可以试着加到最大, 加不了你就再加 Picture2 Picture3.....
回复
Sandrer 2008-03-31
先Picture1.AutoRedraw = True
再Picture1.Cls
最后Picture1.Print

试试看~你顺序搞错了而已~
回复
vansoft 2008-03-31
我有,代码太长.
回复
leochou213 2008-03-31
有个这样的问题,就是文本内的内容图片上显示不全,不知如何解决?
如下图
回复
cbm6666 2008-03-31
呵..漏了 close #1

Open "c:\test.txt" For Input As #1
While Not EOF(1)
Line Input #1, aa
Picture1.Print aa
Wend
close #1
SavePicture Picture1.Image, "c:\tt.bmp"
回复
cbm6666 2008-03-31
你在 SavePicture Picture1.Image, "c:\tt.bmp" 的上面加上下面代码
并在最上面的
Picture1.Move 0, 0, 12000, 9000
改为
Picture1.Move 0, 0, 12000, 90000



Open "c:\test.txt" For Input As #1
While Not EOF(1)
Line Input #1, aa
Picture1.Print aa
Wend
SavePicture Picture1.Image, "c:\tt.bmp"

你的图要多大就装多大(当然有一定的限制),大不了你再换另一个Picture2 Picture3
回复
cbm6666 2008-03-31
'添加 Picture1

Private Sub Form_Load()
Me.Width = 12000: Me.Height = 9000: Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
Picture1.Move 0, 0, 12000, 9000
Picture1.AutoRedraw = True
Picture1.FontName = "楷体_GB2312"
Picture1.FontSize = 24
aa = "欢迎光临 CSDN"
Picture1.CurrentX = (Me.Width - LenB(StrConv(aa, vbFromUnicode)) * 10 * Picture1.FontSize) \ 2
Picture1.CurrentY = 50
Picture1.Print aa
Picture1.FontSize = 16
Picture1.Print
Picture1.Print "RT,要用print在picture中载入txt文本后,转化成bmp格式保存,要怎么写?"
Picture1.Print "我这样写的"
Picture1.Print "Private Sub Form_Load()"
Picture1.Print " Picture1.FontSize = 20"
Picture1.Print " Picture1.BackColor = &H0&"
Picture1.Print " Picture1.ForeColor = &HFF&"
Picture1.Print "End Sub"
Picture1.Print "Private Sub Command1_Click()"
Picture1.Print " Picture1.CurrentX = 2000"
Picture1.Print " Picture1.CurrentY = 1500"
Picture1.Print " Picture1.Print "; 欢迎光临; ""
Picture1.Print " Picture1.AutoRedraw = True"
Picture1.Print " SavePicture Picture1.Image," & Chr(34) & "e:\temp.bmp" & Chr(34)
Picture1.Print "End Sub"
Picture1.Print "不过好像有点问题,而且文本载入也没写进去."
Picture1.Print "高手们帮忙完善下吧!"
Picture1.Print
Picture1.FontSize = 24
aa = "图片已保存在 C:\tt.bmp"
Picture1.CurrentX = (Me.Width - LenB(StrConv(aa, vbFromUnicode)) * 10 * Picture1.FontSize) \ 2
Picture1.Print aa
SavePicture Picture1.Image, "c:\tt.bmp"
End Sub

回复
leochou213 2008-03-31
但是这样不能显示完全吖,只能显示picture控件大小的那么一块...
回复
vbman2003 2008-03-31
dim s as string

open "e:\temp.txt" for binary as #1
s=space(lof(1))
get #1,,s
close

Picture1.AutoRedraw = True
Picture1.cls
Picture1.CurrentX = 2000
Picture1.CurrentY = 1500
Picture1.Print s
SavePicture Picture1.Image, "e:\temp.bmp"



回复
leochou213 2008-03-31
十分感谢,那如何把文本文档载入进去代替"欢迎光临"几个字呢?
回复
vbman2003 2008-03-31
试试看~你顺序搞错了而已~

Picture1.AutoRedraw = True
Picture1.CurrentX = 2000
Picture1.CurrentY = 1500
Picture1.Print "欢迎光临"
SavePicture Picture1.Image, "e:\temp.bmp"
回复
leochou213 2008-03-31
能写具体点么,帮帮忙,谢谢了.
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7489

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2008-03-31 10:30
社区公告
暂无公告