What about Bitmaps and other images?

This is a discussion on What about Bitmaps and other images? within the C++ Programming forums, part of the General Programming Boards category; Is it posible to dynamicaly create an image?if so please be patient and tell how.And how do you display an ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    44

    What about Bitmaps and other images?

    Is it posible to dynamicaly create an image?if so please be patient and tell how.And how do you display an image in C and/or C++?Also,does anybody have a suggestion for how to make nice looking graphics and images?

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    100
    Use a graphics library... like allegro... or SDL or Directx or opengl... learn about those

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    44
    Thats one way,but then you become dependant on those libraries,i'd rather stay independant and right my own code for it

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    Those graphics libraries are a bit much for accomplishing what the original poster is trying. Windows API is necessary for using at least a couple of those libraries anyway. You might as well use the Windows API to display your bitmap!

    If you know Windows API look into SetDiBits() That should make you happy!

  5. #5
    Registered User
    Join Date
    Jun 2002
    Posts
    44
    that's interesting,but i abhore windows realy,and it would realy be windows writing the bit-maps,not my program.

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    Cut the first 2 bytes off of a bitmap and discard. Read in the next 52 bytes into an array of integers and view. If the bitmap is single color, by viewing the remaining bits, you will see the obvious pattern.

  7. #7
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    ok, then what you want is to generate a bmp file? Well I'll do my best to explain the format. For starters, there are a few structures you'll need to know. BITMAPINFOHEADER, BITMAPFILEHEADER, BITMAPINFO, RGBQUAD. I'm not going to put them all out here just cause I'm lazy but you can do the research on that part. The bmp file is as follows

    BITMAPINFOHEADER
    BITMAPINFO
    which is
    BITMAPINFOHEADER and the color palette table.

    The size of the color palette table is dependant on the bit depth defined in BITMAPINFO structure. if you are dealing with 256 colors your color table will be sizeof(RGBQUAD)*256. A full color bitmap has no color table.

    All rows are multiples of 4 bytes so you have "padding" when there is a non-multof4 number of pixels.

    pixels are indexes into the table when 256 color or less, pixels are RGBQUAD when full color.

  8. #8
    Registered User
    Join Date
    Jun 2002
    Posts
    44
    Thanks,that explains alot,i pasted your reply to a file on HD just to make sure i didn't lose it .But what about displaying the BMP without an API after it is created,i guess that was my real question.

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    Well, for that, you'll need assembly programming. I don't know how that's done quite yet. But you will be writing the bytes directly to the video memory. There is no "easy" way, though. Good luck.
    Code:
    #include <ip.hpp>

  10. #10
    Registered User
    Join Date
    Jul 2002
    Posts
    273
    ok, since you hate windows you'll probably be working in dos. This means mode 13 or mode X is most likely. Like sebastiani said, there is assembly instruction for changing the mode of the video card and setting video memory pixels. for help on this, do a search for denthor graphics tutorials. It's an old dos graphics programming tutorial that seems to suit your situation quite well

Popular pages Recent additions subscribe to a feed

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