rookie_rockie

hi, i'm looking for a way to convert images into hexadecimal. can someone give me some url examples

thanks in advance




Re: Visual C# General converting images into hexadecimal

Peter Ritchie

By image, I assume you mean Bitmap.

There's a couple of ways this might be done. One is to loop through all the pixels in the bitmap (Bitmap.Width, Bitmap.Height, Bitmap.GetPixel) converting their value to hexadecimal with the call bitmap.GetPixel(x,y).ToArgb().ToString("X"). Alternatively you could use Bitmap.LockBits to get the scanline data and convert each of those into hexadecimal. See the documentation for BitmapData.Scan0 for an example of getting and processing scanline data.






Re: Visual C# General converting images into hexadecimal

IsshouFuuraibou

Another way, if you want to just convert the binary information, is to open the image in a BinaryReader and convert the bytes to Hexadecimal (strings). Maybe if you could tell us more about what you want to do, why, and what you have tried, we can help you better.





Re: Visual C# General converting images into hexadecimal

Peter Ritchie

IsshouFuuraibou wrote:
Another way, if you want to just convert the binary information, is to open the image in a BinaryReader and convert the bytes to Hexadecimal (strings). Maybe if you could tell us more about what you want to do, why, and what you have tried, we can help you better.
Using a BinaryReader with a Stream (either from file or by serializing an image) will include header information not relating the visual representation of the image. If a visual representation of the image in hex digits is required, that would likely skew the image.






Re: Visual C# General converting images into hexadecimal

Peter Ritchie

rookie_rockie, are you trying to UUEncode an image file or something similar to that




Re: Visual C# General converting images into hexadecimal

IsshouFuuraibou

True, but depending on what his goal is, maintaining the header information might be a wanted effect. It could be some restrictive transfer operation to perform, in which case maintaining the header for decoding the hex string back to an image is a wanted effect. However if they are wanting to pass the raw hex data of the image to something for processing, then the header information is an unwanted skew.

We really are going to need more information from rookie_rockie to explain more about what they are trying to do. Baring that, I'll recommend using Peter's method in general.





Re: Visual C# General converting images into hexadecimal

rookie_rockie

thanks for the reply.

may i know what is UUEncode

i have a smart device c# client(windows mobile 5.0) that would need to convert the image(bitmap) into hexadecimal before sending it to the server (through sockets, the server is a java, version 1.5, when the server receives the hexadecimal, it will match the hexadecimal values that it has received against a set of hexadecimal values in its database). everything is fine however i have no idea how to convert the image into hexadecimal before sending it .pls advise me