Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Trucos (https://www.clubdelphi.com/foros/forumdisplay.php?f=52)
-   -   Convertir de BMP a JPG y viceversa (https://www.clubdelphi.com/foros/showthread.php?t=80643)

dec 09-06-2007 19:26:09

Convertir de BMP a JPG y viceversa
 
Uses JPEG;

Convertir a JPG

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
  MyJPEG : TJPEGImage;
  MyBMP  : TBitmap;
begin
  MyBMP := TBitmap.Create;
  with MyBMP do
  try
    LoadFromFile('A.BMP');
    MyJPEG := TJPEGImage.Create;
    with MyJPEG do
        begin
            Assign(MyBMP);
            SaveToFile('A.JPEG');
            Free;
        end;
   finally
      Free;
   end;
end;

Convertir a BMP

Código Delphi [-]
procedure TForm1.Button2Click(Sender: TObject);
var
  MyJPEG : TJPEGImage;
  MyBMP  : TBitmap;
begin
  MyJPEG := TJPEGImage.Create;
  with MyJPEG do
     begin
         LoadFromFile('A.JPEG');
         MyBMP := TBitmap.Create;
         with MyBMP do
            begin
                Width := MyJPEG.Width;
                Height := MyJPEG.Height;
                Canvas.Draw(0,0,MyJPEG);
        SaveToFile('A.BMP');
                Free;
             end;
         Free;
     end;
end;


La franja horaria es GMT +2. Ahora son las 04:20:50.

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