Bitmap in Notepad...

This is a discussion on Bitmap in Notepad... within the Game Programming forums, part of the General Programming Boards category; For fun, I opened up a bitmap in notepad. It was just a bunch of jibberish followed by a lot ...

  1. #1
    Ecologist
    Join Date
    Aug 2001
    Location
    Utah.
    Posts
    1,291

    Bitmap in Notepad...

    For fun, I opened up a bitmap in notepad. It was
    just a bunch of jibberish followed by a lot of
    squares (I'm sure you people already knew this)...

    At the beginning of the file there is a BM. Is
    this the BM that you check when you load
    a bitmap in a C-program? Is the rest of the
    jibberish the remainder of the header?

    Here is the jibberish to my bitmap:

    BM ( <      $
    ??? OHO OOO ```  .. p 0 O
    ?? P _? O _ o? p .. .._.. ???
    ? ..


    After this, there was a bunch of sqares and
    dots (.). Are the squares/dots the actual
    data? How can I see what's behind these squares?

    Will someone explain this stuff to me? Please?
    Last edited by Cheeze-It; 11-07-2001 at 02:00 AM.
    Staying away from General.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    19
    When Notepad reads a file, it does so assuming it's in ASCII-code binary form. since a bitmap is not intended to be read as characters / numbers, it appears to be 'jibberish'. each character representation is the collective value of each 8 BITS of bitmap data (max. value 255 - one BYTE - one CHARACTER)!

    with that in mind, you could quite easily write a conversion program which would take each character and convert it into binary form. alternatively, you could use a Hex editor (i.e. HexWorks). the data here is NOT strictly all for the bit map; there are two other sections (i.e. an 8x8 bitmap will NOT consist of 8x8=64 bits=8 bytes):

    1) Bitmap Header: contains version, compression and other information related to the bitmap
    2) Colours: defines the colours (RGB) used by the bitmap

    Peter Kimberley
    peter_kimberley@hotmail.com
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    Use the type command from a console prompt for, erm, prettier jibberish (extended ASCII - no boxes). (It will probably beep a bit too.)
    ie:
    type pic.bmp
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

  4. #4
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    If you have Visual C++ and open it as a binary file it displays it correctly

  5. #5
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Question

    Hmm, just wondering. In a 256 colour bitmap, each pixel would be 1 byte (8 bits), right? That means that each character that shows up in notepad (from the actual data-part) would represent a pixel in the picture.
    So if you know the ASCII-value for every character, you can actually "see" the picture in notepad..?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  6. #6
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133
    Is there a way to read in the header for the bitmap and then modify it?

    Here is my situation. My daugher(2yrs old) is learing how to use the computer. And she likes to use paint. I have taken some of her coloring books and coppied(scanner) them onto the hd. But I coppied them in black and white(to reduce shades/colors). Now I have a nice looking picture for her to color. The only problem is that it is in b/w only, no color can be used.

    There must be a way to do this right? Can anyone point me into the right direction? I am going to try google in a minute, to see if I can find anything. But don't let that stop you from helping.
    C++ Is Powerful
    I use C++
    There fore I am Powerful

  7. #7
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Well, I believe that you just open the picture in paint then select SAVE AS.
    Somewhere in the window that pops up, you can choose which colour depth you want to save it in, for example: 2 (Black/White), 8, 16, 256, 16bit, 24bit or 32bit.
    Select whichever you want and then click on SAVE (maybe it's OK?)

    Done!
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    19
    in theory, i think that'd work - good luck remembering all 255 character codes, though!! trouble is, however, the fonts used in Windows do not display all 255 characters, and you will therefore only see a number of them (depending on the font used). even EDIT.COM in DOS (Justin W mentioned this earlier) will not display all, as escape characters (i.e. 13, 10, 0, etc.) will be used in page formatting. also is the header which you will not know the size of, so will not know where it ends, and further the dimensions of the bit map will be unknown, so you won't know how to adjust the wrapping in Notepad accordingly.....

  9. #9
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Originally posted by kimberleyp
    Even EDIT.COM in DOS (Justin W mentioned this earlier) will not display all, as escape characters (i.e. 13, 10, 0, etc.) will be used in page formatting.
    What does the "formatting" characters do in a text file? ie. does character 13 make a new line? 10 makes a tab jump?
    Could be useful if you wanted to create a nicely formatted textfile in a program *HINT*
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  10. #10
    Registered User
    Join Date
    Oct 2001
    Posts
    375
    True the formatting doesn't give you a very good picture of what's going on (backspace seems to come up a lot in binary files and erases the text before it.. amusing to watch on a 486 as a line will print characters, then erase them, then print, etc several times). Also return character is not new line, and thus it will overwrite previous characters on the line.....

    You'd need a binary editor to do this by hand, but the best solution is just to write your own prog to parse out the bitmap info.
    Allegro precompiled Installer for Dev-C++, MSVC, and Borland: http://galileo.spaceports.com/~springs/

  11. #11
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    oh, and palette's would give you a problem... so you'd be able to, yes, distinguish similar 'shades'... however the rest would be arbitrary...

    plus, you have 24 bit formats too, which brings about even more confusion... good luck! [i happen to know a lot about bitmaps, so ask me if you would like... i like getting pms... ]
    hasafraggin shizigishin oppashigger...

  12. #12
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Yes, actually

    Yes, actually I have a problem with bitmaps... or rather the actual data reading from a bitmap. But the code is pretty large, so I'll wait to ask about it until I have shortened it a little to make it more readable (it is badly commented too ).
    What the program does is converting 24bit bitmaps into 8bit bitmaps, with a "good color result" (colors get screwed up sometimes ).

    PS: Is it spelled color or colour???
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  13. #13
    Registered User Kuplex's Avatar
    Join Date
    Dec 2001
    Posts
    18
    Don't worry too much about it. Unless you really need to modify it that way--but then, use something that will open up the binary version or hex version of it, then editing through the code is possible. (or at least easier)
    Kuplex
    "The only thing you can count on is uncertainty."

    Must I explain myself futher?

  14. #14
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    hehe... mark of a true professional: uncommented bloatware...

    take your time! and PM me too if you like...
    hasafraggin shizigishin oppashigger...

  15. #15
    Unregistered
    Guest

    Re: Yes, actually

    Originally posted by Magos
    PS: Is it spelled color or colour???
    Englishmen say colour, Americans say color.
    (say color though, because Americans are cooler and englishmen say TOMAAAAAAAHTO and POTAAAAAAAAAHTO)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 05:04 PM
  3. Loading a Bitmap resource for OpenGL Texture[x]
    By the dead tree in forum Game Programming
    Replies: 4
    Last Post: 08-26-2004, 02:12 PM
  4. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM
  5. texture is all white in opengl!
    By Crossbow in forum Game Programming
    Replies: 7
    Last Post: 03-31-2002, 11:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21