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?
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?
Use a graphics library... like allegro... or SDL or Directx or opengl... learn about those
Thats one way,but then you become dependant on those libraries,i'd rather stay independant and right my own code for it
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!
that's interesting,but i abhore windows realy,and it would realy be windows writing the bit-maps,not my program.
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.
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.
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.
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 <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
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