1

this is my code. Here i hv formed the byte array of img, i 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;
}
1
  • 3
    If you have an byte arrary why do you want to add some extra bytes to it?? and what error are you getting? Commented May 10, 2010 at 6:41

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.