Page 1 of 1
VESA pixel alignment...
Posted: Sat Jun 30, 2007 6:24 pm
by JJeronimo
Today I wrote some code to use VESA's LFB...
At first, I selected a 24bit video mode but assumed that each pixel was aligned to 32bit boundaries, but it didn't work. After that, I assumed that it was not aligned to 4 byte, and it worked.
Now, I'm scared! If I select a mode with 15-bit color depth, can I assume any special alignment, or am I doomed to pack the bits all over the frame buffer?!
JJ
Posted: Sat Jun 30, 2007 7:29 pm
by frank
It is 16 bit aligned. It is just 16 bit mode with 1 less bit for the green. At least thats how the color modes work in Direct X.
Posted: Sat Jun 30, 2007 8:30 pm
by JJeronimo
frank wrote:It is 16 bit aligned. It is just 16 bit mode with 1 less bit for the green. At least thats how the color modes work in Direct X.
So the general algorithm to obtain the number of bytes per pixel consist in rounding up the bits per pixel value to a multiple of 8, and dividing by 8, right?
JJ
Posted: Sat Jun 30, 2007 8:37 pm
by Brendan
Hi,
JJeronimo wrote:frank wrote:It is 16 bit aligned. It is just 16 bit mode with 1 less bit for the green. At least thats how the color modes work in Direct X.
So the general algorithm to obtain the number of bytes per pixel consist in rounding up the bits per pixel value to a multiple of 8, and dividing by 8, right?JJ
Yes, except for 16 colour modes and text modes...
Cheers,
Brendan
Posted: Sun Jul 01, 2007 7:22 am
by Pavia
JJeronimo wrote:frank wrote:It is 16 bit aligned. It is just 16 bit mode with 1 less bit for the green. At least thats how the color modes work in Direct X.
So the general algorithm to obtain the number of bytes per pixel consist in rounding up the bits per pixel value to a multiple of 8, and dividing by 8, right?
JJ
Not, right.
If you bits per pixel value to a multiple of 8, and dividing by 8, then have not round value.
Right.
BitsPerPixel=(BitsPerPixel+7)/8*8;
BytesPerPixel=(BitsPerPixel+7)/8
10Fh - 320x200 16.8M (8:8:8 )
112h - 640x480 16.8M (8:8:8 )
115h - 800x600 16.8M (8:8:8 )
118h - 1024x768 16.8M (8:8:8 )
11Bh - 1280x1024 16.8M (8:8:8 )
The modes can be 24bpp or 32bpp depend on video card. Test bit per pixel.
Posted: Sun Jul 01, 2007 1:41 pm
by JJeronimo
Pavia wrote:Not, right.
If you bits per pixel value to a multiple of 8, and dividing by 8, then have not round value.
Right.
BitsPerPixel=(BitsPerPixel+7)/8*8;
BytesPerPixel=(BitsPerPixel+7)/8;
You tell me that it's wrong, but then point me the same solution...
To round a number up to a multiple of x, you do:
num = int( (num+x-1) /x ) *x;
So, my assembly code will be (original bpp value in ax):
add ax, 8-1
shr ax, 3 ;Divide by 8, discarding remainder...
And now I have the bytes per pixel value...
10Fh - 320x200 16.8M (8:8:8 )
112h - 640x480 16.8M (8:8:8 )
115h - 800x600 16.8M (8:8:8 )
118h - 1024x768 16.8M (8:8:8 )
11Bh - 1280x1024 16.8M (8:8:8 )
The modes can be 24bpp or 32bpp depend on video card. Test bit per pixel.
What are those "16.8M"?
JJ
Posted: Sun Jul 01, 2007 8:08 pm
by Brendan
Hi,
JJeronimo wrote:10Fh - 320x200 16.8M (8:8:8 )
112h - 640x480 16.8M (8:8:8 )
115h - 800x600 16.8M (8:8:8 )
118h - 1024x768 16.8M (8:8:8 )
11Bh - 1280x1024 16.8M (8:8:8 )
The modes can be 24bpp or 32bpp depend on video card. Test bit per pixel.
What are those "16.8M"?
That'd be the approximate total number of colours (16777216 seperate colours to be exact).
Cheers,
Brendan
Posted: Sun Jul 01, 2007 9:10 pm
by JJeronimo
Brendan wrote:JJeronimo wrote:10Fh - 320x200 16.8M (8:8:8 )
112h - 640x480 16.8M (8:8:8 )
115h - 800x600 16.8M (8:8:8 )
118h - 1024x768 16.8M (8:8:8 )
11Bh - 1280x1024 16.8M (8:8:8 )
The modes can be 24bpp or 32bpp depend on video card. Test bit per pixel.
What are those "16.8M"?
That'd be the approximate total number of colours (16777216 separate colours to be exact).
Right.
I hadn't identified the number, cause in computing I usually consider 1K to be 1024units, even if we talk about colors...
However, I guess this isn't rigorous...
JJ
Posted: Mon Jul 02, 2007 10:59 am
by jnc100
JJeronimo wrote:I usually consider 1K to be 1024units
k = kilo = 10^3 = 1000
ki = kibi = 2^10 = 1024
M = mega = 10^6 = 1,000,000
Mi = mebi = 2^20 = 1,048,576
...
IEEE 1541
but I guess I'm just being pedantic.
Regards,
John
Posted: Mon Jul 02, 2007 12:28 pm
by JJeronimo
jnc100 wrote:JJeronimo wrote:I usually consider 1K to be 1024units
k = kilo = 10^3 = 1000
ki = kibi = 2^10 = 1024
M = mega = 10^6 = 1,000,000
Mi = mebi = 2^20 = 1,048,576
Thanksssssssss!
JJ