ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 loadFromStream/BLOB
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

adyble

United Kingdom
7 Posts

Posted - Jun 04 2024 :  08:24:30  Show Profile  Reply
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  Show Profile  Reply
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
Go to Top of Page

adyble

United Kingdom
7 Posts

Posted - Jun 05 2024 :  06:14:20  Show Profile  Reply
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
Go to Top of Page

adyble

United Kingdom
7 Posts

Posted - Jun 05 2024 :  09:25:32  Show Profile  Reply
I'd be happy to write the data using insert into, but don;t know how to get at the image
Andy
Go to Top of Page

xequte

38610 Posts

Posted - Jun 05 2024 :  20:42:15  Show Profile  Reply
Hi

Are you sure the database is not located in a read-only path?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

adyble

United Kingdom
7 Posts

Posted - Jun 06 2024 :  03:10:21  Show Profile  Reply
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.
Go to Top of Page

xequte

38610 Posts

Posted - Jun 06 2024 :  21:57:45  Show Profile  Reply
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
Go to Top of Page

adyble

United Kingdom
7 Posts

Posted - Jun 07 2024 :  10:01:04  Show Profile  Reply
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
Go to Top of Page

adyble

United Kingdom
7 Posts

Posted - Jun 07 2024 :  10:03:08  Show Profile  Reply
Or is it best not to use TIEDBBitmap at all and use TIEBitmap instead ?
Go to Top of Page

xequte

38610 Posts

Posted - Jun 07 2024 :  16:15:57  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: