PDA

Ver la Versión Completa : Exportar imagenes de un contenedor


Jose Roman
11-03-2015, 14:35:36
Cordial saludo,

Tengo un TbsPngImageList de la clase TCustomImageList (componente de Almediaev) el cual tiene un varias imagenes PNG exportar todas las imagenes contenidas, alguien sabe como realizar esto?

ecfisa
11-03-2015, 21:34:20
Hola Jose Roman.

No conozco el componente que mencionas, pero si desciende de TCustomImageList como comentas, tendría que funcionarte de este modo:

uses PNGImage;

procedure ExportPngImages(CusImgLst: TCustomImageList; Path: string);
var
BMP: TBitmap;
PNG: TPNGObject;
i: Integer;
begin
Path:= IncludeTrailingPathDelimiter(Path);
for i:= 0 to CusImgLst.Count - 1 do
begin
BMP:= TBitmap.Create;
PNG:= TPNGObject.Create;
try
CusImgLst.GetBitmap(i, BMP);
PNG.Assign(BMP);
PNG.SaveToFile(Format('%sPNGImage%d.PNG', [Path, i+1]));
finally
BMP.Free;
PNG.Free;
end;
end;
end;


Ejemplo de uso:

procedure TForm1.Button1Click(Sender: TObject);
begin
ExportPngImages(ImageList1, 'C:\tmp\iconos');
end;

En este caso realicé las pruebas con un componente TImageList (otro descendiente de TCustomImageList) y funciona correctamente.

Saludos :)