I have a component that pumps out 29 bitmaps a second. I want to use DelphiX to display them stretched to the size of the display. (Note: These bitmaps are not known until runtime)
I originally tried to load each bitmap into the same slot in a DXImageList but that lead to many memory leaks and errors.
Now I am trying to use a single TDirectDrawSurface as a buffer that holds the image and it is then drawn to the screen(DXDraw) on a DXTimer event. But the issue I am having is I cannot get another image into it after the initial image.
Here is the initialization (Test) code
Code:
Surf : TDirectDrawSurface.
procedure TForm1.DisplayInitialize(Sender: TObject);
var bmp : TBitmap;
begin
bmp := TBitmap.Create;
bmp.LoadFromFile('D:\Images\Niagra.bmp');
Surf := TDirectDrawSurface.Create(Display.DDraw);
Surf.LoadFromGraphic(bmp);
Surf.Restore;
bmp.Destroy;
end;
And in the timer event where all the drawing is being done it draws as expected. Next is some test code I run to see if I can replace the original image.
Code:
procedure TForm1.Button1Click(Sender: TObject);
var bmp : TBitmap;
begin
bmp := TBitmap.Create;
bmp.LoadFromFile('D:\Images\Pillar.bmp');
Surf.LoadFromGraphic(bmp);
Surf.Restore;
bmp.Destroy;
end;
But the image displayed does not change. I have also tried
Code:
procedure TForm1.Button2Click(Sender: TObject);
var bmp : TBitmap;
begin
bmp := TBitmap.Create;
bmp.LoadFromFile('D:\Images\Pillar.bmp');
Surf.Canvas.Draw(0,0,bmp);
Surf.Canvas.Release;
Surf.Restore;
bmp.Destroy;
end;
What is the correct way to update the image on the surface?
Bookmarks