将流转换为数组时出现问题

时间:2012-06-20 07:08:18

标签: c#

for (myBitmap.col = 0; myBitmap.col < myBitmap.Height; myBitmap.col++)            
{
    for (myBitmap.row = 0; myBitmap.row < myBitmap.Height; myBitmap.row++)                
    {
        myBitmap.data[myBitmap.row * (int)myBitmap.ScanLineWidth + myBitmap.col + myBitmap.offset] += 5;
    }
}

MemoryStream ms = new MemoryStream(myBitmap.data);

pictureBox1.Image = Image.FromStream(ms);

//pictureBox1.Image = new Bitmap(returnimage);

MessageBox.Show("The image brightness conversion is successful");

我遇到将内存流对象转换为图片的问题。错误来自无效参数

1 个答案:

答案 0 :(得分:1)

在创建图像之前尝试重新设置流指针:

ms.Seek( 0, SeekOrigin.Begin );