Solidworks/VB.NET SaveBMP()未一致保存位图

Solidworks/VB.NET SaveBMP()未一致保存位图,vb.net,bitmap,solidworks,Vb.net,Bitmap,Solidworks,我有一个VB.NET程序,可以在Solidworks中重新确定零件和部件的尺寸,然后使用SaveBMP()在面板中显示部件图形的图像。我的问题不是显示图像,而是每当用户在Solidworks图形中移动尺寸的位置时,位图的整个位置和大小都会改变,我需要进入代码中重新调整裁剪和大小值 将图形另存为位图图像: swModel.SaveBMP(BMPName, 1700, 1100) '17x11 aspect ratio 剪切我的图像以删除空白: Function CropDrawi

我有一个VB.NET程序,可以在Solidworks中重新确定零件和部件的尺寸,然后使用SaveBMP()在面板中显示部件图形的图像。我的问题不是显示图像,而是每当用户在Solidworks图形中移动尺寸的位置时,位图的整个位置和大小都会改变,我需要进入代码中重新调整裁剪和大小值

将图形另存为位图图像:

      swModel.SaveBMP(BMPName, 1700, 1100) '17x11 aspect ratio
剪切我的图像以删除空白:

  Function CropDrawing(ByVal OldImage As Image) As Image
    CropDrawing = Nothing
    Dim X As Integer = GetValue(frmImageScale.txtCropX.Text)
    Dim Y As Integer = GetValue(frmImageScale.txtCropY.Text)
    Dim Width As Integer = GetValue(GetValue(frmImageScale.txtCropW.Text))
    Dim Height As Integer = GetValue(frmImageScale.txtCropH.Text)
    Dim CropRect As New Rectangle(X, Y, Width, Height)
    Try
        Dim CropImage As Bitmap = New Bitmap(CropRect.Width, CropRect.Height)
        Using grp = Graphics.FromImage(CropImage)
            grp.DrawImage(OldImage, New Rectangle(0, 0, CropImage.Width, CropImage.Height), CropRect, GraphicsUnit.Pixel)
            OldImage.Dispose()
            'resave
            CropImage.Save(BMPName)
        End Using
        Return CropImage
    Catch ex As Exception
        'caught if width and height = 0
    End Try
End Function
调整图像大小以适应面板:

Public Function ResizeImage(ByVal OldImage As Image, ByVal TargetWidth As Integer, ByVal TargetHeight As Integer) As System.Drawing.Image
    Return New Bitmap(OldImage, TargetWidth, TargetHeight)
End Function
创建位图后,我裁剪图像,然后调整其大小以填充面板

任何关于为什么会发生这种情况的建议都将不胜感激