Good Morning!
I use this to store jpg's in an Access db.
You can find the app that uses this aon my web site. Look for Michelle's Bears
at www.GreatDayDan.com.
{ This code is from:
Article: Pictures inside a database
http://delphi.about.com/library/weekly/aa030601a.htm
Chapter three of the free
Delphi Database Course for beginners.
Displaying images (BMP, JPEG, ...) inside
an Access database with ADO and Delphi.}
function 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 hx = 'FF'
end;//while (Result = -1) and (bS.Position + 1 < bS.Size)
finally
bS.Free
end; //try...finally
end; // function JpegStartsInBlob
procedure LoadJpg(ADOField: TBlobField; var ImageComp: TImage);
var
bS : TADOBlobStream;
Pic : TJpegImage;
begin
bS := TADOBlobStream.Create(ADOField, bmRead);
try
bS.Seek(JpegStartsInBlob(ADOField), soFromBeginning);
Pic := TJpegImage.Create;
try
Pic.LoadFromStream(bS);
if (Pic.Width < ImageComp.Width) and
(Pic.Height < ImageComp.Height) then
ImageComp.Stretch := False
else
ImageComp.Stretch := True;
ImageComp.Picture.Graphic:=Pic;
finally
Pic.Free;
end; //try...finally
finally
bS.Free
end; //try...finally
end; // procedure LoadJpg
HTH...Dan'l
____________________________________
Every day with Jesus is a Great! day
and He loves YOU!
----- Original Message ----
From: siva subramanian <[email protected]>
To: [email protected]
Sent: Wednesday, August 19, 2009 9:47:18 AM
Subject: [delphi-en] Reg How To Insert Image File Into MySQL Blob Filed In
Delphi 7 Coding
Dear All,
Please advice me
How To Insert Image File Into MySQL Blob Filed In Delphi 7 Coding.
I am saving image into PostgreSQL bytea field through this coding.Its work
fine
tablenamne.FieldByName('byteafiled') .LoadFromFile('c:\temp.jpg');
When i use this coding MySQL blob means.I am getting Error
Einvalid Graphic With Message Bitmap Image Is Invalid like this.
For database connection and query i am using Zeos Access Component.Please
help me.How to solve this problem.Advance thanks to all.
Thanks & Regards
Siva
Yahoo! recommends that you upgrade to the new and safer Internet Explorer
8. http://downloads.yahoo.com/in/internetexplorer/
[Non-text portions of this message have been removed]
------------------------------------
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [email protected]! Groups Links