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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Save Multiple Images to One Database Blob Field

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
DelphiLover Posted - Sep 13 2018 : 10:06:36
Hello,
I have a table as below
Table Name: Documents
Fields: DOCUMENT_ID, DOCUMENT_PHOTO

DOCUMENT_PHOTO should keep up to 100 Images

Is it possible to save multiple images to one database blob field?
I had looked into Demos but I can't find any example

What I do now


procedure TfrmDocumentInfo.FormCreate(Sender: TObject);
begin
  DM.PhotoIEDBMultiBitmab := TIEDBMultiBitmap.Create(DM.dsDocuments,
    'DOCUMENT_PHOTO', '');
  DM.PhotoIEDBMultiBitmab.FollowDBCursor := True;
  PhotoMView.SetExternalMBitmap(DM.PhotoIEDBMultiBitmab);
end;


procedure TfrmDocumentInfo.FormDestroy(Sender: TObject);
begin
  PhotoMView.SetExternalMBitmap(nil);
  FreeAndNil(DM.PhotoIEDBMultiBitmab);
end;


procedure TfrmDocumentInfo.PhotoMViewImageSelect(Sender: TObject; idx: Integer);
var
  MemStream: TMemoryStream;
begin
  if PhotoMView.SelectedImage = -1 then
    Exit;

  PhotoView.ClearAll();
  PhotoMView.CopyToIEBitmap(idx, PhotoView.IEBitmap);
  PhotoView.Update;
  PhotoView.Fit;

  // Get File Size
  MemStream := TMemoryStream.Create;
  PhotoView.IO.SaveToStreamJpeg(MemStream);
  lblSize.Caption := 'File Size: ' + ConvertBytes(MemStream.Size);
  FreeAndNil(MemStream);
end;


and another side problem With above code I get error "NULL BLOB"

and I don't know if it's the right way to do it. I hope to find help here
Thank you
6   L A T E S T    R E P L I E S    (Newest First)
DelphiLover Posted - Sep 14 2018 : 20:11:28
Hi

I'm still thinking to find new best table structure that will fit my needs, Thank you for your suggestion.

If I handle it with a try-except block the error still there but it will not appear
and the ImageEnMView will not be linked to IEDBMultiBitmab

So it's not the right solution, also I had used it before with other applications with same way I had never faced this exception
xequte Posted - Sep 14 2018 : 19:47:21
Hi

I don't know your requirements, so you might have your reasons, but if you have too many tables that only store blob info, you could just use a single table that stores blobs, the blob type (i.e. what table it is related too) and the index.

If you want don't want the Null Blob exception to surface, handle it with a try-except block.





Nigel
Xequte Software
www.imageen.com
DelphiLover Posted - Sep 14 2018 : 05:34:04
I get "NULL BLOB" error when I try to set external Bitmab

PhotoMView.SetExternalMBitmap(DM.PhotoIEDBMultiBitmab);


How can I avoid it?
DelphiLover Posted - Sep 14 2018 : 05:06:19
Hi
I wanted to use sub-tables but I Have many tables with blob field so using sub-tables will lead to have too many tables for blobs, some of blobs contains only 2-10 images,
However I will try your solution and If I have performance issues I will use sub-tables for blob more than 10 Images, Thank you very much.
xequte Posted - Sep 13 2018 : 22:23:19
A "Null Blobk" exception means the blob field it is reading at the current cursor position has a size of zero. So check your database.



Nigel
Xequte Software
www.imageen.com
xequte Posted - Sep 13 2018 : 22:21:32
Hi

Firstly, why store all the photos in the same blob? For performance reasons, you would be much better to have a sub-table that stored each image in its own blob (as reading a single blob to access one image out of a hundred would be taxing).

If you do have good reason to store them all the in same blob, then your options are:

- Save in a multi-frame format, such as TIFF (with the appropriate compression for the image type). Use a TIEMultiBitmap and save it to your blob stream:

https://www.imageen.com/help/TIEMultiBitmap.Write.html


- Save in an ImageEn format. You can use SaveSnapshot to output all images in a TIEMultiBitmap to a stream

https://www.imageen.com/help/TIEMultiBitmap.SaveSnapshot.html


- Build the stream yourself. You can use TIEDBBitmap.Write to output a series of images to a stream, and Read to load from the current stream position. Naturally you will some method to move to the correct position in the stream to load a specific image

https://www.imageen.com/help/TIEDBBitmap.Read.html

Nigel
Xequte Software
www.imageen.com