是否可以通过叠加在一起来将两个或更多相同大小的bmp图片合并为一个?与在Windows XP MS Paint中完成的方式相同:将一张图片粘贴到另一张图片中,次要颜色为透明.

在 XE8 中处理我的项目时,我需要保存和读取自定义项目文件,这些文件存储不同类型的变量和记录。最初,我解决这个问题的方法似乎有效,但在实际项目中却被证明是错误的。
我创建文件、存储“类别”记录的方法:
var
SavingStream: TFileStream;
i,j: Integer;
begin
SavingStream:=TFileStream.Create('SAVE.test', fmCreate or fmOpenWrite or fmShareDenyWrite);
SavingStream.Position:=0;
i:=Length(Categories); **// storing size of an array in a temp variable**
SavingStream.WriteBuffer(i,SizeOf(i)); **// for some reason i couldn't save it directly**
for i:=0 to Length(Categories)-1 do
begin
**{ String }**
SavingStream.WriteBuffer(Categories[i].Name,SizeOf(Categories[i].Name));
**{ Integer }**
SavingStream.WriteBuffer(Categories[i].ID,SizeOf(Categories[i].ID));
**{ Boolean }**
SavingStream.WriteBuffer(Categories[i].Default,SizeOf(Categories[i].Default))
**{ Same routine for dynamic array }**
j:=Length(Categories[i].ChildrenType);
SavingStream.WriteBuffer(j,SizeOf(j));
if j>=1 then for j:=0 to Length(Categories[i].ChildrenType)-1 do SavingStream.WriteBuffer(Categories[i].ChildrenType[j],SizeOf(Categories[i].ChildrenType[j]));
end;
end;
Run Code Online (Sandbox Code Playgroud)
然后阅读它:
var
SavingStream: TFileStream; …Run Code Online (Sandbox Code Playgroud) 我有一条记录,看起来像这样:
TCell = record
Marked: Boolean;
ToBeMarked: Boolean;
Image: TPngImage;
end;
var Cells: array of array of TCell
Run Code Online (Sandbox Code Playgroud)
Cells [n].图像在某个过程中创建,然后存储以供以后使用.每次调用该过程时,都会清除此数组.但是,在关闭程序时,我仍然有一个内存泄漏报告.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, pngimage, Vcl.StdCtrls;
type
TCell = record
Marked: Boolean;
ToBeMarked: Boolean;
Image: TPngImage;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure TestProcedure1;
procedure TestProcedure2(X,Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Cells: array of array of TCell;
RI_LengthX: …Run Code Online (Sandbox Code Playgroud)