Bon, j'ai fait de progres, mais il me reste encore une erreur.
Par contre pour le problèmes des images j'ai trouvé une solution (non pas moi, trouvé sur le web). L'explication est simple lorsque Access ou SQL sauvegarde un blobimage, il concerve dans le champs le chemin d'accès qui a permis de générer le document.
Pour les explications en VO il suffit de ce rendre sur le site : http://delphi.about.com/od/database/l/aa030601d.htm
L'info est géniale et a résolue mon problème d'image.
Donc voici mon nouveau code (a optimiser pour peut etre la la FAQ (moi pas assez fort))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| procedure TForm1.BitBtn1Click(Sender: TObject);
var
ijpg:TJPEGImage;
ibmp:TBitMap;
stre:TADOBlobStream;
begin
data.sql1.open;
data.qatt.open;
data.qAtt.First;
while not data.qatt.eof do
begin
// La photo
try
stre:=tadoblobstream.Create(tblobfield(data.qatt.fieldbyname('at_photo')),bmRead);
stre.Seek(jpegstartsinblob(tblobfield(data.qatt.fieldbyname('at_photo'))),soFromBeginning);
ijpg:=TJPEGImage.Create;
ijpg.LoadFromStream(stre);
ijpg.SaveToFile('p'+floattostr(data.qAtt.fieldbyname('at_id').Value)+'.jpg');
image1.Picture.Bitmap.LoadFromStream(stre); // Marche pas domage
image1.Repaint;
finally
stre.Free;
ijpg.Free;
end;
data.qAtt.Next;
end;
// ijpg.Free;
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; |
La lecture ne pose plus de problème, mais j'ai une erreur au bout de la 16 eme image
EreadError : erreur de lecture de flux sur la ligne
ijpg.LoadFromStream(stre);
Je cherche un moyen pour ne pas gérer cette erreur et passé a l'enregistrement suivant.
Mais comment faire
Merci pour votre aide
Tornade
Partager