image to byte array problems...

  • Thread starter Thread starter topdawg147
  • Start date Start date
T

topdawg147

I'm trying to convert an image to a byte array. However, when i do this
something is getting changed in the bytes (contents, length, etc). I
know because I'm also looking at the image bytes in a hex editor. I
want the image bytes in the program to match those that i'm looking at
in the hex editor. I'm not sure if it's an encoding thing or something
else.Here's the code I'm using:

Public Function ToArray(System.Drawing.Image img)

Dim ms As MemoryStream = New MemoryStream()
img.Save(ms, System.Drawing.Imaging.ImageFormat.Tiff);
Return ms.ToArray()

End Function

Also, I'd like to not have to specify the ImageFormat type.

Thanks,
todd
 
It has nothing to do with Sql specifically. For various job related
stuff, I need to inspect the actual bytes of the image. The image might
be coming from Sql, or a file, or a memory stream.

todd
 
yes if you look at that link i sent you it reads bytes out of sql. You can
do the same thing from a file or from memory stream does not matter
 
Yes, I know how to do that already. (See my first post...)

The problem is this: something is changing the bytes during the
conversion to the byte array. I want the byte array to match what i see
when opening the image in a hex editor.

t
 
Sorry about that... Ok so your trying to compare bytes of an image.
they should not be getting screwed up.. I guess i would be in same spot as
you..
Idea for you to try

Try making 2 picture boxs ... visibile hidden.
create the images in the picture boxes
then compare bit to bit.

I am sorry I can not answer if the bytes are being encoded. But they should
not be from what i understand about the stream process.

question:
If you display the image does it come out right?
 
Back
Top