Thread: Help with a code (beginner)

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    6

    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. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    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?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    6
    Quote Originally Posted by Salem View Post
    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. #4
    Registered User
    Join Date
    Sep 2012
    Posts
    357
    How would you convert the binary value 111 to decimal? 00000000000000000007 or 00000000000000007?

  5. #5
    Registered User
    Join Date
    Sep 2012
    Posts
    6
    Quote Originally Posted by qny View Post
    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. #6
    Registered User
    Join Date
    Sep 2012
    Posts
    6
    But why should i convert hex 0x30 to bin 110000?

  7. #7
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Quote Originally Posted by LK93 View Post
    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?!
    Devoted my life to programming...

  8. #8
    Registered User
    Join Date
    Sep 2012
    Posts
    6
    Quote Originally Posted by GReaper View Post
    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?

    And what does TGA_FLIP_MASK means?

    I am really sorry for my questions, i know i sound retarded but i am just trying to get it...
    Last edited by LK93; 09-23-2012 at 02:57 PM.

  9. #9
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Quote Originally Posted by LK93 View Post
    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.

    Quote Originally Posted by LK93 View Post
    And what does TGA_FLIP_MASK means?
    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]
    Devoted my life to programming...

  10. #10
    Registered User
    Join Date
    Sep 2012
    Posts
    6
    Quote Originally Posted by GReaper View Post
    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. #11
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    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.
    Last edited by Adak; 09-24-2012 at 12:21 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner code assistance
    By akust0m in forum C Programming
    Replies: 6
    Last Post: 08-07-2012, 09:29 PM
  2. help me with this code [beginner]
    By fredsilvester93 in forum C++ Programming
    Replies: 1
    Last Post: 01-21-2012, 03:41 PM
  3. A beginner's code, need suggestion
    By sumitsatsangi in forum C++ Programming
    Replies: 7
    Last Post: 01-21-2012, 06:00 AM
  4. Problem with beginner code... please help
    By rkrajnov in forum C Programming
    Replies: 2
    Last Post: 09-25-2010, 11:47 PM
  5. beginner here need help with an array code
    By Ohshtdude in forum C++ Programming
    Replies: 6
    Last Post: 02-01-2009, 05:42 PM