|
int lpitch16 = (int)(ddsd.lPitch >> 1);
USHORT *video_buffer = (USHORT *)ddsd.lpSurface;
// plot 1000 random pixels with random colors on the
// primary surface, they will be instantly visible
for (int index=0; index < 1000; index++)
{
// select random position and color for 640x480x16
int red = rand()%256;
int green = rand()%256;
int blue = rand()%256;
int x = rand()%800;
int y = rand()%600;
// plot the pixel
Plot_Pixel_Faster16(x,y,red,green,blue,video_buffer,lpitch16);
} // end for index
inline void Plot_Pixel_Faster16(int x, int y,
int red, int green, int blue,
USHORT *video_buffer, int lpitch16)
{
// this function plots a pixel in 16-bit color mode
// assuming that the caller already locked the surface
// and is sending a pointer and byte pitch to it
// first build up color WORD
USHORT pixel = _RGB16BIT565(red,green,blue);
// write the data
video_buffer[x + y*lpitch16] = pixel;
} // end Plot_Pixel_Faster16
//======================================分割线=============================================
int mempitch = (int)ddsd.lPitch;
USHORT *video_buffer = (USHORT *)ddsd.lpSurface;
// plot 1000 random pixels with random colors on the
// primary surface, they will be instantly visible
for (int index=0; index < 1000; index++)
{
// select random position and color for 640x480x16
USHORT color = rand()%256;
int x = rand()%800;
int y = rand()%600;
// plot the pixel
video_buffer[x+y*mempitch>>1] = color;
} // end for index
///////////////////////////////////==========================================================================
我知道问题应该是出现在lPitch上,但是想不通,在相同的视频模式下,第一个可以全屏填充像素,但是第二个只能填充全屏的一半:左边,另外一边为空,希望大家能帮我解决下,谢谢。
注:
typedef unsigned short USHORT;
typedef unsigned short WORD;
typedef unsigned char UCHAR;
typedef unsigned char BYTE; |
|