Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Modificar imagenes (https://www.clubdelphi.com/foros/showthread.php?t=94219)

trex2000 07-10-2019 19:55:38

Modificar imagenes
 
Saludos a todos.

Me podrian ayudar para poder modificar imágenes desde una aplicación que ya tengo en delphi y se le desea agregar la opción de recortar el tamaño de la imagen original y poder renombrarla, alguien me podria ayudar y decirme como poder hacerlo?

Espero haberme explicado bien.

De antemano muchas gracias.

aposi 07-10-2019 20:21:46

Con este codigo cargas la imagen y la guardas con el nombre que quieras
Código Delphi [-]
Jpg:= TJPEGImage.Create;
               try                  
                    Jpg.LoadFromFile(Ruta_origen+nombre +'.jpg');
                    proporcional(Jpg,500,500);                   
                    Jpg.SaveToFile(Ruta_destino+nombre +'.jpg');                   
               finally
                Jpg.Free;
               end;


la funcion proporcional la ajusta al tamaño que quieras


Código Delphi [-]
procedure Proporcional(Imagen: TGraphic; Ancho, Alto: Integer);
var
  Bitmap: graphics.TBitmap;
begin
  Bitmap:= graphics.TBitmap.Create;
  try
    if Imagen.Width < ancho then ancho := Imagen.Width;
    if Imagen.Height < alto then alto := Imagen.Height;
    if  (Ancho/Imagen.Width) < (Alto/Imagen.Height) then
      Alto:= Trunc((Ancho*Imagen.Height)/Imagen.Width)
    else
      Ancho:= Trunc((Imagen.Width*Alto)/Imagen.Height);
    Bitmap.Width:= Ancho;
    Bitmap.Height:= Alto;
    Bitmap.Canvas.StretchDraw(Bitmap.Canvas.ClipRect,Imagen);
    Imagen.Assign(Bitmap);
  finally
    Bitmap.Free;
  end;

end;

trex2000 08-10-2019 06:57:50

Gracias por tu respuesta.


La franja horaria es GMT +2. Ahora son las 23:44:59.

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