Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Gráficos (https://www.clubdelphi.com/foros/forumdisplay.php?f=8)
-   -   Crear un thumbnail rapido (https://www.clubdelphi.com/foros/showthread.php?t=64459)

Rako 02-04-2009 15:36:03

Crear un thumbnail rapido
 
Hola, no tengo mucha idea de como hacer esto ni como funciona, pero el caso es que me peta y no se muy bien porque. Este codigo haria un thumbnail de una imagen grande, dejando el valor mayor de anchura/altura a 70, y el otro a su correspondiente escala:

Código:

try
    ImageEnIO1.LoadFromFileJpeg(filename);
    //MejoraFotoProc.AttachedBitmap:=ImageEnIO1.AttachedBitmap;
    MejoraFotoProc.AttachedIEBitmap:=ImageEnIO1.AttachedIEBitmap;
    MejoraFotoProc.AttachedBitmap:=ImageEnIO1.AttachedBitmap;
    //if ImageEnIO1.AttachedBitmap.Height > ImageEnIO1.AttachedBitmap.Width then begin
    //if ImageEnIO1.Bitmap.Height > ImageEnIO1.Bitmap.Width then begin
    if MejoraFotoProc.AttachedBitmap.Height > MejoraFotoProc.AttachedBitmap.Width then begin
      //scale := 70 / jpg.Height;
      scale := 70 / ImageEnIO1.Bitmap.Height;
    end else begin
      scale := 70 / ImageEnIO1.Bitmap.Width;
    end;
    w:=Round(ImageEnIO1.Bitmap.Width * scale);
    h:=Round(ImageEnIO1.Bitmap.Height * scale);
    try
        MejoraFotoProc.Resample(w,h,rfNone);
        ImageEnIO1.IEBitmap:=MejoraFotoProc.AttachedIEBitmap;
        ImageEnIO1.SaveToFileJpeg('tmp_thumb.JPG');
    finally
    end;
  except
    MessageDlg('Error loading picture', mtWarning, [mbOK], 0);
  end;

Me peta cuando simplemente intenta acceder a las variables de width o heigth en el if del imageenio o del imageenproc para saber como escalarlo.

Me imagino que estara mal cargado los imageenio e imageenproc. Pretendia que imageenIO cargara un .jpg del discoduro, y le pasara la imagen al imageenproc.

muchas gracias por adelantado

cHackAll 03-04-2009 02:08:42

:rolleyes:


La franja horaria es GMT +2. Ahora son las 09:27:17.

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