我的代码在Windows XP上不起作用

编程入门 行业动态 更新时间:2024-10-23 13:27:10
本文介绍了我的代码在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上不起作用

本文发布于:2023-11-23 15:51:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622019.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上不   代码   Windows   XP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!