Ver Mensaje Individual
  #10  
Antiguo 08-12-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola look.

Otra vueltita de tuerca...
Código Delphi [-]
procedure ConcatPngHrz(const PngNames: array of TFileName; const PngPath, FullTargetName: string);
var
  bmp: TBitmap;
  png: array of TPNGObject;
  i,hgt,wdt: Integer;
begin
  hgt := 0;
  wdt := 0;
  SetLength(png, Length(PngNames));
  for i := Low(PngNames) to High(PngNames) do
  begin
    png[i] := TPNGObject.Create;
    png[i].LoadFromFile(IncludeTrailingPathDelimiter(PngPath) + PngNames[i]);
    if png[i].Height > hgt then hgt := png[i].Height;
    Inc(wdt, png[i].Width);
  end;
  bmp := TBitmap.Create;
  bmp.PixelFormat:= pf32bit;
  bmp.Width  := wdt;
  bmp.Height := hgt;
  bmp.Canvas.Brush.Color := clWhite;
  bmp.Canvas.FillRect(Rect(0, 0, wdt, hgt));
  bmp.TransparentColor := clWhite;
  bmp.Transparent := True;
  wdt := 0;
  for i := Low(PngNames) to High(PngNames) do
  begin
    png[i].Draw(bmp.Canvas, Rect(wdt, 0, wdt +  png[i].Width, png[i].Height));
    Inc(wdt, png[i].Width);
  end;
  with png[Low(PngNames)] do
  begin
    Assign(bmp);
    SaveToFile(FullTargetName);
  end;
  for i := Low(PngNames) to High(PngNames) do png[i].Free;
  bmp.Free;
end;
De este modo eliminamos la limitante a tres archivos orígen, y también podemos usar diferentes altos ya que la imágen destino se ajusta a la de mayor tamaño.

Por ejemplo, una llamada podría ser:
Código Delphi [-]
  ConcatPngHrz(['A.PNG', 'B.PNG', 'C.PNG' ,'D.PNG', 'E.PNG', 'F.PNG', { (...) }], 'C:\IMAGENES', 'C:\IMAGENES\CONCAT.PNG');
Si además te interesa mostrarla en un TImage dentro del código, convendría hacer al procedimiento ConcatPngHrz método de un form (o agregar un parámetro de tipo TForm).

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita