RGB values?

Posted By: sheefo

RGB values? - 08/26/06 16:25

Is it possible to make 3D GameStudio read colours as RGB instead of BGR? Like maybe in A7? (or the next update).

It's gets anoying when I have to ensure everything is colour is formatted as Blue, Green then Red. Who the hell uses BGR values anyway?
Posted By: Michael_Schwarz

Re: RGB values? - 08/26/06 16:45

Quote:

Who the hell uses BGR values anyway?




Some LCD displays
Posted By: Joey

Re: RGB values? - 08/26/06 18:01

the windows gdi and graphic cards store it in this order afaik.
Posted By: sheefo

Re: RGB values? - 08/26/06 19:14

This was the first time I'd seen colour values formatted this way, I am used to RGB(A). Even DirectX uses RGB.
It would make life easier (for me) if 3D GameStudio used RGB... it's just a thought...
Posted By: ulillillia

Re: RGB values? - 08/27/06 03:18

When using BMP images, it's BGR format. You can make Gamestudio write BMP images. When writing the color 64, 128, 255, which is sky blue in the RGB format, it's treated as a bright grayish-orange color in the BGR format. You can see this for yourself. Just use this RGB color and save a small 16x16 BMP image of all this color. In a hex edittor, you'd see it as FF 80 40 repeated 256 times after the 54-byte file header data. I don't know if this applies to other image formats (like JPG, PNG, GIF, or, more easily, TGA (easy when uncompressed - Gamestudio can write uncompressed TGA images)).
Posted By: sheefo

Re: RGB values? - 08/27/06 15:53

Oh yeah. I guess, but it's like using a CD (or VCR, if you like TV) instead of a DVD in the year 2006!
Posted By: Michael_Schwarz

Re: RGB values? - 08/27/06 19:34

i still use CDs instead of DVD because CD's are more reliable...
Posted By: sheefo

Re: RGB values? - 08/27/06 19:40

... oh. Well, you got me there

EDIT: I just noticed that in SED, the 'color picker' writes it in RGB.
Posted By: ulillillia

Re: RGB values? - 08/28/06 05:25

Quote:

You can make Gamestudio write BMP images.




This proves my claim (fully tested too using pure C-script - it makes a palette much like a 16-bit palette, complete with details):

Code:

var temp_handle;

function write_bmp()
{
// max_loops = 100000;
var red_color = 0;
var green_color = 255;
var blue_color = 0;
var bit_depth;
var current_data_chunk = 0;
// var total_data_chunks;

temp_handle = file_open_write("16bitpalette.bmp");
// start file header data
file_str_write(temp_handle, "BM");
file_asc_write(temp_handle, 54); // *1 // file size (4 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 3); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 0); // *1 // reserved (2 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 0); // *1 // reserved (2 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 54); // *1 // offset to main bitmap data (4 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 0); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 40); // *1 // size of the information sector (4 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 0); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 0); // *1 // image width (4 bytes)
file_asc_write(temp_handle, 4); // *256
file_asc_write(temp_handle, 0); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 64); // *1 // image height (4 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 0); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 1); // *1 // number of planes (2 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 24); // *1 // number of bits per pixel (2 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 0); // *1 // type of compression - 0 if uncompressed (4 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 0); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 0); // *1 // size of image data (4 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 3); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 19); // *1 // X resolution - pixels per meter (4 bytes)
file_asc_write(temp_handle, 11); // *256
file_asc_write(temp_handle, 0); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 19); // *1 // Y resolution - pixels per meter (4 bytes)
file_asc_write(temp_handle, 11); // *256
file_asc_write(temp_handle, 0); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 0); // *1 // colors used - 0 if no pallete (4 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 0); // *65536
file_asc_write(temp_handle, 0); // *16777216
file_asc_write(temp_handle, 0); // *1 // number of important colors - 0 if all are important (4 bytes)
file_asc_write(temp_handle, 0); // *256
file_asc_write(temp_handle, 0); // *65536
file_asc_write(temp_handle, 0); // *16777216
// end file header data

while(current_data_chunk < 65536) // all this creates a palette of 65,536 colors
{
current_data_chunk += 1;
file_asc_write(temp_handle, int(blue_color+0.5)); // BMP uses the BGR format
file_asc_write(temp_handle, int(green_color+0.5));
file_asc_write(temp_handle, int(red_color+0.5));

red_color += 8.226;

if (red_color >= 256)
{
red_color = 0;
blue_color += 8.226;

if (blue_color >= 256)
{
blue_color = 0;
green_color -= 4.048;
}
}
}

file_close(temp_handle);
}

on_v = write_bmp();



Given that it can write BMP files, I'm pretty sure it can write any type of file as well, openable in external programs (such as creating a pure sine WAV file or duplicating an MP3). This would be a decent enhancement for my benchmark tester - create BMP images instead of just numbers in a text file.
Posted By: jcl

Re: RGB values? - 08/28/06 07:18

As to the original question: It is arguable whether RGB (as in DirectX) or BGR (as in all image formats) is better. Today I'd probably also use RGB and also the DirectX coordinate system with the upright Y axis. However, as you can imagine, once we've decided for a format we can hardly change it suddenly.
Posted By: sheefo

Re: RGB values? - 08/28/06 11:06

Wow, pretty:

© 2024 lite-C Forums