我的代码在Windows XP上不起作用 [英] My code doesn't work on Windows XP

查看:73
本文介绍了我的代码在Windows XP上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我遇到了一个非常奇怪的问题,我的部分代码在Windows 7和Windows Vista上运行良好,但是在Windows XP上,出现了参数无效"异常.引发异常的函数是这样的:

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:

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



有谁知道这到底是怎么回事?我在两台Windows XP PC上测试了我的程序(它是32位可执行文件),并且两者都存在相同的问题.两台XP机器均具有最新的.NET Framework.
预先谢谢您.



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.

推荐答案

您正在将Bitmap对象而不是Image对象传递给g.DrawImage.它们是不同的.

试试这个:

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

Try this:

g.DrawImage(CType(bmpSource, Image), 0, 0, rect, GraphicsUnit.Pixel)


这篇关于我的代码在Windows XP上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆