VESA pixel alignment...
VESA pixel alignment...
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
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
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?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.
JJ
Hi,
Cheers,
Brendan
Yes, except for 16 colour modes and text modes...JJeronimo wrote: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?JJfrank 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.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Not, right.JJeronimo wrote: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?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.
JJ
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.
You tell me that it's wrong, but then point me the same solution...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;
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...
What are those "16.8M"?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.
JJ
Hi,
Cheers,
Brendan
That'd be the approximate total number of colours (16777216 seperate colours to be exact).JJeronimo wrote:What are those "16.8M"?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.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Right.Brendan wrote:That'd be the approximate total number of colours (16777216 separate colours to be exact).JJeronimo wrote:What are those "16.8M"?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.
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
k = kilo = 10^3 = 1000JJeronimo wrote:I usually consider 1K to be 1024units
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