本文介绍了如何解决这个在vd.net中的gdi +中发生的一般错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click

    Dim productId As Integer = 0
    Dim userId As Integer = 0
    userId = Convert.ToInt32(Session(Common.SESSION_USERID).ToString())

    Dim strImage1 As String = String.Empty
    Dim FileImage1 As String = String.Empty
    Dim strParth1 As String = String.Empty
    Dim strRemoveString1 As String = String.Empty
    If (flImage1.HasFile) Then
        Dim strPath As String = Server.MapPath("Common/ProductImages/")
        'Dim strPath As String = Server.MapPath("httpdocs/Common/ProductImages/")
        flImage1.SaveAs(strPath + flImage1.FileName)
        strParth1 = strPath + flImage1.FileName
        FileImage1 = flImage1.FileName
        strImage1 = "Common/ProductImages/" + flImage1.FileName

        Dim big As String = "~Big"
        Dim strm As Stream = flImage1.PostedFile.InputStream
        Dim targetFile = strParth1
        GenerateThumbnails(3.0, strm, targetFile, big)

    Else
       
    End If

    If Request.QueryString("Id") IsNot Nothing Then
        productId = InsertUpdateProduct(Convert.ToInt32(Request.QueryString("Id")), userId, txtName.Text, editorDesc.Content, txtPrice.Text, strImage1, txtShippingPrice.Text)
        If productId > 0 Then
            lblMsg.Text = "updated successfuly...."
            lblMsg.ForeColor = System.Drawing.Color.Green
        End If
    Else

        Dim strProductCount As Integer
        Dim strPlan As String = String.Empty

        strProductCount = Session(Common.SESSION_ProductCount)
        strPlan = Session(Common.SESSION_PlanTitle)

        If (Convert.ToInt32(strProductCount) < 30 And strPlan = "Gold Member") Then

            productId = InsertUpdateProduct(0, userId, txtName.Text, editorDesc.Content, txtPrice.Text, strImage1, strImage2, strImage3, txtShippingPrice.Text)
            If productId > 0 Then
                lblMsg.Text = "inserted successfuly...."
                lblMsg.ForeColor = System.Drawing.Color.Green
            End If
        Else
        End If

    End If

End Sub







Private Sub GenerateThumbnails(ByVal scaleFactor As Double, ByVal sourcePath As Stream, ByVal targetPath As String, ByVal name As String)
    Using image = System.Drawing.Image.FromStream(sourcePath)
        Dim newWidth = CInt(Math.Truncate(image.Width * scaleFactor))
        Dim newHeight = CInt(Math.Truncate(image.Height * scaleFactor))
        Dim thumbnailImg = New Bitmap(newWidth, newHeight)
        Dim thumbGraph = Graphics.FromImage(thumbnailImg)
        thumbGraph.CompositingQuality = CompositingQuality.HighQuality
        thumbGraph.SmoothingMode = SmoothingMode.HighQuality
        thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic
        Dim imageRectangle = New Rectangle(0, 0, newWidth, newHeight)
        thumbGraph.DrawImage(image, imageRectangle)

        Dim withoutExtension As String = targetPath
        Dim strImage As String = String.Empty
        Dim strArr() As String
        strArr = withoutExtension.Split(".")
        strImage = strArr(0)
        targetPath = strImage + ".jpg"

        Dim targetPath1 As String = targetPath.Replace(Path.GetFileNameWithoutExtension(targetPath), Path.GetFileNameWithoutExtension(targetPath) & name)

        thumbnailImg.Save(targetPath1, image.RawFormat)
        thumbnailImg.Dispose()
    End Using
End Sub











以上代码正常工作在本地或IIS但在服务器中此代码不起作用

这是gdi +

发生的一般错误请解决此问题....

紧急。






Above this code are properly working on local or IIS but in Server this code is not working
It's a generic error occurred in gdi+
Please resolve this problem....
It's urgent.

推荐答案


这篇关于如何解决这个在vd.net中的gdi +中发生的一般错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 02:28