Hola:
Para mostrar la foto hago esto:
Pongo un TDataSource enlazado al DataSet correspondiente y un TImage.
En el evento OnDateChange del DataSource pongo esto:
Código Delphi
[-]
procedure TFPalabras.DSFotoPalNueDataChange(Sender: TObject; Field: TField);
var
m: TStream;
begin
if DM.IBDSPalNueFOTO.IsNull then
ImgFotoPalNue.Picture := nil
else
begin
if DM.IBDSPalNueFORMATOFOTO.AsString = 'BMP' then
ImgFotoPalNue.Picture.Graphic:= TBitmap.Create
else if DM.IBDSPalNueFORMATOFOTO.AsString = 'JPG' then
ImgFotoPalNue.Picture.Graphic:= TJpegImage.Create
else
Exit;
m:= DM.IBDSPalNue.CreateBlobStream(DM.IBDSPalNueFOTO, bmRead);
ImgFotoPalNue.Picture.Graphic.LoadFromStream(m);
m.Free;
end;
end;
Para borrar la foto (del TImage y del campo Blob) pongo esto:
Código Delphi
[-]
procedure TFPalabras.TBBorraFotoClick(Sender: TObject);
begin
if Application.MessageBox('¿Seguro que desea borrar esta foto?','Borrar',mb_OkCancel+mb_IconQuestion)= IdOk then
begin
ImgFotoPalNue.Picture.Assign(nil);
if (DM.IBDSPalNue.State <> dsEdit) and (DM.IBDSPalNue.State <> dsInsert) then
DM.IBDSPalNue.Edit;
DM.IBDSPalNueFOTO.Assign(nil);
DM.IBDSPalNue.Post;
end;
end;
Como te dije tengo fotos .bmp y .jpg y por eso tengo un campo donde guardo el formato.
Para .jpg hay que añadir en el uses la unit JPeg
Puedes mirar aquí:
http://www.rinconcitodelphi.com/comp...omponentes.htm
De título: Imágenes en campos Blob de Interbase y componentes IBX
Suerte. Tomás.