Hexa class - format correct hexa string
readed 4732 timesThis class will help you to get correct hexa string to save in a file. eg, 10 in decimal is "A" in hexadecimal, but when creating an hexa string to save it in a file you need to give the byte like "0A".
Then you have word ( 2 bytes ) and DWord ( 4 bytes ). Lets say you want to save in hexa a width of your bitmap, saying 678. 678 in hexa is 2A6 and must be saved in a DWord ( 4 bytes ). The thing is that Words and DWords are read from right to left, but the bytes still from left to right. So you should have this to be correct: A6 02 00 00.
Anyway you don't need to know all of this. With the class to get your hexa string just do Hexa.DWord( "2A6" ) and you'll get the "A6020000" in result. Check the function in the class.
The getString will let you choose the length of the string, eg if you need to retreive the hexa for a pixel do like:
-
getString( _bmp.getPixel(0,0).toString( 16 ), 6 );






(No Ratings Yet)
