Click here to Skip to main content
15,850,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi this is geetha,
i am trying to read the image into byte array and modifying this byte array. this i am able to do correctly. but when i try to redraw the image from this byte array it is giving an error.. my i know the problem... Here I am trying to add secrete information to the image and redraw the image with no much difference from the original.

memorystream ms=new memorystream(bt); // bt is the byte array hving
//modified image data like bt[0]=bt[0]+ 5;
picturebox2.image=image.fromstream(ms); // error: invalid argumen
Updated 12-May-10 20:46pm

This is the second time that you have asked, essentially, the same question.

Both times, members have suggested that the changes you are making to the byte array are corrupting it. I will make it three times.

I have some questions:

1. Are you able to 'redraw' the image correctly before you 'improve' it?
2. What you trying to do to the image with your modifications.

If the answer to 1. is no, then you have a corrupt image anyway. If yes, then that merely confirms that you are corrupting the image.

For 2. if you tell us what you are trying to do we may be able to suggest other ways to do it.

BTW: Looking at the line of code that you have commented out, you are aware that images have a header section which has to be correct for it to be recognised as an image. Guess where this header section lives! That's right, at the beginning of the data, exactly where bt[0] is messing about.
Share this answer
sursangeetha wrote:
//modified image data like bt[0]=bt[0]+ 5;

1. On what logic you are modifying the byte array?
2. Whats the reason behind modifying an image byte array. Is it of any use after it?

Btw: Looks like you are trying to add an integer to a certain byte array. They are not integers(=> not a base 10)! Probably leading to a corrupt array.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900