User avatar
mbferguson
Posts: 31
Joined: Thu Nov 15, 2018 2:33 pm

Hexdump outputting too many radixes (was) VERY ANNOYING!!! [Solved]

Tue Nov 20, 2018 1:51 pm

I am trying to get some icons to display on my arduino TFT screen. I'm using the following example on the mcufriend library --> drawBitmap_kbv. There is a clear way he has gone about putting the bitmap radixes into an array. He is using a 64x64 bit icon, I don't want my icon to be that big but I'm starting at that point so it is easier to see what I must do. His array is simply an array of uint16 that has 4096 elements. Makes sense... 64x64 = 4096.

Here's the problem. When I do this on the pi terminal

$ hexdump -e '16/1 " %04X" "\n"' image.bmp

It gives me an array of 16 x 777 radixes... with the last row having a bit less = 12426 radixes

There's no way to divide that number and get 4096 so it can't be that I entered the command twice or anything. WHAT IS WRONG??? :x

Image
Last edited by mbferguson on Tue Nov 20, 2018 4:56 pm, edited 1 time in total.

User avatar
mbferguson
Posts: 31
Joined: Thu Nov 15, 2018 2:33 pm

Re: Hexdump outputting too many radixes VERY ANNOYING!!!

Tue Nov 20, 2018 3:20 pm

I found the answer in the BMP documentation. There is simply an enormous amount of header information, color definitions, etc. So now I get to write a java program to print 0x in front and comma after of all the radixes :lol:

dave j
Posts: 116
Joined: Mon Mar 05, 2012 2:19 pm

Re: Hexdump outputting too many radixes VERY ANNOYING!!!

Tue Nov 20, 2018 3:46 pm

You're much better off saving your BMP file in a format that doesn't have a header (or at least a fixed size one so you can discard the data you don't want).

That 16 x 777 radixes is a) because it includes the BMP header, b) because you've got a 24 bit per pixel BMP file rather than a 16 bit one needed for your display (implied by the uint16 in your post) and c) you're processing a byte at a time not two.

If you save your BMP file as 16 bits per pixel, and try

Code: Select all

hexdump -v -e '16/2 "0x%04X, " "\n"' image.bmp
that will give you something closer to what you want - although it will include the BMP header.


jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23071
Joined: Sat Jul 30, 2011 7:41 pm

Re: Hexdump outputting too many radixes VERY ANNOYING!!!

Tue Nov 20, 2018 4:37 pm

You can use the cut command to remove the header prior ro piping to hexdump

IIRC, `cut -c 54-` will remove the first 54 bytes, which is the size of some BMP files header- but you will need to check which format of BMP you are using.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

User avatar
mbferguson
Posts: 31
Joined: Thu Nov 15, 2018 2:33 pm

Re: Hexdump outputting too many radixes VERY ANNOYING!!!

Tue Nov 20, 2018 4:41 pm

Jamesh, why is there no way to upvote/like comments on this forum? When someone help me I want to give them the thumbs up, and the only way to tell if someone is a forum badass is by their post count. I could simply post a bunch of wrong answers and pretend I'm a cool guy then...

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23071
Joined: Sat Jul 30, 2011 7:41 pm

Re: Hexdump outputting too many radixes VERY ANNOYING!!!

Tue Nov 20, 2018 4:43 pm

We've considered it, but IIRC either the forum software doesn't support it, or we didn't think it was a good idea. It was a while back.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

jahboater
Posts: 4595
Joined: Wed Feb 04, 2015 6:38 pm

Re: Hexdump outputting too many radixes VERY ANNOYING!!!

Tue Nov 20, 2018 4:50 pm

mbferguson wrote:
Tue Nov 20, 2018 4:41 pm
Jamesh, why is there no way to upvote/like comments on this forum? When someone help me I want to give them the thumbs up, and the only way to tell if someone is a forum badass is by their post count. I could simply post a bunch of wrong answers and pretend I'm a cool guy then...
Why not just a quick reply like:- "I tried your suggestion. It worked really well. Thanks for the help!"

User avatar
mbferguson
Posts: 31
Joined: Thu Nov 15, 2018 2:33 pm

Re: Hexdump outputting too many radixes VERY ANNOYING!!!

Tue Nov 20, 2018 4:53 pm

jahboater wrote:
Tue Nov 20, 2018 4:50 pm
mbferguson wrote:
Tue Nov 20, 2018 4:41 pm
Jamesh, why is there no way to upvote/like comments on this forum? When someone help me I want to give them the thumbs up, and the only way to tell if someone is a forum badass is by their post count. I could simply post a bunch of wrong answers and pretend I'm a cool guy then...
Why not just a quick reply like:- "I tried your suggestion. It worked really well. Thanks for the help!"
I want the other guy to be able to show it to the other cool guys, so they can gauge who is the coolest 8-)

Also there are too many sticky threads I gotta scroll past every time I get on here :| :x

W. H. Heydt
Posts: 10582
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Hexdump outputting too many radixes VERY ANNOYING!!!

Tue Nov 20, 2018 4:54 pm

mbferguson wrote:
Tue Nov 20, 2018 4:41 pm
Jamesh, why is there no way to upvote/like comments on this forum? When someone help me I want to give them the thumbs up, and the only way to tell if someone is a forum badass is by their post count. I could simply post a bunch of wrong answers and pretend I'm a cool guy then...
Probably the most effective way to do that is to (a) thank those that helped, (b) state that what parts solved your problem, and (c) change your thread title to be prefixed with "[SOLVED]".

Return to “General discussion”