Home > Back-end >  Form the Image display picture flicker problems, not DoubleBuffered problem, is the problem that the
Form the Image display picture flicker problems, not DoubleBuffered problem, is the problem that the

Time:09-19

Made a desktop collection udp and legends, but when the receiver shows out some problems
Display process: I will receive pictures of flow joining together into a larger, more directly in the Form of the assign to generate a larger version of the image space, the effect is to display no problem, don't flicker (in the Form have defined the doublebuffered=true), but as long as the mouse moved to the window or in a window, the window will flash and the memory begins to abnormal increase, consider whether mousemove problem but concrete is not clear that looked great spirit to guide
As my synthetic images and show the code
Void CSCREENFORCEDSYNCLIENTCLASS: : TransformPngToBmpAndMergeIntoOneImage ()
{
int i=0;
Unsigned short usTotalWidthTemp=0;
Unsigned short usTotalHeightTemp=0;

Unsigned short usSingleWidthTemp=0;
Unsigned short usSingleHeightTemp=0;

This - & gt; IMergeSuccess=0;

//char cFilenameTemp [32]="\ \ test \ \ total BMP";
//AnsiString ansiFileName=AnsiString (cFilenameTemp);
//define a single BMP image
Graphics: : TBitmap * tBmpSingleBitmapTemp;

//set up the whole complete BMP object
This - & gt; TBmpTotalBmp=new Graphics: : TBitmap;
This - & gt; TBmpTotalBmp - & gt; Width=this - & gt; UsTotalImageWidth;
This - & gt; TBmpTotalBmp - & gt; Height=this - & gt; UsTotalImageHeight;
This - & gt; TBmpTotalBmp - & gt; PixelFormat=pf16bit;
//this - & gt; TBmpTotalBmp - & gt; The Assign (Form1 - & gt; Image1 - & gt; Picture - & gt; Bitmap);

//build consists only of the changed image image
Graphics: : TBitmap * tBmpChangedTotalBitmap;
TBmpChangedTotalBitmap=new Graphics: : TBitmap;
TBmpChangedTotalBitmap - & gt; Width=this - & gt; UsTotalImageWidth;
TBmpChangedTotalBitmap - & gt; Height=this - & gt; UsTotalImageHeight;
TBmpChangedTotalBitmap - & gt; PixelFormat=pf16bit;

While (usTotalHeightTemp{
While (usTotalWidthTemp{
//if the whole image incompletely filled but also store the current single image vector list all all images have been copied to the whole picture, showing the accept the picture is not complete, after the completion of all pictures sent to the sender to request
If (i>=this - & gt; VRecvImageListNow. The size ()
{
This - & gt; SendRequestForTotalImage ();
break;
}
//a single PNG to BMP
TBmpSingleBitmapTemp=new Graphics: : TBitmap ();
TBmpSingleBitmapTemp - & gt; The Assign (this - & gt; VRecvImageListNow [I] tPngOfSinglePiece);
UsSingleWidthTemp=tBmpSingleBitmapTemp - & gt; Width;
UsSingleHeightTemp=tBmpSingleBitmapTemp - & gt; Height;
//copy will be in the list of images in order to the whole picture
BitBlt (this - & gt; TBmpTotalBmp - & gt; Canvas - & gt; Handle, usTotalWidthTemp usTotalHeightTemp, usSingleWidthTemp usSingleHeightTemp, tBmpSingleBitmapTemp - & gt; Canvas - & gt; Handle, 0, 0, SRCCOPY);
//will change the photo copy to another on the big picture
If (this - & gt; VRecvImageListNow [I] iIsThisImageChanged==1)
{
This - & gt; VRecvImageListNow [I] iIsThisImageChanged=0;
BitBlt (tBmpChangedTotalBitmap - & gt; Canvas - & gt; Handle, usTotalWidthTemp usTotalHeightTemp, usSingleWidthTemp usSingleHeightTemp, tBmpSingleBitmapTemp - & gt; Canvas - & gt; Handle, 0, 0, SRCCOPY);
}
UsTotalWidthTemp=usTotalWidthTemp + usSingleWidthTemp;
i++;
//tBmpSingleBitmapTemp - & gt; FreeImage ();
//tBmpSingleBitmapTemp - & gt; ReleaseHandle ();
The delete tBmpSingleBitmapTemp;
}//end while usTotalWidthTempUsTotalHeightTemp=usTotalHeightTemp + usSingleHeightTemp;
UsTotalWidthTemp=0;
}//end while usTotalHeightTemp
Form1 - & gt; Image1 - & gt; Picture - & gt; Bitmap - & gt; The Assign (this - & gt; TBmpTotalBmp);
Form2 - & gt; Image1 - & gt; Picture - & gt; Bitmap - & gt; The Assign (tBmpChangedTotalBitmap);
Delete this - & gt; TBmpTotalBmp;
The delete tBmpChangedTotalBitmap;

//this - & gt; IMergeSuccess=1;
//this - & gt; IImageShowed=0;
//this - & gt; TBmpTotalBmp - & gt; SaveToFile (ansiFileName);
}

CodePudding user response:

The original poster can take a look at this is useless:
http://blog.163.com/tab_98/blog/static/1192409720170247251785/
Pay attention to the WM_ERASEBKGND

CodePudding user response:

This kind of situation is not necessary to use the Image element, you get the figure, directly onto a CD, and then put a Panel on the window or the Label of what, direct call BitBlt onto these controls the DC is ok, also need not open DoubleBuffer

DoubleBuffer this stuff, you don't know how to achieve it is internal, and Image element, you also don't know it is how to implement internal refresh

So this problem, you can change numerous for brief, do not use the Image control to display the Image, his painting on a Panel for

In my opinion the Image this control, is used to display a static Image, also is the hard disk of an existing Image file, only just use

If you need to repeat draw many times images in a widget, it was his bitblt better

From the code above you, change a few lines can realize what I said, there should be no blinking

CodePudding user response:

refer to the second floor draculamx response:
this kind of situation is not necessary to use the Image element, you get the figure, directly onto a CD, and then put a Panel on the window or the Label of what, direct call BitBlt onto these controls the DC is ok, also need not open DoubleBuffer

DoubleBuffer this stuff, you don't know how to achieve it is internal, and Image element, you also don't know it is how to implement internal refresh

So this problem, you can change numerous for brief, do not use the Image control to display the Image, his painting on a Panel for

In my opinion the Image this control, is used to display a static Image, also is the hard disk of an existing Image file, only just use

If you need to repeat draw many times images in a widget, it was his bitblt better

From the code above you, change a few lines can realize what I said, there should be no blinking
received synthetic bitmap with TRect I copied to the paint box, after won't be the flashing cursor the image part of the loss, but there will be a bed of color piece, and the memory would skyrocket, the cursor is not touch no problem, run the night also is very stable

CodePudding user response:

reference 1st floor ooolinux response:
the original poster can take a look at this there is no:
http://blog.163.com/tab_98/blog/static/1192409720170247251785/
Pay attention to the WM_ERASEBKGND
this I tried, the effect is not very obvious

CodePudding user response:

refer to the body of the 4th floor, I am your response:
Quote: refer to 1st floor ooolinux response:
have no the original poster can take a look at this:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related