Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Gráficos (https://www.clubdelphi.com/foros/forumdisplay.php?f=8)
-   -   no puedo insertar bmp a jpg desde codigo. (https://www.clubdelphi.com/foros/showthread.php?t=29850)

uper 02-02-2006 17:02:51

no puedo insertar bmp a jpg desde codigo.
 
saludos,

tengo que convertir bmp a jpg por codigo, he hecho un procedimiento para que lo haga estrayendo el id y buscarlo en la nueva tabla para ir insertando la imagen, de hecho la nueva tabla ya tiene datos solo falta agregar las imagenes.

Código PHP:

Var ID:double;
    
MyJPEG TJPEGImage;
    
MyBMP  TBitmap;
    
fn:string;
begin
  IBQuery1
.Open;
  
IBQuery1.First;
  
Destino.Open;
 try
  while 
not IBQuery1.Eof do
   
begin
   ID
:= IBQuery1ETIQUETA_ID.Value;
   
Destino.Locate('ETIQUETA_ID',ID, []);
    
fn:='C:\Logo.bmp';
    
TBlobField(IBQuery1.FieldByName('ETIQUETA_IMAGEN')).SaveToFile('C:\Logo.bmp');
    
MyBMP := TBitmap.Create;
    
with MyBMP do
    try
     
LoadFromFile(fn);
     
MyJPEG := TJPEGImage.Create;
     
with MyJPEG do
      
begin
       Assign
(MyBMP);
       
SaveToFile('C:\YourJpegHere.jpg');
       
Free;
       
end;
     
finally
      Free
;
    
end;
   
Destino.Edit;
   
DestinoETIQUETA_IMAGEN.LoadFromFile('C:\YourJpegHere.jpg');
   
Destino.Post;
   
IBQuery1.Next;
   
end;
    
trDestino.Commit;
   
finally
    IBQuery1
.close;
    
Destino.close;
    
ShowMessage('listo de procesar ....');
 
end;
end

Bueno si lo ejecuto me da el error de bitmap image is not valid. sin encambio si paso de bmp a bmp no hay problemas, pero es mejor convertir a jpg por el tamaño que ocupan.
gracias.

dec 02-02-2006 17:12:32

Hola,

Con el siguiente código no me va mal para convertir un "BITMAP" en un "JPEG". Adáptalo como te sea menester, a ver si te sive de algo.

Código Delphi [-]
uses
  Jpeg;

procedure BitmapToJpeg(const
  origen, destino: string);
var
  bitmap: TBitmap;
  jpeg: TJPEGImage;
begin
  bitmap := TBitmap.Create;
  jpeg := TJPEGImage.Create;
  try
    bitmap.LoadFromFile(origen);
    jpeg.Assign(bitmap);
    jpeg.SaveToFile(destino);
  finally
    jpeg.Free;
    bitmap.Free;
  end;
end;


La franja horaria es GMT +2. Ahora son las 19:28:08.

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