1

仍然有调整我的图像大小的问题。

使用 c sharp.net 4.0 winforms 和 MS Visual Studio 2010。

这是我目前拥有的代码:

private void ShowArrow()
    {
        foreach (DataGridViewRow paretoRow in ParetoGrid.Rows)
        {
            if ((paretoRow.Cells["Pareto6"].Value != null) && (Convert.ToInt32(paretoRow.Cells["CurrentPareto"].Value) < (Convert.ToInt32(paretoRow.Cells["NewPareto"].Value))))
            {
                downArrow.Width = 2; 
                downArrow.Height = 2;
                paretoRow.Cells["p1"].Value = downArrow; 
            }
            else if ((paretoRow.Cells["Pareto6"].Value != null) && (Convert.ToInt32(paretoRow.Cells["CurrentPareto"].Value) > (Convert.ToInt32(paretoRow.Cells["NewPareto"].Value))))
            {
                //ParetoGrid.Rows[paretoRow.Index].DefaultCellStyle.BackColor = Color.LightGreen;
                paretoRow.Cells["p1"].Value = upArrow;
            }
        }
    }

但是当我尝试编辑图像大小时,它说图像是只读的?这是调整图像大小的好方法吗?或者,还有更好的方法?

非常感谢

4

2 回答 2

1

您可以检查图像对象的“只读”属性并继续操作。假设您的变量是 BitmapImage myImage。

bool isReadOnly = myImage.IsSealed;

还有另一种方法称为 SetValue。希望这可以帮助。

http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.aspx

于 2012-04-27T10:04:56.347 回答
0

如果你有一个 Image 对象,你可以试试这个:

http://msdn.microsoft.com/en-us/library/system.drawing.image.getthumbnailimage.aspx

实际上不是一个单一的解决方案,但它接近它。您可能希望事先生成调整大小的图像并稍后使用。

于 2012-04-27T10:07:30.477 回答