Gracias
Gracias Neftali veo que la solución estaba ante mis narices, para la próxima garantizo buscar bien antes de preguntar. Sin embargo ya he hecho todos los pasos y me da un error en tiempo de ejecución que no logro depurar por ningún lado. Este es el error: Stream read error. La aplicación no explota ni nada de eso tan solo muestra este error y ya. Echale un vistazo al código como me quedo, casi igual que el ejemplo que me dices...
....................
const
JPEGstarts = 'FFD8';
BMPstarts = '424D'; //BM
var
Form1: TForm1;
implementation
uses jpeg;
{$R *.dfm}
procedure TForm1.btnShowImageClick(Sender: TObject);
var
bS : TADOBlobStream;
Pic : TJpegImage;
begin
bS := TADOBlobStream.Create(AdoTable1Picture, bmRead);
try
bS.Seek(JpegStartsInBlob(AdoTable1Picture),soFromBeginning);
Pic:=TJpegImage.Create;
try
Pic.LoadFromStream(bS);
ADOImage.Picture.Graphic:=Pic;
finally
Pic.Free;
end;
finally
bS.Free
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ADOTable1Picture.SaveToFile('BlobImage.dat');
end;
function TForm1.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;
end.
__________________
El único hombre que no se equivoca es el que nunca hace nada.
|