Mastodon
Programmierung

Graphic: TImage flickering

i’ve found this in a Newsgroup:

—–8<-----snip-----8<----snap----- It is a Delphi 6 bug I have post the reason why Timgae is flickering to the newsgroup after examine the VCL source code of Delphi 5 and Delphi 6. In Delphi 6 the Timage always redraw the background except if stretch is true In Delphi 5 if the bitmap covers all the array of the Timage (bitmap greater or equal image size) then the background is not redrawn. You can change this in the Delphi 6 vlc source code its just one line . !!! Here is the listing of the TImage.PictureChanged in delphi 6 vcl Delphi 6 [code lang="delphi"]procedure TImage.PictureChanged(Sender: TObject); var G: TGraphic; begin if AutoSize and (Picture.Width > 0) and (Picture.Height > 0) then
SetBounds(Left, Top, Picture.Width, Picture.Height);
G := Picture.Graphic;
if G <> nil then
begin
if not ((G is TMetaFile) or (G is TIcon)) then
G.Transparent := FTransparent;
if (not G.Transparent) and Stretch and not Proportional then // change
here !!!!!
ControlStyle := ControlStyle + [csOpaque]
else // picture might not cover entire clientrect
ControlStyle := ControlStyle – [csOpaque];
if DoPaletteChange and FDrawing then Update;
end
else ControlStyle := ControlStyle – [csOpaque];
if not FDrawing then Invalidate;
end;
[/code]

The If-condition should be changed to :

[code lang=”delphi”] if (not G.Transparent) and (Stretch or ((G.Width >= Width) and (G.Height
>= Height))) and not Proportional then
ControlStyle := ControlStyle + [csOpaque]
[/code]

this adds to the condition that if the bitmap covers the Timage then the
ControlStyle is set to csOpaque and so the background is not redrawn every
time the Image change.
Good Luck

—–8<-----snip-----8<----snap-----

0 Kommentare zu “Graphic: TImage flickering

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.