# Thread: Help with a code (beginner)

1. ## Help with a code (beginner)

Hi!

I am new at c programming and need some help... Its involve images stored on disk in a bitmap in TGA format. I am not shore if how much i need to explain, i post a part of the file and hope someone can explain a solution...

http://i45.tinypic.com/fyhc15.png (the 0x30 you need to convert to binary format)

And this you need to complete the code.

http://i49.tinypic.com/1zbr41.png

i really need help...

Sorry for the language...

2. So how much of a "beginner" are you?

The kind of beginner that did "hello world" this morning, and now you're tackling image format conversion?

Or are you at a stage where you're comfortable with fopen / fread etc and just need a bit of a nudge towards your goal?

3. Originally Posted by Salem
So how much of a "beginner" are you?

The kind of beginner that did "hello world" this morning, and now you're tackling image format conversion?

Or are you at a stage where you're comfortable with fopen / fread etc and just need a bit of a nudge towards your goal?
I can handle fopen fread and so, but i am not a expert... So how about 0x30 in binary format? is it just 00110000 or 000110000? And why?

4. How would you convert the binary value 111 to decimal? 00000000000000000007 or 00000000000000007?

5. Originally Posted by qny
How would you convert the binary value 111 to decimal? 00000000000000000007 or 00000000000000007?
I would convert it to 7. But i still don't know how to write 0x30 is it 110000? The 0x don't do anything or what?

6. But why should i convert hex 0x30 to bin 110000?

7. Originally Posted by LK93
But why should i convert hex 0x30 to bin 110000?
You could convert it to 00110000.0000 if you wanted, but what's the point? Extra zeros are discarded because they are insignificant.

EDIT: It's like saying "Should I write seven as 7.0 or 7.00?" Say what?!

8. Originally Posted by GReaper
You could convert it to 00110000.0000 if you wanted, but what's the point? Extra zeros are discarded because they are insignificant.

EDIT: It's like saying "Should I write seven as 7.0 or 7.00?" Say what?!
Okej, but why should i convert it from 0x30 to 110000? What happens in the code?

I am really sorry for my questions, i know i sound retarded but i am just trying to get it...

9. Originally Posted by LK93
Okej, but why should i convert it from 0x30 to 110000? What happens in the code?
You don't convert anything. You just print it on a different base. Everything in the code is encoded to binary.

Originally Posted by LK93
Wow, I simply don't know and can't find any info on that!
[wild_guess] It's a preprocessor constant for Targa image files to get if the image should be flipped or not, through a bitfield [/wild_guess]

10. Originally Posted by GReaper
You don't convert anything. You just print it on a different base. Everything in the code is encoded to binary.

Wow, I simply don't know and can't find any info on that!
[wild_guess] It's a preprocessor constant for Targa image files to get if the image should be flipped or not, through a bitfield [/wild_guess]
Okey, thanks!

For some reasons i don't want to post the entire code here... I know this is much to ask for, but do you have time to help me with the code on email or some chat function?

11. I'd say study up on what it is that you want to do with the data, and then post the smallest example of it that you can, for code -- not your current whole program.

Changing formats is bogus - it's like changing from a whitewall to a blackwall, tire, which are otherwise identical, and expecting your car to accelerate faster, somehow.

OK, that analogy isn't nearly as good as GReaper's, but let's move on.