Form中Image控件显示图片闪烁的问题,不是DoubleBuffered问题,是鼠标移上去就会闪的问题
做了一个udp传说的桌面采集的东西,但在接收方显示时出了一些问题
我的显示流程:将接收到的图片流拼接成大图,再直接用Form中的image空间assign生成的大图,效果是显示没问题,不闪烁(在Form中已经定义了doublebuffered = true),但是只要将鼠标移入窗口或者在窗口中移动,窗口就会闪烁且内存会开始不正常增加,考虑是不是欧尼mousemove的问题但是具体不清楚,望大神指导
贴上我的合成图片及显示的代码
void CSCREENFORCEDSYNCLIENTCLASS::TransformPngToBmpAndMergeIntoOneImage()
{
int i = 0;
unsigned short usTotalWidthTemp = 0;
unsigned short usTotalHeightTemp = 0;
unsigned short usSingleWidthTemp = 0;
unsigned short usSingleHeightTemp = 0;
this->iMergeSuccess = 0;
//char cFilenameTemp[32]= ".\\test\\total.bmp";
//AnsiString ansiFileName = AnsiString(cFilenameTemp);
//定义单张bmp图像
Graphics::TBitmap *tBmpSingleBitmapTemp;
//建立整张完整的bmp对象
this->tBmpTotalBmp = new Graphics::TBitmap;
this->tBmpTotalBmp->Width = this->usTotalImageWidth;
this->tBmpTotalBmp->Height = this->usTotalImageHeight;
this->tBmpTotalBmp->PixelFormat = pf16bit;
//this->tBmpTotalBmp->Assign(Form1->Image1->Picture->Bitmap);
//建立仅由变化了的图像组成的图像
Graphics::TBitmap *tBmpChangedTotalBitmap;
tBmpChangedTotalBitmap = new Graphics::TBitmap;
tBmpChangedTotalBitmap->Width = this->usTotalImageWidth;
tBmpChangedTotalBitmap->Height = this->usTotalImageHeight;
tBmpChangedTotalBitmap->PixelFormat = pf16bit;
while(usTotalHeightTemp<this->usTotalImageHeight)
{
while(usTotalWidthTemp<this->usTotalImageWidth)
{
//若整张图片还未填满但存储当前单张图片的向量列表中所有图片已经全部复制到整张图片上,说明此次接受完成后图片不全,需向发送方请求所有图片发送
if(i>=this->vRecvImageListNow.size())
{
this->SendRequestForTotalImage();
break;
}
//将单张png转为bmp
tBmpSingleBitmapTemp = new Graphics::TBitmap();
tBmpSingleBitmapTemp->Assign(this->vRecvImageListNow[i].tPngOfSinglePiece);
usSingleWidthTemp = tBmpSingleBitmapTemp->Width;
usSingleHeightTemp = tBmpSingleBitmapTemp->Height;
//将列表中的图片按顺序拷贝到整张大图上
BitBlt(this->tBmpTotalBmp->Canvas->Handle,usTotalWidthTemp,usTotalHeightTemp,usSingleWidthTemp,usSingleHeightTemp,tBmpSingleBitmapTemp->Canvas->Handle,0,0,SRCCOPY);
//将变化了的图片拷贝到另一张大图上
if(this->vRecvImageListNow[i].iIsThisImageChanged==1)
{
this->vRecvImageListNow[i].iIsThisImageChanged = 0;
BitBlt(tBmpChangedTotalBitmap->Canvas->Handle,usTotalWidthTemp,usTotalHeightTemp,usSingleWidthTemp,usSingleHeightTemp,tBmpSingleBitmapTemp->Canvas->Handle,0,0,SRCCOPY);
}
usTotalWidthTemp = usTotalWidthTemp+usSingleWidthTemp;
i++;
//tBmpSingleBitmapTemp->FreeImage();
//tBmpSingleBitmapTemp->ReleaseHandle();
delete tBmpSingleBitmapTemp;
}//end while usTotalWidthTemp<this
usTotalHeightTemp = usTotalHeightTemp+usSingleHeightTemp;
usTotalWidthTemp = 0;
} //end while usTotalHeightTemp<this
Form1->Image1->Picture->Bitmap->Assign(this->tBmpTotalBmp);
Form2->Image1->Picture->Bitmap->Assign(tBmpChangedTotalBitmap);
delete this->tBmpTotalBmp;
delete tBmpChangedTotalBitmap;
//this->iMergeSuccess = 1;
//this->iImageShowed = 0;
//this->tBmpTotalBmp->SaveToFile(ansiFileName);
}