Author |
Topic |
|
adyble
United Kingdom
7 Posts |
Posted - Jun 04 2024 : 08:24:30
|
Hello I've looked everywhere but can;t find an example. Below is my code to load an image form a database. It works ok with the cxImage but I can;t out how to load it into the ImaqeENViewer Thanks, Andy
procedure TfmMidDBImages.LoadImage(); var BlobStream: TFDBlobStream;
begin
BlobStream := TFDBlobStream.create(qryImages.FieldByName('IMAGE') as TBlobField, bmRead); try cxImage1.Picture.LoadFromStream(BlobStream);
ImageEnView1.IO.LoadFromStream(BlobStream);
finally BlobStream.Free; end;
end;
|
|
xequte
38610 Posts |
Posted - Jun 04 2024 : 18:34:36
|
Hi
Please see the examples at:
http://www.imageen.com/help/TIEDBBitmap.html
For instance, to make a TImageEnView display the image at the current database position:
// Create DB Aware TImageEnView
procedure TMainForm.FormCreate(Sender: TObject);
begin
... Open a database table ...
fDBBitmap := TIEDBBitmap.create( DataSource1, 'Image', 'Name' );
ImageEnView1.SetExternalBitmap( fDBBitmap );
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
FreeAndNil( fDBBitmap );
end;
To load an image from the current database position on demand:
MyBMP := TIEDBBitmap.Create();
MyBMP.Read( MyTableImageBlob );
ImageEnView1.Assign( MyBmp );
MyBmp.Free;
Nigel Xequte Software www.imageen.com
|
|
|
adyble
United Kingdom
7 Posts |
Posted - Jun 05 2024 : 06:14:20
|
Thanks for the reply Nigel, That works ok for reading the data. Every time I scan a document using the demo or even compiled demo from you website, I get access violation on the fDBBitmap.Write(); line. The image shows ok, DBrecord remains in dsInsert, so the images is never written to the table. Andy |
|
|
adyble
United Kingdom
7 Posts |
Posted - Jun 05 2024 : 09:25:32
|
I'd be happy to write the data using insert into, but don;t know how to get at the image Andy |
|
|
xequte
38610 Posts |
Posted - Jun 05 2024 : 20:42:15
|
Hi
Are you sure the database is not located in a read-only path?
Nigel Xequte Software www.imageen.com
|
|
|
adyble
United Kingdom
7 Posts |
Posted - Jun 06 2024 : 03:10:21
|
hi, The db is fine. Its a remote Mysql db. We can write to it no problem. I can give you temporary credentials if you want to try it ? There are only images stored on this database. If you can tell me how to get the imnge into a stream I can write the data manually into the BLOB. |
|
|
xequte
38610 Posts |
Posted - Jun 06 2024 : 21:57:45
|
Hi
TIEBitmap.Read() and Write() both support stream overloads.
http://www.imageen.com/help/TIEBitmap.Write.html
e.g.
// Output current image to a TImage
bmp := TIEBitmap.Create;
Stream := TMemoryStream.Create;
bmp.Read( 'D:\image.webp' );
bmp.Write( Stream, ioBMP );
Stream.Position := 0;
Image1.Picture.LoadFromStream( Stream );
Stream.Free();
bmp.Free();
Nigel Xequte Software www.imageen.com
|
|
|
adyble
United Kingdom
7 Posts |
Posted - Jun 07 2024 : 10:01:04
|
Hi Nigel I that's using TIebitmap but we are using the TIEDBBitmap?
I'm trying - bmp.Read (fDBBitmap.???? );
I can;t work out how to get the bitmap from the TIEDBBitmap Andy |
|
|
adyble
United Kingdom
7 Posts |
Posted - Jun 07 2024 : 10:03:08
|
Or is it best not to use TIEDBBitmap at all and use TIEBitmap instead ? |
|
|
xequte
38610 Posts |
Posted - Jun 07 2024 : 16:15:57
|
Sorry, I'm not really understanding what you are trying to do here.
TIEDBBitmap inherits all the usual bitmap methods of TIEBitmap, so you can just access the TBitmap as follows:
fDBBitmap.AssignTo( myBMP );
Nigel Xequte Software www.imageen.com
|
|
|
|
Topic |
|