Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Conexión con bases de datos (https://www.clubdelphi.com/foros/forumdisplay.php?f=2)
-   -   imagenes en multiregistro (https://www.clubdelphi.com/foros/showthread.php?t=12577)

JoseQ 21-07-2004 10:41:47

imagenes en multiregistro
 
Buenas, tengo una tabla que entre otro campos contiene uno con la ruta de determinada imagen, estoy intentando mostrar en un multiregistro (DBctrlGrid) los campos de la tabla y la imagen que pone en el campo ruta, xo no me deja, me muestra siempre la 1ª foto, en todos los campos, alguna sugerencia de como se podria hacer?

ruina 21-07-2004 11:10:16

Con el evento OnPaintPanel, y dibujas la imagen en el canvas.

Código Delphi [-]
procedure TForm1.DBCtrlGrid1PaintPanel(DBCtrlGrid: TDBCtrlGrid; Index: Integer);
var
  Bitmap : TBitMap;
begin
  Bitmap := TBitmap.Create;
  try
    with Bitmap do begin
      LoadFromFile(ClientDataSet1ruta.AsString);
      DBCtrlGrid1.Canvas.Draw(1,1,BitMap);
    end;
  finally
    Bitmap.Free;
  end;
end;

te recomiendo hacer un findfile antes o poner un try except en el LoadFromFile, por si no existe la imagen.

JoseQ 21-07-2004 11:50:30

Parece una buena solucion, pero, las imagenes no caben, osea, son demasido grandes, y no me deja ajustarlas, e intentado pintar las imagenes sobre un timage en strecht i propotyional, xo nada de nada, tambien e intentado explotar la funcion scale del JPEG, xo un octavo no es suficiente, y ademas si introduzco imagenes mas pequeñas que las estoy probrando se veria demasiado pequeño

ruina 21-07-2004 12:28:53

mira a ver este otro, usando StrechDraw:


Código Delphi [-]
procedure TForm1.DBCtrlGrid1PaintPanel(DBCtrlGrid: TDBCtrlGrid; Index: Integer);
var
  Bitmap : TBitMap;
  r:TRect;
begin
  Bitmap := TBitmap.Create;
  try
    with Bitmap do begin
      r:=Rect(1,1,50,50);
      try
          LoadFromFile(ClientDataSet1ruta.AsString);
          if (Height>r.Bottom-r.Top) or (Width>r.Right-r.Left) then
               DBCtrlGrid1.Canvas.StretchDraw(r,BitMap)
          else DBCtrlGrid1.Canvas.Draw(r.Left,r.Top,BitMap)
      except
           DBCtrlGrid1.Canvas.Brush.Color:=clWhite;
           DBCtrlGrid1.Canvas.FillRect(r);
           DBCtrlGrid1.Canvas.Pen.Color:=clred;
           DBCtrlGrid1.Canvas.PenPos:=r.TopLeft;
           DBCtrlGrid1.Canvas.LineTo(r.Bottom,r.Right);
           DBCtrlGrid1.Canvas.PenPos:=Point(r.Top,r.Right);
           DBCtrlGrid1.Canvas.LineTo(r.Bottom,r.left);
      end;
    end;
  finally
    Bitmap.Free;
  end;
end;

JoseQ 21-07-2004 12:46:37

Perfecto !!!eres un crack, xD, Gracias, con el rect a 1,1,100,100 encaja a la perfeccion, GRacias de nuevo

ruina 21-07-2004 13:00:30

de nada hombre pa eso estamos ^_^


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

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