Pages

Tuesday, June 11, 2013

Surface and pixel studying notes

My webcam test function captures an image in the Surface format.  But I don't know what exactly is a surface.  So I googled the following.

After the reading, I now know what is a surface.  But is the image in surface format a BMP file, or a jpeg file?


Pixel and Surface 

http://msdn.microsoft.com/en-us/library/windows/desktop/bb153349(v=vs.85).aspx

In Microsoft Direct3D, all two-dimensional (2-D) images are represented by a linear range of memory called a surface. A surface can be thought of as a 2-D array in which each element holds a color value that represents a small section of the image, called a pixel

An image's detail level is defined both by the number of pixels needed to represent the image and the number of bits needed for the image's color spectrum.

For example, an image that is 800 pixels wide by 600 pixels tall with 32 bits of color for each pixel (written as 800x600x32) is more detailed then an image that is 640 pixels wide by 480 pixels tall with 16 bits of color for each pixel (written as 640x480x16).

Likewise, the more detailed image requires a larger surface to store the data. For an 800x600x32 image, the surface's array dimensions are 800x600, and each element holds a 32-bit value to represent its color.

All surfaces have a size and store a specific number of bits that represent color. These bits are separated into individual color elements: red, green, and blue.

In Microsoft DirectX 9.0 for Managed Code, all color elements are defined by the Format enumeration. A color format is broken down into the number of byes reserved for each color. For example, a 16-bit color format is defined as Format.R5G6B5, where five bits are reserved for red (R), six bits for green (G), and five bits for blue (B).

All formats are listed from left to right, most significant bit (MSB) to least significant bit (LSB). For example, ARGB is ordered from the MSB channel A (alpha) to the LSB channel B (blue). During traversal of surface data, the data is stored in memory from LSB to MSB, which means that the channel order in memory is from LSB (blue) to MSB (alpha).

The default value for formats that contain undefined channels is 1. The only exception is the A8 format, which is initialized to 000 for the three color channels.

.END

No comments:

Post a Comment