Click here to Skip to main content
15,905,875 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello guys, I have very strange problem, a portions of my code works excellent on Windows 7 and Windows Vista, but on Windows XP I got 'Parameter is not valid' exception. The function that throws the exception is this:

VB
Private Function CropPattern(ByVal intCrpX As Integer, ByVal intCrpY As Integer, ByVal intCrpW As Integer, ByVal intCrpH As Integer, _
                               ByVal bmpSource As Bitmap) As Bitmap
       Dim bmpCropBitmap1 As Bitmap
       Dim rect As Rectangle = New Rectangle(intCrpX, intCrpY, intCrpW, intCrpH)
       bmpCropBitmap1 = New Bitmap(intCrpW, intCrpH)
       Dim g As Graphics = Graphics.FromImage(bmpCropBitmap1)

       g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
       g.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
       g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
       g.DrawImage(bmpSource, 0, 0, rect, GraphicsUnit.Pixel)
       g.Dispose()
       Return bmpCropBitmap1
   End Function


Does anyone know what the hell is going on? I tested my program(which is 32 bit executable) on two windows xp PCs and there is the same problem on the both of them. Both XP machines have the latest .NET Framework .
Thank you in advance.
Posted
Comments
[no name] 28-Aug-11 7:48am    
What is the exact error message and in which line ?

1 solution

You're passing a Bitmap object to g.DrawImage instead of a Image object. They are different.

Try this:

VB
g.DrawImage(CType(bmpSource, Image), 0, 0, rect, GraphicsUnit.Pixel)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900