We now have really extracted the value for Green, in this case 49. Because we did shift the values during the extraction, we must shift them back when building up the new pixel. It isn't indeed. Therefore, I wrote a function which does expensive precalculations. It is called PrecalcRGBcomponents .
Clipping When drawing an image, clipping is a very important thing to do.
The first and most important reason is that whithout clipping, you could write into buffer-memory which isn't yours, and your program will crash. The second, also important reason is that it is a waste of CPU to draw pixels which are not within the visible user-screen. This paragraph expains clipping. You will notice that it is fairly simple to implement. I will explain the algoritm first, and then show some examples and the corresponding clipped values.