Foxtable(狐表)用户栏目专家坐堂 → 压缩时自动关闭app


  共有2487人关注过本帖树形打印复制链接

主题:压缩时自动关闭app

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


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
压缩时自动关闭app  发帖心情 Post By:2018/9/17 21:28:00 [只看该作者]

Else
    For Each key As String In e.PostValues.Keys
        If key.Contains("imgs_") Then
            Dim bs As Byte() = Convert.FromBase64String(e.PostValues(key).split(",")(1))
            Dim stream As System.IO.Stream = New System.IO.MemoryStream(bs)
            Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(stream)
            bmp.Save("c:\web\xp\" & e.Cookies("username") & ".jpg", ImageFormat.Jpeg)
            Dim slt As String ="c:\web\xp\" & e.Cookies("username") & ".jpg"
            Dim img1 As image = getImage(slt)
            Dim bmp1 As bitmap
            If img1.width > 800 Then
                If 800 * (img1.height / img1.width) > 600 Then
                    bmp1 = new bitmap(img1, 800*(600/(800*(img1.height/img1.width))), 600)
                Else
                    bmp1 = new bitmap(img1, 600, 600 * (img1.height / img1.width))
                End If
            End If
            bmp1.save(slt, ImageFormat.Jpeg)
            bmp1.Dispose
        End If
    Next
    With wb.AddMsgPage("","msgpage","上传成功", "") '生成成功提示页
        Dim bt1=.AddButton("btn1","确定","xpcj.htm")
        bt1.kind=1
        bt1.Attribute = "style='border:1px solid black;border-radius:20px;padding:0px;width:50%'"
        
    End With
End If
wb.AppendHTML("<script type='text/javascript' src='/" & path & "/js/common.js'></script>", True)
wb.AppendHTML("<script type='text/javascript' src='/" & path & "/js/camera.js'></script>")


e.WriteString(wb.Build)

当照的相或选择的原图比较大(如几M),上传时有点慢,测试过很容易卡死,自动关闭了,上面上传代码如何提高效率,成其连续测试两张就更容易,是不是所谓内存溢出,当原图小时没问题,这该怎么办,?

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106168 积分:539957 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/9/17 22:14:00 [只看该作者]

后台保存图片改为异步模式:http://www.foxtable.com/mobilehelp/scr/3268.htm

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2018/9/17 22:46:00 [只看该作者]

Dim e As RequestEventArgs = args(0)
Dim path As String = "foxtableAppTest"
Dim wb As New weui
wb.InsertHTML("<!DOCTYPE html>")
wb.InsertHTML("<html>")
wb.InsertHTML("<head>")
wb.InsertHTML("<meta charset='utf-8'>")
wb.InsertHTML("<meta name='viewport' c />")
wb.InsertHTML("<title></title>")
wb.InsertHTML("<script src='../mui/js/mui.js'></script>")
wb.InsertHTML("<script src='../mui/js/xc.js'></script>")
wb.InsertHTML("<link href='../mui/css/mui.css' rel='stylesheet'/>")
wb.InsertHTML("<script Type='text/javascript' charset='utf-8'>mui.init();</script>")
wb.InsertHTML("</head>")
wb.InsertHTML("<body>")
wb.InsertHTML("<header class='mui-bar mui-bar-nav mui-bar-nav-bg'>")
wb.InsertHTML("<a  id='icon-menu' class='mui-action-back mui-icon mui-icon-left-nav mui-pull-left'></a>")
'wb.InsertHTML ("<a class='mui-action-back mui-icon mui-icon-home mui-pull-right mui-a-color'></a>")
wb.InsertHTML("<h1 class='mui-title'>我的照片</h1>")
wb.InsertHTML("</header>")
wb.InsertHTML("<div class='mui-content'>")
wb.InsertHTML("<br>")
wb.InsertHTML("<br>")

wb.AddForm("","form1","xpcj.htm")
If e.PostValues.Count = 0 Then
    wb.InsertHTML("form1","<div style='height: 150px;'><span style='position:absolute;margin-top:60px;margin-left:20px;'>我的照片:</span><img alt='你还没有照片' src='./xp/" & e.Cookies("username") & ".jpg' style='height: 150px;width:120px;margin-left:120px;max-height:100%'></div><br>")
    If ReadSex(e.Cookies("username"))= "女"
        wb.InsertHTML("form1","<div style='height: 170px'><span style='position:absolute;margin-top:70px;margin-left:20px;'>样板照片:</span><div id='imgs'><img src='./xp/yb.jpg' style='height:150px;width:120px;margin-top:20px;margin-left:120px;max-height:100%;'></div></div><br/>")
    End If
    If ReadSex(e.Cookies("username"))= "男"
        wb.InsertHTML("form1","<div style='height:150px'><span style='position:absolute;margin-top:70px;margin-left:20px;'>样板照片:</span><div id='imgs' style='widht:120px;height:150px;'><img src='./xp/yb1.jpg' style='height:150px;width:120px;margin-left:120px;max-height:100%;'></div></div><br/>")
    End If
    With wb.AddPageFooter("form1","pf1","")
        With wb.AddButtonGroup("form1","btg1",False)
            Dim bt1= .Add("btn1", "拍照", "button")
            bt1.Attribute = "onclick=getImageByCamera('imgs') style='border:1px solid black;border-radius:40px;padding:0px;'"
            bt1.kind=1
            Dim bt2= .Add("btn2", "相册", "button")
            bt2.Attribute = "onclick=galleryImg('imgs') style='border:1px solid black;border-radius:40px;padding:0px;'"
            bt2.kind=1
            Dim bt3=.Add("btn3", "上传")
            bt3.kind=1
            bt3.attribute="style='border:1px solid black;border-radius:40px;padding:0px;'onclick=javascript:mui.toast('正在上传,请等待');"
        End With
    End With
Else
    For Each key As String In e.PostValues.Keys
        If key.Contains("imgs_") Then
            Dim bs As Byte() = Convert.FromBase64String(e.PostValues(key).split(",")(1))
            Dim stream As System.IO.Stream = New System.IO.MemoryStream(bs)
            Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap(stream)
           bmp.Save("c:\web\xp\" & e.Cookies("username") & ".jpg", ImageFormat.Jpeg)
            Dim slt As String ="c:\web\xp\" & e.Cookies("username") & ".jpg"
            Dim img1 As image = getImage(slt)
            Dim bmp1 As bitmap
            If img1.width > 400 Then
                If 400 * (img1.height / img1.width) > 300 Then
                    bmp1 = new bitmap(img1, 400*(300/(400*(img1.height/img1.width))), 300)
                Else
                    bmp1 = new bitmap(img1, 300, 300 * (img1.height / img1.width))
                End If
            End If
            bmp1.save(slt, ImageFormat.Jpeg)
         '  bmp1.Dispose

        End If
    Next
    With wb.AddMsgPage("","msgpage","上传成功", "") '生成成功提示页
        Dim bt1=.AddButton("btn1","确定","xpcj.htm")
        bt1.kind=1
        bt1.Attribute = "style='border:1px solid black;border-radius:20px;padding:0px;width:50%'"
    End With
End If
wb.AppendHTML("<script type='text/javascript' src='/" & path & "/js/common.js'></script>", True)
wb.AppendHTML("<script type='text/javascript' src='/" & path & "/js/camera.js'></script>")
e.WriteString(wb.Build)
e.Handled = True


  Case "xpcj.htm"
        e.AsyncExecute = True
        Functions.Execute("xpcj",e) '学生个人成绩
        Functions.AsyncExecute("xpcj", e)


老师,是这样吧?现在还是存在两个问题,
第一个是当上传大一点的图片在上传时还没提示上传成功就自动关闭,要重启才行。
第二个点顶部返回没问题,但点手机返回就自动关闭,但其他页面点顶部返回和手机返回都可以并不出现自动关闭的问题,是哪里有问题呢






 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106168 积分:539957 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/9/17 22:57:00 [只看该作者]

把保存图片的代码单独拿出来异步保存

至于app的问题我这边没有环境测试

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/9/18 9:34:00 [只看该作者]

具体做个例子发上来才能测试。类似人家的例子【002HBuilder实例二(拍照上传)】那样做

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2018/9/18 17:45:00 [只看该作者]

老师,请问4楼的:把保存图片的代码单独拿出来异步保存
是什么意思,不理解这个怎么做



 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/9/18 17:50:00 [只看该作者]

1、是上传慢还是显示慢?是上传前手机的问题,还是你上传后服务器端处理的问题?图片的大小是多少?是不是过大了?你没有压缩图片?

 

2、在你httprequest那里加入msgbox,看执行到哪里的时候出问题。看是传输的时候慢,还是传输完毕你保存的时候慢。


 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2018/9/18 17:58:00 [只看该作者]

老师,慢都好,传张照片大约10秒,关键是上传过程中,当原图几M时就要卡死退出app,一至在学习这个东西,终于左拼右凑可以了,但又出来了上传慢和卡死问题,请老师救我,代码在楼上

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/9/18 19:06:00 [只看该作者]

以下是引用刘林在2018/9/18 17:58:00的发言:
老师,慢都好,传张照片大约10秒,关键是上传过程中,当原图几M时就要卡死退出app,一至在学习这个东西,终于左拼右凑可以了,但又出来了上传慢和卡死问题,请老师救我,代码在楼上

 

1、测试论坛的 【002HBuilder实例二(拍照上传】是否有你说的问题?

 

2、请做一个类似【002HBuilder实例二(拍照上传】的例子才能测试。


 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1936 积分:14844 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2018/9/18 20:28:00 [只看该作者]

002HBuilder实例二(拍照上传)例子在论坛里没找到

 回到顶部
总数 18 1 2 下一页