473,809 Members | 2,780 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bitmap to Hexadecimal conversion

12 New Member
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 26351
macklin01
145 New Member
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 New Member
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
Pramod Kadur
12 New Member
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 New Member
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
Pramod Kadur
12 New Member
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 New Member
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
Pramod Kadur
12 New Member
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
SimonPlatten
6 New Member
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 New Member
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

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

Similar topics

10
22827
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 number and would like to convert it into float. Can anyone tell me how to do it? int main() { float theFloat;
5
7915
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 Damon
2
9758
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 can i do that in C#. also i want to convert a hexadecimal number (24 digits) into a binary number
2
4649
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 different. I'm used the following code to do the conversion. May any of you tell me what's happening? Thanks, Here are my code.... internal static Bitmap convertImage(string imageText)
8
18670
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 adv.
7
19240
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 00000000000000001111111111111111 11111111111111111111111111111111 00000000000000000000000000000000 11111111111111110000000000000000
6
14759
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++){ printf("%02x",bs); } }
6
16921
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
3199
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> using namespace std; void binary(int number) { int remainder; if(number <= 1)
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10387
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7662
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.