I have tried discard and it didn't work for me
Also, I am not loading images at startup so doing everything on ReDraw doesn't work.
The reason I don'y have everything drawing on the Redraw event is because when I load the test images, it is a onetime thing
Here is how I load/redraw my bitmaps (only pertinent code)
1) Declare my var's
var
Form1: TForm1;
TheImage1: TBGRABitmap;
TheImage2: TBGRABitmap;
theBMP: TBGRABitmap;
newBMP: TBGRABitmap;
startUp: Boolean = True;
2) I use Notebook for multiple pages.
When form loads a it displays "loading" button. (this will be where a user creates or loads a project)
When the "Load" button is clicked it loads three images (transparent PNG, and two character PNG's)
FYI... the transparent PNG is to eliminate the Black screen I get if I don't assign a bitmap when the control displays.
This also will be needed once I remove the two other test character PNGs.
i simulate the checkered background (and use the transparent PNG because I will be resizing the actual controls and if I turn off AutoSize, then the checkered look will remain correct.
Eventually a person will be loading more images as pseudo layers
procedure TForm1.Button1Click(Sender: TObject);
begin
nb.PageIndex:=1;
theBMP:= TBGRABitmap.Create('transpatentmask.png');
BGRAGraphicControl1.Bitmap.Assign(theBMP);
newBMP:= TBGRABitmap.Create('transpatentmask.png');
BGRAGraphicControl2.Bitmap.Assign(newBMP);
btnDesign.Enabled:=True;
mnuDesign.Enabled:=True;
TheImage1:= TBGRABitmap.Create('style_01.png');
TheImage2:= TBGRABitmap.Create('style_02.png');
theBMP.PutImage(0, 0, TheImage1, dmDrawWithTransparency );
theBMP.PutImage(0, 0, TheImage2, dmDrawWithTransparency ); //dmLinearBlend or dmDrawWithTransparency
BGRAGraphicControl1.Bitmap.Assign(theBMP);
BGRAGraphicControl1.Refresh;
end;
3) Here is my redraw prod
procedure TForm1.BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
begin
BGRAGraphicControl1.Bitmap.Assign(theBMP.Bitmap);
if assigned(TheImage1) then
begin
TheImage1.Draw(Canvas,0,0,false); //true makes it opaque - false makes transparent
end;
if assigned(TheImage2) then
begin
TheImage2.Draw(Canvas,0,0,false); //true makes it opaque - false makes transparent
end;
if assigned(theBMP) then
begin
theBMP.Draw(Canvas,0,0,false); //true makes it opaque - false makes transparent
end;
end;
procedure TForm1.BGRAGraphicControl2Redraw(Sender: TObject; Bitmap: TBGRABitmap
);
begin
BGRAGraphicControl2.Refresh;
//BGRAGraphicControl2Paint(Sender);
if assigned(newBMP) then
begin
newBMP.Draw(Canvas,0,0,false); //true makes it opaque - false makes transparen
end;
end;
4) Here is all my resize code
procedure TForm1.FormResize(Sender: TObject);
begin
if StartUp = False Then
if (nb.PageIndex = 1) Or (nb.PageIndex = 2) Then
begin
BGRAGraphicControl1.Bitmap.Assign(theBMP.Bitmap);
BGRAGraphicControl2.Bitmap.Assign(newBMP.Bitmap);
BGRAGraphicControl2Redraw(Sender,newBMP);
//BGRAGraphicControl2.DiscardBitmap;
end
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
TheImage1.Free;
TheImage2.Free;
theBMP.Free;
newBMP.Free;
end;
procedure TForm1.ScrollBox3Resize(Sender: TObject);
begin
if StartUp = False Then
if (nb.PageIndex = 1) Or (nb.PageIndex = 2) Then
begin
//BGRAGraphicControl1.Bitmap.Assign(theBMP.Bitmap);
//BGRAGraphicControl2.Bitmap.Assign(newBMP.Bitmap);
BGRAGraphicControl2Redraw(Sender,newBMP);
end
end;
procedure TForm1.ScrollBox3Paint(Sender: TObject);
begin
if StartUp = False Then
if (nb.PageIndex = 1) Or (nb.PageIndex = 2) Then
begin
BGRAGraphicControl1.Bitmap.Assign(theBMP.Bitmap);
BGRAGraphicControl2.Bitmap.Assign(newBMP.Bitmap);
BGRAGraphicControl2Redraw(Sender,newBMP);
end
end;
end.