Jump to content
  • Advertisement
Sign in to follow this  
mrtie_dye

BPP, Resolution, etc

This topic is 4849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I understand that BPP stands for Bits Per Pixel, and I think that 800X600 resoultion means 800 pixels wide and 600 pixels deep. Anyone care to go into a little more depth on these topics? What exaclty does 32 BPP mean? What are the differences between 32 bpp and 16 bpp? I am messing around in SDL, using this tutorial. I really want to understand all the things in this tutorial, but I am not that great with math, and this tutorial keeps jumping off the math cliff staight into trig hell. (or something like that) I just want to learn the pixel manipulation, not how to draw a snake based on cos that is perpendicular to the sin of an obtuse triangle whose inverted base is equal to the distance between the lateral poles. I messed around with changing the bpp when setting the video mode in sdl, but the results were rather confusing. I have no idea why I got the results I did. In 32 bpp mode, I printed what I thought would be a blue box, but instead it was red. Switch to 16 bpp mode, and it is blue, but the box is longer than it should be, and there are spaces in between the pixels. ??? Also, what is the alpha component? I have a pretty good understading of RGB, but I never really grasped what the alpha component is. What is a scanline? Any links, comments; anything you can provide to help me with this is greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
BPP is how many colors you have. 16 bits per pixel means that there are 16 (2 bytes) bits of data that go to each pixel. To compute how many colors this is, just take 2 to the power of BPP. So, if you are in 16BPP mode, you have 2^16=65536 colors.

The reason your box changes colors is probably due to the way SDL indexes colors. I have never played with SDL, but I am going to guess that when you initialize a screen, each color (1, 2, 3....65536) will be defined already. So, color 0 will be black, color 1 will be green. When you change the mode and use the same number, I think you are simply going to use a different "preset" that shares its number in both modes. So, while color 3 ,may be blue in 16 bit mode, color 3 may be red in 32 bit mode.

The length issue sounds like you are changing screen resolution.

Alpha is another "component" that is specified with color. Basically, it is transparency. The more alpha, the more transparent.

I think "scanline is a generic reference to any array of pixels that is displayed horizontally.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

About colors : I'm not familiar with SDL, but in 32 bpp, blue should be 0x000000FF or 255 according to the tutorial. Red is 0x00FF0000.

About your rectangle in 16bpp : you shouldn't use the function from the tutorial. As the previous poster wrote, in 16bpp, every pixel is 2 bytes. The code from the tutorial assumes unsigned ints for every pixel. Usually the breakdown of bits in 16bpp is rrrrrggggggbbbbb (R5G6B5) or rrrrrgggggbbbbb (R5G5B5). So, every time you write your int, you're putting 2 pixels. the first has a value of 0x00FF, that is blue with a tiny bit of green and the second is 0x0000 or black. If you want to use 16bpp, you must work with 16 bits variable (unsigned shorts).


yofs = 0;
unsigned short color = 31; // 16bpp blue
for (i = 0; i < 480; i++)
{
for (j = 0, ofs = yofs; j < 640; j++, ofs++)
{
((unsigned short*)screen->pixels)[ofs] = color;
}
yofs += screen->pitch / 2; // pitch is the true width in bytes
}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I was wrong, reading the following of the tutorial shows that colors are stored in BGR format. That is, red and blue componant are swapped. So red is 0x000000FF and blue is 0x00FF0000.

Share this post


Link to post
Share on other sites
Quote:
Original post by tHiSiSbOb
I think "scanline is a generic reference to any array of pixels that is displayed horizontally.


A scanline is a horizontal line of the bitmap in bytes. It is ALWAYS divisible by four. So if you have a 24bpp bitmap of width 3, the scanline will be 3bytes x 3 + 3 bytes padding. Of course, if you are using a 32bpp bitmap the scan width will always be divisible by four.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!