我在用 Delphi+DirectDraw 编程时遇到了一个这样的问题:
C++语言的代码为:
DDSURFACEDESC2 ddsd;
......
int mempitch = ddsd.lPitch;
UCHAR * video_buffer = 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++)
{
UCHAR color = rand() % 256;
int x = rand() % 640;
int y = rand() % 480;
// plot the pixel
video_buffer[x+y*mempitch] = color;<<<<----------问题所在处???
} // end for index
其中lpSurface是一个指针,怎样才能把标记出来的部分变为Pascal语言呢?
delphi中的指针不象C,C++中那样灵活,碰到问题真难解决!!!
C++语言的代码为:
DDSURFACEDESC2 ddsd;
......
int mempitch = ddsd.lPitch;
UCHAR * video_buffer = 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++)
{
UCHAR color = rand() % 256;
int x = rand() % 640;
int y = rand() % 480;
// plot the pixel
video_buffer[x+y*mempitch] = color;<<<<----------问题所在处???
} // end for index
其中lpSurface是一个指针,怎样才能把标记出来的部分变为Pascal语言呢?
delphi中的指针不象C,C++中那样灵活,碰到问题真难解决!!!
可以转换为
PByte(Integer(video_buffer)+x+y*mempitch])^ := color;
可以转换为
PByte(Integer(video_buffer)+x+y*mempitch))^ := color;