读书人

C语言求翻译解决办法

发布时间: 2012-03-09 16:54:57 作者: rapoo

C语言求翻译
int lpitch16 = (int)(ddsd.lPitch > > 1);
USHORT * video_buffer = (USHORT *)ddsd.lpSurface; //这句怎么写,delphi里lpSurface是Pointer类型,书上看是内存的偏移量地址

for (int index=0; index < 1000; index + +) //循环
{
int red = rand () %256; //随机数
int green = rand () %256;
int blue = rand () %256;
int x = rand ()% 800;
int y = rand () %600;

//写入内存
video_buffer[x+y*lpitch16]=_RGB16BIT(red,green,blue); //这句又怎么写,_RGB16BIT过程已经翻译好了
}


[解决办法]
var
video_buffer : PWord;
pRGB : PWord;
这样不行。
这样的话, inc(pRGB)是按Word(即两个字节)来移动指针的,
那么 inc (pRGB, x + y * lpitch16); 这个指针位置计算就出问题了。

读书人网 >.NET

热点推荐