Ver Mensaje Individual
  #12  
Antiguo 07-02-2014
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola cl2raul.

Si las imágenes guardadas en tu base de datos son de tipo Windows bitmap podes hacer:
Código Delphi [-]
...

procedure ResizeBitmap(Bitmap: TBitmap; Width, Height: Integer; Background: TColor);
var
  R: TRect;
  B: TBitmap;
  X, Y: Integer;
begin
  if assigned(Bitmap) then
  begin
    B:= TBitmap.Create;
    try
      if Bitmap.Width > Bitmap.Height then
      begin
        R.Right:= Width;
        R.Bottom:= ((Width * Bitmap.Height) div Bitmap.Width);
        X:= 0;
        Y:= (Height div 2) - (R.Bottom div 2);
      end
      else
      begin
        R.Right:= ((Height * Bitmap.Width) div Bitmap.Height);
        R.Bottom:= Height;
        X:= (Width div 2) - (R.Right div 2);
        Y:= 0;
      end;
      R.Left:= 0;
      R.Top:= 0;
      B.PixelFormat:= Bitmap.PixelFormat;
      B.Width:= Width;
      B.Height:= Height;
      B.Canvas.Brush.Color:= Background;
      B.Canvas.FillRect(B.Canvas.ClipRect);
      B.Canvas.StretchDraw(R, Bitmap);
      Bitmap.Width:= Width;
      Bitmap.Height:= Height;
      Bitmap.Canvas.Brush.Color:= Background;
      Bitmap.Canvas.FillRect(Bitmap.Canvas.ClipRect);
      Bitmap.Canvas.Draw(X, Y, B);
    finally
      B.Free;
    end;
  end;
end;

// Agregar imágenes a ImageList e incorporarlas al ComboBoxEx
procedure TForm1.FormCreate(Sender: TObject);
const
   IMG_X = 64;
   IMG_Y = 32;
var
  BM: TBitmap;
  cc: Integer;
begin
  ImageList1.Width := IMG_X;
  ImageList1.Height:= IMG_Y;
  cc:= 0;
  while not DataSet.Eof do
  begin
    BM:= TBitmap.Create;
    try
      BM.Assign(DataSet.FieldByName('CAMPO_IMAGEN')); 
      ResizeBitmap(BM, IMG_X, IMG_Y, clBtnFace);
      ImageList1.Add(BM, nil);
    finally
      BM.Free;
    end;
    ComboBoxEx1.ItemsEx.AddItem(DataSet.FieldByName('CAMPO_STRING').AsString,cc,0,0,0,nil);
    DataSet.Next;
    Inc(cc);
  end;
  ComboBoxEx1.Images:= ImageList1;
  ComboBoxEx1.ItemIndex := 0;
end;
Si guardaste las imágenes en un tamaño adecuado para ser mostradas en el combo, podes prescindir de la función ResizeBitmap.

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita