|
查看: 1436|回复: 3
|
[vb6] 文字 —〉图案的问题
[复制链接]
|
|
|
我已经写好.txt 转换成jpeg和bmp file,
可是我要如何scan text 的 lenght 和 height来set picture box的大小,
以便不会有多余的白色空位在右边和下面,谢谢
我的概念是loop每一条 text line然后拿最长的line为lenght of picture box,
然后 scan 到 end of file 来得到 height,可是这两个part不懂怎么写
希望有人可以教我。。。 |
|
|
|
|
|
|
|
|
|
|
发表于 16-6-2010 02:32 PM
|
显示全部楼层
大概是这样吧:
width = 0;
height = 0;
whiile ( !feof(fhandle) ) {
line = fget( fhandle ); // 或者其他 read line 的 function
if( line > width )
width = line;
width++; // 每一行都加 height
} |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 16-6-2010 02:37 PM
|
显示全部楼层
大概是这样吧:
width = 0;
height = 0;
whiile ( !feof(fhandle) ) {
line = fget( fhandle ); // ...
flashang 发表于 16-6-2010 02:32 PM 
这个是C还是vb哦? |
|
|
|
|
|
|
|
|
|
|
发表于 24-6-2010 05:20 PM
|
显示全部楼层
本帖最后由 雪儿与小鱼儿 于 24-6-2010 05:23 PM 编辑
Dim FileNumber As Integer
Dim TempStr As String
Dim TCol As Long, TRow As Long
Dim TWidth As Long, THeight As Long
FileNumber = FreeFile
TCol = 1
'''open your file
Open App.Path & "\PictureText.txt" For Input As FileNumber
Do While Not EOF(FileNumber)
Line Input #FileNumber, TempStr
'''check if new line length bigger, assign the new length value to TCol
If Len(TempStr) > TCol Then
TCol = Len(TempStr)
End If
TRow = TRow + 1
Loop
Close #FileNumber
TWidth = TCol '''picture box width
THeight = TRow '''picture box height
 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|