Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Gráficos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 18-01-2007
Avatar de Doraemon
Doraemon Doraemon is offline
Registrado
 
Registrado: abr 2005
Ubicación: Ñemby Paraguay
Posts: 5
Poder: 0
Doraemon Va por buen camino
Question Mostrar una imagen JPG

Hola a todos,... estuve buscando en el foro y encontre la manera de mostrar en un TImage una imagen almacenada en un campo de access tipo OLE... creo haber buscado lo suficiente como para pedir a alguien me pueda decir porque me sale el error "Invalid class typecast" en la linea donde hago el "SaveToStream"...¿¿???

Aqui esta el codigo:

Código Delphi [-]
procedure TfraDefinicionNotificadores.MostrarFoto;
var   MS: TMemoryStream;   IB: TJPEGImage;   sSQL: String;
begin   with ADQFotoX do     begin       SQL.Clear;       sSQL:= 'SELECT Foto FROM Notificadores WHERE CodigoNotificadores=' + ADONotificadoresCodigoNotificadores.AsString;
      SQL.Add(sSQL);
      Open;
      (FieldByName('Foto') as TGraphicField).SaveToStream(MS);
    end;
  IB.LoadFromStream(MS);
  imgFoto.Picture.Assign(IB);
  MS.Free;
  IB.Free;
end;

Desde ya muchas gracias... espero haber dicho todo como para recibir alguna ayudita

Última edición por dec fecha: 18-01-2007 a las 00:17:05.
Responder Con Cita
  #2  
Antiguo 19-01-2007
Avatar de Doraemon
Doraemon Doraemon is offline
Registrado
 
Registrado: abr 2005
Ubicación: Ñemby Paraguay
Posts: 5
Poder: 0
Doraemon Va por buen camino
Talking Ya encontre la solucion...

Estuve buscando mas ejemplos y pude solucionar mi problema...

Acá pongo el codigo que quedo finalmente:

Código Delphi [-]procedure TfraDefinicionNotificadores.MostrarFoto; var bS : TADOBlobStream; Pic : TJpegImage; begin bS := TADOBlobStream.Create(ADONotificadoresFoto, bmRead); try bS.Seek(JpegStartsInBlob(ADONotificadoresFoto), soFromBeginning); Pic:=TJpegImage.Create; try if Length(ADONotificadoresFoto.AsString)>0 then begin Pic.LoadFromStream(bS); imgFoto.Picture.Graphic:=Pic; end else imgFoto.Picture.Assign(nil); finally Pic.Free; end; finally bS.Free end; end;


Código Delphi [-]function TfraDefinicionNotificadores.JpegStartsInBlob( PicField: TBlobField): integer; var bS : TADOBlobStream; buffer : Word; hx : string; begin Result := -1; bS := TADOBlobStream.Create(PicField, bmRead); try while (Result = -1) and (bS.Position + 1 < bS.Size) do begin bS.ReadBuffer(buffer, 1); hx:=IntToHex(buffer, 2); if hx = 'FF' then begin bS.ReadBuffer(buffer, 1); hx:=IntToHex(buffer, 2); if hx = 'D8' then Result := bS.Position - 2 else if hx = 'FF' then bS.Position := bS.Position-1; end; //if end; //while finally bS.Free end; //try end;
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

Temas Similares
Tema Autor Foro Respuestas Último mensaje
mostrar una imagen en un DBGrid adebonis Varios 12 25-09-2012 13:33:00
Mostrar Imagen remota ( desde internet ) MRSAM Internet 4 30-11-2006 22:28:57
Mostrar imagen de un campo binario kiketijuana SQL 0 28-06-2006 01:20:33
como mostrar una imagen a base de un componente Nelly Varios 7 01-12-2005 15:50:43
Mostrar mi cursor en una imagen franc28 Varios 4 25-04-2005 19:17:39


La franja horaria es GMT +2. Ahora son las 21:23:48.


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