Foxtable(狐表)用户栏目专家坐堂 → [求助]递归函数返回不了正确的值?


  共有1863人关注过本帖平板打印复制链接

主题:[求助]递归函数返回不了正确的值?

帅哥哟,离线,有人找我吗?
黄训良
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1100 积分:8985 威望:0 精华:0 注册:2014/3/15 14:36:00
[求助]递归函数返回不了正确的值?  发帖心情 Post By:2017/5/15 13:48:00 [只看该作者]

递归函数如下:
Dim width As Integer = args(0)  '模板宽度
Dim height As Integer = args(1)    '模板高度
Dim ImagePath As String = args(2)   '图片文件
Dim iSource As Image = getimage(ImagePath)
Dim ob As Bitmap = new Bitmap(width , height )
Dim g As  Graphics  = Graphics.FromImage(ob)
g.Clear(Color.WhiteSmoke)
g.DrawImage(iSource, new Rectangle(0,0, width , height ), 0, 0, iSource.Width, iSource.Height, GraphicsUnit.Pixel)
Dim dFile As String  = "D:\test01.JPG"
ob.Save(dFile)
Application.DoEvents()

Dim Info As new FileInfo(dFile)
Dim len As Integer = info.Length
width = width - 100
height = height - 100

If len < 204800         '判断图片大小是否大于200KB
    Return True    '返回不了这个TRUE
Else
    Vars("RecursiveCount") += 1  '测试记录一下递归次数
    Functions.Execute("ImageCompress",width,height ,ImagePath)   '递归  
End If

iSource.Dispose()
ob.Dispose()
g.Dispose()

附上例子:
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目6.foxdb



 回到顶部