开发者

error while converting the byte array to image ,after modifying the byte array and the byte array is taken from the image itself in c#

this is my code. Here i hv formed the byte array of img, i开发者_StackOverflow社区 am trying to add some vlue to this byte array say 10 and i'll take care that the value is not exceeding 255. later if i try to redraw the image via the following code i am getting error at this line... what can be the problem.. without modification if i try to draw the image it is coming but if i cahnge some value it is not drawing..

public Image btoi(byte[] bt)
{
    ms = new MemoryStream(bt, 0, bt.Length);
    img = Image.FromStream (ms, true); // error at this line
    ms.Close();

    return img;
}


The image data can be stored in various formats, including a header wich describes the image data. If you want to change the RGB value of the pixels you have to first make sure that the image format you are using are indeed storing data in RGB format and second only manipulate those parts of the memory block that contains the RGB values.

If you alter the entire memory block you will probably overwrite the values indicating image width and height as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜