Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros temas > Trucos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Los mejores trucos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 08-06-2006
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.269
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Crear Thumbnails (o mini imágenes)

Se plantea el problema de cómo generar lo que normalmente llamamos un "thumbnail" de una imagen que tenemos guardada en un fichero. Añadiendo un poco más de código podríamos generar todos los "thumbnail" de las imagenenes que hay en el directorio. Para ello se utiliza un componente TBitmap.

Vamos con el código:

Código Delphi [-]
var
   bmp: TBitmap;
   jpg: TJpegImage;
   scale: Double;
 begin
   // Abrir la imagen
   if opendialog1.execute then
   begin
     jpg := TJpegImage.Create;
     try
       // Cargar la imagen
       jpg.Loadfromfile(opendialog1.filename);
       if jpg.Height > jpg.Width then
         scale := 50 / jpg.Height
       else
         scale := 50 / jpg.Width;
       bmp := TBitmap.Create;
       try
         //Crear el thumbnail
         bmp.Width := Round(jpg.Width * scale);
         bmp.Height := Round(jpg.Height * scale);
         bmp.Canvas.StretchDraw(bmp.Canvas.Cliprect, jpg);
         // Dibujarlo en el control
         Self.Canvas.Draw(100, 10, bmp);
         // Convertirlo y guardarlo en disco.
         jpg.Assign(bmp);
         jpg.SaveToFile(ChangeFileext(opendialog1.filename, '_thumb.JPG'));
       finally
         bmp.free;
       end;
     finally
       jpg.free;
     end;
   end;

Se necesita un form con un control OpenDialog para abrir el fichero de imagen (JPG).
Y la Unit jpeg en el uses.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 19:59:27.


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
Copyright 1996-2007 Club Delphi