Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Exportar imagenes de un contenedor (https://www.clubdelphi.com/foros/showthread.php?t=87873)

Jose Roman 11-03-2015 14:35:36

Exportar imagenes de un contenedor
 
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:
Código Delphi [-]
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:
Código Delphi [-]
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 :)


La franja horaria es GMT +2. Ahora son las 13:54:12.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi