Loading Bitmaps from Database
Posted: Fri 10 Nov 2006 12:22
Hello,
I have following problem. I am trying to convert an application which currently using BDE to SDAC 3.80 components (demo version). If I get this running we will buy them.
I have further used a BDE TQuery to retrieve the Picture.
This code worked no longer, I got messages like unsupported type conversions. Original Message is in German "Ungültige Typumwandlung".
I modified the code to following
This code does not supply the message, as the code above, but sadly the stream seems to be empty and no picture is loaded from the database.
I use an SQL Server 2000 and the fieldtype in the database is of type image.
If someone help me with a hint, it would be very good for me.
I have following problem. I am trying to convert an application which currently using BDE to SDAC 3.80 components (demo version). If I get this running we will buy them.
I have further used a BDE TQuery to retrieve the Picture.
Code: Select all
lBlobStream := TBlobStream.Create(TBlobField(FieldByName('FLAG')),
bmREAD);
try
lBitMap := Graphics.TBitMap.Create;
lBitMap .PixelFormat := pf4bit;
lBitMap .TransparentMode := tmAuto;
lBitMap .Transparent := true;
lBitmap.LoadFromStream(lBlobStream);
finally
lBlobStream.Free;
end;
I modified the code to following
Code: Select all
lStream := TMemoryStream.Create;
try
TBlob(FieldByName('FLAG')).SaveToStream(lStream);
lBitMap := Graphics.TBitMap.Create;
lBitMap .PixelFormat := pf4bit;
lBitMap .TransparentMode := tmAuto;
lBitMap .Transparent := true;
lBitmap.LoadFromStream(lStream);
finally
lStream.Free;
end;
I use an SQL Server 2000 and the fieldtype in the database is of type image.
If someone help me with a hint, it would be very good for me.