Page 1 of 1

TPicshow : redrawWindow replaced by function

PostPosted: June 20th, 2011, 3:19 pm
by Tisseyre
{hi Kambiz
I am looking to speed up image display when i click on a drawGrid...
For example if i write a function witch return a bitmap instead of a procedure as you do with :
"RedrawWindow(WindowHandle, @DisplayRect, 0, RDW_INVALIDATE or RDW_UPDATENOW);"
I create a TPicture and i write : form1.image1.picture.Assign(Picshow1.GetImgProgress(value))
This is interesting, profitable or binding? #-o
}
function TCustomPicShow.GetImgProgress(Value: TMaxi) : TBitmap; //(TMaxi ~~ TProgress)
begin
result := nil;
if Busy and not display.empty then begin
EnterCriticalSection(CS);
try fProgress := Value;
UpdateDisplay;
result:= display;
finally LeaveCriticalSection(CS); end;
end;

//my bitmap is formatted but with a TPicture the result is faster of course
//thank you for your opinion

Re: TPicshow : redrawWindow replaced by function

PostPosted: June 21st, 2011, 4:53 pm
by Kambiz
TImage is a non-windowed control and uses its parent canvas to draw itself. It's lightweight, but you will encounter some problem regarding flickering and thread synchronization.

In other hand, assigning the new frame to an image may looks simpler and faster, but besides updating the image it does some additional tasks that are redundant in our case.