I have a grayscale image in the ".raw" file format. How do i display it under DOS using C? I need a graphics mode where i have a 0-255 levels of pixel intensities.
The image is to b displayed on a SVGA console.
I have a grayscale image in the ".raw" file format. How do i display it under DOS using C? I need a graphics mode where i have a 0-255 levels of pixel intensities.
The image is to b displayed on a SVGA console.
If 64 levels of gray is enough, mode 13 (VGA) is pretty easy to use. See the links section for tutorials.
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.
No you don't. To convert from 24 bit to 8 bit color you would shift every value right by 3. Can be done for 16 bit RAW also.I need a graphics mode where i have a 0-255 levels of pixel intensities.
This way you could display the image in it's native 24-bit or in 16-bit, 256 color mode (13h).
Since it's grayscale, you won't lose much image quality in the conversion. Also since grayscale is just equal r,g,b, mode 13h would provide every greyscale color possible since it has 256 palette entries and the max value for any one color in 24 bit is 255. Each palette entry would represent one of the r,g,b greyscales in 24-bit.
You would have to parse the data and when the data is diff than any previously encountered, increment the palette index and shoot the RGB values shifted right by 3 to the ports to change the palette.
Just a comment:
You cannot use 255 levels of gray in mode 13, I have tried that . Only 64.
If you set the palette to R=G=B=PaletteIndex, you will get Black->Gray->White in index 0-63, then it will start over in index 64-127, 128-191 and 192-255.
Why? I don't know, maybe someone else do...
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.
Yes, I know. The bit depth for the colors in mode 13 is not 8, it is 6. You will get an approx. of those 255 colors when you convert them to the right format.
You could also use linear interpolation on the colors to get an approx of the greyscale image
Thanks Magos and Bubba for your replies. I was the one who started this thread (though i was unregistered at that time).
Unfortunately, i was off the problem for nearly a week.
Now, i am back on it, but am right where i left.
I am using the 13h mode of VGA. It offeres 256 colors, out of which i observed that only 16 are gray(16-31). So, that leaves with me a graylevel of 16.
Going frm a 256 depth to 16 depth image is quite some degradation. Could you elaborate on how to get 64 (or preferably 256 ) gray levels.
maybe i need only to change the palette in 13h mode ? but if so, how do i do that ?
in 13h, i guess there r no RGB values - its just 1 byte of colorvalue for a pixel.
One more thing...if 256 gray levels are possible with SVGA programming...do tell me about that.
In the links section, there is a link to www.brackeen.com where you can find some really good mode 13 tutorials. One of them covers palette manipulation. Sorry, but I have no experience with SVGA however...Originally posted by kp
Going frm a 256 depth to 16 depth image is quite some degradation. Could you elaborate on how to get 64 (or preferably 256 ) gray levels.
maybe i need only to change the palette in 13h mode ? but if so, how do i do that ?
That's right, they use a palette to store the RGB data instead of storing the RGB value for each pixel. You get lesser colours, but it saves memory! That is one reason why this graphics mode is "easy" to use...Originally posted by kp
In 13h, i guess there r no RGB values - its just 1 byte of colorvalue for a pixel.
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.
hey..thanks Magos. that was a great link. i adjusted the palette, and now...as u already told me of the limitation...i have a 64 gray level display. though this might do...but can i push my luck further ? any chance of getting a 256 level display ?
Bubba, you said something about 'converting to the right format'..cud u plz elaborate on that ?
one thing more ....while in the 13h VGA mode only...i want some formatted text display. like i want a string to be displayed at the bottom of the screen. how do i achieve that ?
and thanks again for all ur effort. i won't have got the display working without ur help.
Not in mode 13, I believe. You have to learn SVGA . Try a search on google, or search for SVGA on the forum.Originally posted by kps
hey..thanks Magos. that was a great link. i adjusted the palette, and now...as u already told me of the limitation...i have a 64 gray level display. though this might do...but can i push my luck further ? any chance of getting a 256 level display ?
There are no standard function that prints good-looking text in mode 13. You could use printf(), however the result is not so good . The best would be to build your own function that loads a bitmap (containing all the letters) and draw them to the screen.
Bubba, you said something about 'converting to the right format'..cud u plz elaborate on that ?
one thing more ....while in the 13h VGA mode only...i want some formatted text display. like i want a string to be displayed at the bottom of the screen. how do i achieve that ?
Glad I could be of help.
and thanks again for all ur effort. i won't have got the display working without ur help.
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.
You can try 0x10F mode from the VESA standard - this is 320x200x32 mode and you will get all the 256 levels of gray.
regards,
Bojidar
Most cards do not support 320x200 hi-color modes