PDA

View Full Version : خطای A generic error occurred in GDI+



asn2010
دوشنبه 02 اسفند 1389, 19:35 عصر
سلام به دوستان :لبخندساده:
یک خطایی دارم که خیلی جالبه !!

کد زیر در یک برنامه کاملا درت کار می کند و در برنامه دیگه نه !! برنامه دیگه برنامه اصلیه متاسفانه :لبخند:


Public Function ResizeImage(ByVal imgToResize As Image, ByVal Width As Integer, ByVal Height As Integer) As Image
Dim sourceWidth As Integer = imgToResize.Width
Dim sourceHeight As Integer = imgToResize.Height
Dim nPercent As Single = 0
Dim nPercentW As Single = 0
Dim nPercentH As Single = 0
nPercentW = Width / sourceWidth
nPercentH = Height / sourceHeight
If nPercentH < nPercentW Then
nPercent = nPercentH
Else
nPercent = nPercentW
End If
Dim destWidth As Integer = CType((sourceWidth * nPercent), Integer)
Dim destHeight As Integer = CType((sourceHeight * nPercent), Integer)
Dim b As Bitmap = New Bitmap(destWidth, destHeight)
Dim g As Graphics = Graphics.FromImage(CType(b, Image))
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(imgToResize, 0, 0, destWidth, destHeight)
g.Dispose()
Return CType(b, Image)
End Function


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myBitmap As Bitmap = New Bitmap("C:\Inetpub\wwwroot\test\Gallery_Pictures\Images_Ga llery\Scan10016.JPG") ''''''''''
Dim myThumbnail As Image = ResizeImage(myBitmap, 120, 116)
myThumbnail.Save("c:\2.jpg")
End Sub

البته بگما سایت های زیرو بررسی کردم و هیچکدام مشکل منو حل نکرد اصلا کلا اونا تو اجرا مشکل دارن ولی مال من یه جا کار می کنه و جای دیگه نه دیگه دارم....:عصبانی++:

http://forum.p30world.com/showthread.php?t=384851
http://www.p2p.dotnetsource.com/Default.aspx?g=posts&t=8058
http://barnamenevis.org/showthread.php?202643-%D8%AE%D8%B7%D8%A7%DB%8C-A-generic-error-occurred-in-GDI-.

و چنتای دیگه...

فکر نمی کنم مشکل از کد باشه ا زچیه نمی دونم :گریه: