473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Bitmap to Hexadecimal conversion

Hello All,

I need to convert the bitmap image to hexadecimal, so is there any free tool for doing this conversion? Any other suggestion is always welcome.

Thank you in advance.

Regards,
Pramod
Dec 22 '06 #1
10 26251
macklin01
145 100+
Hello All,

I need to convert the bitmap image to hexadecimal, so is there any free tool for doing this conversion? Any other suggestion is always welcome.

Thank you in advance.

Regards,
Pramod
Do you mean to output the pixel values in hex?

You could use my EasyBMP C++ BMP library. It's free and open source. Here's how you would get at the individual pixel values:

Expand|Select|Wrap|Line Numbers
  1. #include "EasyBMP.h"
  2.  
  3. // ... 
  4.  
  5. BMP Image;
  6. Image.ReadFromFile( "SomePicture.bmp" );
  7.  
  8. for( int j=0 ; j < Image.TellHeight() ; j++ )
  9. {
  10.  for( int i=0; i < Image.TellWidth() ; i++ )
  11.  {
  12.   cout << "red: " << Image(i,j)->Red << "\t"
  13.        << "green: " << Image(i,j)->Green << "\t"
  14.        << "blue: " << Image(i,j)->Blue << endl;
  15.  }
  16. }
  17.  
The red, green, and blue values are of type ebmpBYTE, which are essentially unsigned chars ranging from 0 to 255. You'd be free to convert those to hex or whatever you like as you see fit. (And I'm sure you'd have people who are willing to help determine the conversion.) I suppose that the color (255,0,0) would appear as

0xff0000,

the color (16,32,254) would be

0x1020fe,

etc. Please let me know if this is the sort of thing you are trying to do. Thanks -- Paul
Dec 22 '06 #2
macklin01
145 100+
To come to think of it, this modification should do the trick:

Expand|Select|Wrap|Line Numbers
  1. cout << "pixel (" << i << "," << j << "): " 
  2.      << hex << Image(i,j)->Red << 
  3.      << hex << Image(i,j)->Green << 
  4.      << hex << Image(i,j)->Blue << endl;
  5.  
Thanks -- Paul
Dec 22 '06 #3
Do you mean to output the pixel values in hex?

You could use my EasyBMP C++ BMP library. It's free and open source. Here's how you would get at the individual pixel values:

Expand|Select|Wrap|Line Numbers
  1. #include "EasyBMP.h"
  2.  
  3. // ... 
  4.  
  5. BMP Image;
  6. Image.ReadFromFile( "SomePicture.bmp" );
  7.  
  8. for( int j=0 ; j < Image.TellHeight() ; j++ )
  9. {
  10.  for( int i=0; i < Image.TellWidth() ; i++ )
  11.  {
  12.   cout << "red: " << Image(i,j)->Red << "\t"
  13.        << "green: " << Image(i,j)->Green << "\t"
  14.        << "blue: " << Image(i,j)->Blue << endl;
  15.  }
  16. }
  17.  
The red, green, and blue values are of type ebmpBYTE, which are essentially unsigned chars ranging from 0 to 255. You'd be free to convert those to hex or whatever you like as you see fit. (And I'm sure you'd have people who are willing to help determine the conversion.) I suppose that the color (255,0,0) would appear as

0xff0000,

the color (16,32,254) would be

0x1020fe,

etc. Please let me know if this is the sort of thing you are trying to do. Thanks -- Paul

Hello Paul,

Thankyou for the feedback.

Actually i was looking for conversion from a bitmap image to its equivalent hexadecimal numbers.
Eg: like from image.bmp to its hexadecimal format

Thank you in advance.

Regards,
Pramod
Dec 26 '06 #4
macklin01
145 100+
Hello Paul,

Thankyou for the feedback.

Actually i was looking for conversion from a bitmap image to its equivalent hexadecimal numbers.
Eg: like from image.bmp to its hexadecimal format

Thank you in advance.

Regards,
Pramod
I'm afraid I don't understand. A bitmap image is in binary to begin with. hex is just a matter of how you view the data. -- Paul
Dec 26 '06 #5
I'm afraid I don't understand. A bitmap image is in binary to begin with. hex is just a matter of how you view the data. -- Paul
Hello,

Actually i have got an bitmap image and i need to convert this into a icon for me to use it in my application. On edit on this icon as text format i will obtain it in hexa decimal format.

So either i need to convert this bitmap to icon or to its hexadecimal equivalent. Its better for me to have it in hex format as i need to copy this on to the existing icon.

Rgds,
Pramod
Dec 26 '06 #6
macklin01
145 100+
Hello,

Actually i have got an bitmap image and i need to convert this into a icon for me to use it in my application. On edit on this icon as text format i will obtain it in hexa decimal format.

So either i need to convert this bitmap to icon or to its hexadecimal equivalent. Its better for me to have it in hex format as i need to copy this on to the existing icon.

Rgds,
Pramod
What are the dimensions of the image? Also, do you need it in reduced color? (4 or 8 bits per pixel) Lastly, do you need only the image pixels, or the entire .ico data structure? I'm just trying to understand what it is you actually need.

Thanks -- Paul
Dec 26 '06 #7
What are the dimensions of the image? Also, do you need it in reduced color? (4 or 8 bits per pixel) Lastly, do you need only the image pixels, or the entire .ico data structure? I'm just trying to understand what it is you actually need.

Thanks -- Paul

Hello,

I have a bitmap image (width=154 and height=124), units=pixel and this one i need to convert into an icon so i can use it in resource workshop. After conversion, the icon should be in 32*32 size, 16 colors and in hexa decimal format like
'00 00 01 00 01 00 20 20 10 00 00 00 00 00 E8 02'
'00 00 16 00 00 00 28 00 00 00 20 00 00 00 40 00' etc

So if i copy this hexadecimal format in resource workshop, i should be able to reproduce the earlier same bitmap image but now as an icon.
Suggest me if i can do the same in any other way.

Hope i am clear here. Thank you in advance.

Rgds,
Pramod
Dec 27 '06 #8
If you want just the file as hex, its a simple process:

Open File
Do Until EOF
Read Section of File into buffer
For i=0 to length of buffer
Output byte[i] of buffer as hex
Next
Loop
Close File

If you actually want to translate the file into something meaningful then you will have to specify what file format the image is in. You cannot simply spit out RGB, all graphic file formats are very different, some use compression others do not.

If you want to convert the graphic to an icon, simply load the graphic, copy to the clipboard, then load you icon editor and paste image from the clipboard. Resize and save as ico file.
Dec 27 '06 #9
macklin01
145 100+
Note that the .ico file format is slightly different than the .bmp file format, so spitting it out in hex isn't enough.

Also, note that your image is not square, so resizing it to 32 x 32 will involve some distortion. -- Paul
Dec 27 '06 #10
good work
Oct 17 '10 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: pavithra.eswaran | last post by:
Hi, I would like to convert a single precision hexadecimal number to floating point. The following program seems to work fine.. But I do not want to use scanf. I already have a 32 bit hexadecimal...
5
by: Damon | last post by:
I'm getting '', hexadecimal value 0x02, is an invalid character when I'm deseralizing XML from a 3rd party XML gateway. How do I get rid of these hexadecimal values before I deserialize? Cheers...
2
by: akash deep batra | last post by:
hi i want to convert a 96 bit binary number into a hexadecimal number. e.g binary number= 001100010001010000100101011110111111010101110100010110000101011000101010000000000000000000000000 how...
2
by: iyuen | last post by:
I'm trying to convert byte array (valid bitmap format) into some bitmaps and back to byte array again. But when I inspect the content of the array before and after the conversion they are...
8
by: Vijay | last post by:
Hi , I am doing a small project in c. I have a Hexadecimal file and want to convert into ascii value. (i.e., Hexadecimal to Ascii conversion from a file). Could anyone help me? Thanks in...
7
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006...
6
by: Andrea | last post by:
Hi, suppose that I have a string that is an hexadecimal number, in order to print this string I have to do: void print_hex(unsigned char *bs, unsigned int n){ int i; for (i=0;i<n;i++){...
6
by: sweeet_addiction16 | last post by:
hello Im writin a code in c... can sum1 pls help me out in writing a c code to convert decimalnumber to hexadecimal number.The hexadecimal number generated has to be an unsigned long.
14
by: Ellipsis | last post by:
Ok so I am converting to hexadecimal from decimal and I can only cout the reverse order of the hexadecimal?! How could I reverse this so its the right order? Heres my code: #include <iostream>...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.