How to create an independent copy of Delphi TBitmap?

I have an application that prints text and images on pages on a printer. On the footer, we display an image that is cached by loading it once and saving it to TBitmap. In the printing procedure, he creates a new TBitmap, and then calls a function that assigns a cached bitmap. He then finishes calling Canvas.StretchDraw on this bitmap.

Function GetFooterGraphic(Var xBitmap : TBitmap) : boolean;
begin
  // load cache here
  if assigned(g_xFooterBitmap) then
  begin
    xBitmap.Assign(g_xFooterBitmap);
    result := true;
  end;
end

// Get bitmap, then:
xCanvas.StretchDraw(xDrawRect, xBitmap);

The problem is that the bitmap does not work after a certain number of pages. I can only imagine that this is a problem with the driver, but this happens on most printers at different times. I can fix this by reloading the bitmap every time, but I prefer to keep the cache.

VCL, xBitmap.Assign . , . :
TBitmap ?

TBitmap () , , , , .

Delphi 2007, .

+3
2

, , , , FreeImage Assign .

+4

SaveToStream LoadToStream, , TMemoryStream.

0

Source: https://habr.com/ru/post/1755314/


All Articles