Graphics 101 -- Frame Buffer

Graphics 101 Frame Buffer

When dealing with graphic images there are various parameters defining its geometry.

  • memptr The base pointer to a coordinate within the image related to its physical memory address.

  • bits per pixel The number of bits per pixel used to represent the image. Typically 1/4/8/16/24/32-bit but pretty much only 8- to 32-bit are used these days.

  • width The width of the image in pixels.

  • height The height of the image in pixels.

  • stride The number of bytes used to represent the start of one row of pixels to the start of another. It should be noted that there may be extra bytes beyond the last visible pixel and the start of the row of pixels. For example, in Figure 19-2 the 640-pixel scanline has an overage of 384 bytes. That means when you write that 640 th pixel you need to add 384 to get to the start of the next scanline (640+384=1024).

    image from book
    Figure 19-2: Bitmap dimension information

So now let's use this information in some real code.

 #ifdef __cplusplus extern "C" void gfxClrAsm(byte *pDst, uint nStride,  uint nWidth, uint nHeight); #endif                  //   Comment this line out for C code #define USE_ASM_GFXCLR          //   Graphics Clear      //      //   This is a pre-clipped function used to clear a bitmap      //   pointed to by the destination pointer.      //   Note: This can be used to clear 8/16/24/32-bit pixels.     #ifdef USE_ASM_GFXCLR #define gfxClr   gfxClrAsm #else     void gfxClr(byte *pDst, uint nStride, uint nWidth, uint nHeight) {     do {         memset(pDst, 0, nWidth);         pDst += nStride;      } while (--nHeight); } #endif 

Project:

Using what you've learned, try to write the C function above in assembly optimized for your processor.

 void gfxClrAsm(byte *pDst, uint nStride, uint nWidth, uint nHeight); 


32.64-Bit 80X86 Assembly Language Architecture
32/64-Bit 80x86 Assembly Language Architecture
ISBN: 1598220020
EAN: 2147483647
Year: 2003
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net