Help required in converting a bit map to a Hex file.

Discussion in 'C' started by chandrasas, Oct 24, 2008.

  1. chandrasas

    chandrasas New Member

    Joined:
    Mar 13, 2008
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Hello,
    I am working in Embedded Systems. In my current project i am in requirement of converting a bit map into a Hex file. Can any one suggest me..the way to proceed.

    Thanks & Regards,
    Sekhar
     
  2. imported_xpi0t0s

    imported_xpi0t0s New Member

    Joined:
    Jul 18, 2008
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Is it a bitmap in the sense of a picture, or just a set of bits? i.e. do you need to decode the format and convert just some of the data?

    Converting binary to hex is really easy, four bits map directly onto each hex digit. 0000~1001 map to 0-9, and 1010~1111 map to A-F. So an 8-bit binary number 10100011 would just be A3 in hex (1010=A, 0033=3).

    Are you converting the bitmap to hex for uploading into an embedded system, or is it the embedded processor itself that will be doing the conversion? If the latter, what chip are you using?
     
  3. chandrasas

    chandrasas New Member

    Joined:
    Mar 13, 2008
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Hello,
    Thanks for responding.
    My intention is to convert a Bit Map Picture to a Hex file. In my current embedded project i am working on LCD Display module. There we are in need of converting a String(which will be written in Fast LCD) that will be converted to Hex file with the help of Visual basic. This is the current scenario. But my intention is to convert that Bit Map into Hex through C.

    Thanks & Regards,
    sekhar
     
  4. imported_xpi0t0s

    imported_xpi0t0s New Member

    Joined:
    Jul 18, 2008
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    So is your plan to display the image on the LCD?
    Which LCD are you using, out of interest?
    Obviously you'll need to get hold of the BMP file format; there's an article which seems to cover it at Wikipedia (BMP_file_format).
    How do you want the hex file to represent the bitmap? If, say, the bitmap contains the letter A, will the resulting hex file contain numbers like 0x18, 0x24, 0x42, 0x42, 0x7e, 0x42, 0x42, 0x00?
    Why do you want to do it in C rather than in VB?
     
  5. chandrasas

    chandrasas New Member

    Joined:
    Mar 13, 2008
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Hello,
    Thanks for your support.
    We are using the LCD pannel of 128x64. I require the format like suppose if we give a letter A.....then it generates the hex files like 0x24,0x16 etc.

    Thanxs,
    sekhar
     
  6. imported_xpi0t0s

    imported_xpi0t0s New Member

    Joined:
    Jul 18, 2008
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Which LCD panel, as in make, model, etc, if you were to order one, what would you ask the shop for? There are several manufacturers who eack make several models, so "the 128x64 panel" doesn't really answer the question.

    What format do you want? Do you mean a program? You're unlikely to get someone here to write the program for you, but we'll help where you're stuck. Did you have a look at the Wikipedia article?
     
  7. chandrasas

    chandrasas New Member

    Joined:
    Mar 13, 2008
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Hello,
    Thanks for your support.
    I am using the display P09703(Orit Display Corporation).
    I dont need a program which is written by some one. I need help in regarding the caluculations point of view. Suppose, in my present situation my BAS file (after genrating font for a required string through fast LCD) occupying 130 bytes. The VB file is converting each pixel of that particular format into hex file format.
    So, i need help in regarding the actual methodology and fundaa behind in caluculation.

    Thanks & Regards,
    Sekhar
     
  8. chandrasas

    chandrasas New Member

    Joined:
    Mar 13, 2008
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    0
    Hello,
    Thanks I got bit information from Wikipedia regarding BMP_FILE_Format. Thanks for the information.

    Regards,
    Sekhar
     
  9. imported_xpi0t0s

    imported_xpi0t0s New Member

    Joined:
    Jul 18, 2008
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    I couldn't find a reference guide for a P09703 display. The only result for this was from a site called "htd - tech . com" (DO NOT VISIT) which seemed to be flagged as a malware site.

    I'm still not clear on exactly what calculations you need doing. Could you give an example of what you want converted to what, explaining how the results are derived from the input? If it's as simple as converting 8-bit numbers to hexadecimal format, then you would consider the upper 4 bits then the lower 4 bits, then numbers from 0-9 would become '0'-'9', and numbers 10-15 would become 'A'-'F'. For example:
    Code:
    char tohex(int n)
    {
    	n&=15;
    	if (n>=0 && n<=9) return '0'+n;
    	if (n>=10 && n<=15) return 'A'+n-10;
    }
    
    void tohextest()
    {
    	int tab[]={27,45,103,255,1,0xa5,-1};
    	for (int i=0; tab[i]>=0; i++)
    	{
    		printf("0x%c%c, ",tohex(tab[i]>>4),tohex(tab[i]));
    	}
    }
    
    The output of the above is 0x1B, 0x2D, 0x67, 0xFF, 0x01, 0xA5. Is this anything like what you're after?
     
  10. imported_xpi0t0s

    imported_xpi0t0s New Member

    Joined:
    Jul 18, 2008
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Bizarrely the top hit in Google for "Orit Display Corporation" is this page!

    Could you give me a public URL reference to a site that has reference info for the Orit P09703? The _only_ hit in Google for "Orit P09703" is again this page.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice