首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

C语言求翻译解决办法

2012-03-09 
C语言求翻译intlpitch16(int)(ddsd.lPitch 1)USHORT*video_buffer(USHORT*)ddsd.lpSurface//这句怎

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); 这个指针位置计算就出问题了。

热点排行