• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BMP to HEX Conversion

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need help converting bmp images into hex values, which will be primarily used for creating picture messages for Nokia phones.
Thanks in advance.
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So... you need to write a program to convert a series of binary numbers to hex?
What do you have written so far? maybe we can help you where you are stuck.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically you'll need to loop through the array. For each single byte, convert to two hex digits. With some spaces and line breaks thrown in for readability.
You'd think that DecimalFormat or Integer.toHexString() would help here, but I can't get that to display leading zeros when they occur (despite documentation that makes it sound like it should be possible), so I'd avoid it for this application. Without leading zeros it's harder to read - e.g. would you rather read
37 4 4 10 FF EF 7 60
83 4C A0 0 2 7D 7D 0
or
37 04 04 10 FF EF 07 60
83 4C A0 00 02 7D 7D 00
To get something like the latter, you'll have to maintain leading zeros by crafting the digits yourself. E.g.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic