C
czw6296
Unregistered / Unconfirmed
GUEST, unregistred user!
以下程序是将屏幕分成3*3的小格子,每个格子填充颜色,当填充整个屏幕时,速度较慢,一秒钟只能进行2次。
有谁知道媒体播放器是如何填充颜色的,没有感觉到有停顿现象,不会使用setpixel吧,那样速度会更慢。
deltaw=3;
deltah=3;
void TForm1:raw(void)//如何提高速度
{
HDC DC;
if (lpDDSPrimary->IsLost() == DDERR_SURFACELOST)
lpDDSPrimary->Restore();
if (lpDDSBack->GetDC(&DC) == DD_OK)
{
Canvas->Handle = DC;//能否不用Canvas,直接写缓存,加快速度?
if(phase)
{
top=1;
//填充方格颜色,当方格数量较多时,速度较慢
for(int i=0;i<Canvas->ClipRect.Bottom;i+=deltah)
{
left=1;
for(int j=0;j<Canvas->ClipRect.Right;j+=deltaw)
{
Canvas->Brush->Color=(TColor)RGB(255-i,255-j,255-i*j);
Canvas->FillRect(Rect(left,top,left+deltaw,top+deltah));
left+=deltaw;
}
top+=deltah;
}
Canvas->TextOutA(50,100,"Front"
phase = 0;
}
else
{
top=1;
for(int i=0;i<Canvas->ClipRect.Bottom;i+=deltah)
{
left=1;
for(int j=0;j<Canvas->ClipRect.Right;j+=deltaw)
{
Canvas->Brush->Color=(TColor)RGB(255-i*j,255-j,255-i);
Canvas->FillRect(Rect(left,top,left+deltaw,top+deltah));
left+=deltaw;
}
top+=deltah;
}
Canvas->TextOutA(50,150,"Back"
phase = 1;
}
lpDDSBack->ReleaseDC(DC);
}
}
以上程序来自c++builder的例子,我做了修改,如果有朋友想要源代码,请留下email共同探讨
有谁知道媒体播放器是如何填充颜色的,没有感觉到有停顿现象,不会使用setpixel吧,那样速度会更慢。
deltaw=3;
deltah=3;
void TForm1:raw(void)//如何提高速度
{
HDC DC;
if (lpDDSPrimary->IsLost() == DDERR_SURFACELOST)
lpDDSPrimary->Restore();
if (lpDDSBack->GetDC(&DC) == DD_OK)
{
Canvas->Handle = DC;//能否不用Canvas,直接写缓存,加快速度?
if(phase)
{
top=1;
//填充方格颜色,当方格数量较多时,速度较慢
for(int i=0;i<Canvas->ClipRect.Bottom;i+=deltah)
{
left=1;
for(int j=0;j<Canvas->ClipRect.Right;j+=deltaw)
{
Canvas->Brush->Color=(TColor)RGB(255-i,255-j,255-i*j);
Canvas->FillRect(Rect(left,top,left+deltaw,top+deltah));
left+=deltaw;
}
top+=deltah;
}
Canvas->TextOutA(50,100,"Front"
phase = 0;
}
else
{
top=1;
for(int i=0;i<Canvas->ClipRect.Bottom;i+=deltah)
{
left=1;
for(int j=0;j<Canvas->ClipRect.Right;j+=deltaw)
{
Canvas->Brush->Color=(TColor)RGB(255-i*j,255-j,255-i);
Canvas->FillRect(Rect(left,top,left+deltaw,top+deltah));
left+=deltaw;
}
top+=deltah;
}
Canvas->TextOutA(50,150,"Back"
phase = 1;
}
lpDDSBack->ReleaseDC(DC);
}
}
以上程序来自c++builder的例子,我做了修改,如果有朋友想要源代码,请留下email共同探讨