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
 Copy Image from one ImageEnDBView to another

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
Patrick Quinn Posted - May 23 2012 : 15:11:26
Hi Nigel and Fabrizio

I am using two ImageEnDBView controls, one to store a full size image in one field in a table, the other to store a thumbnail (to later populate an ImageEnMview).

I am trying to copy the image from the first to the second (and after that resize it) but cannot make it copy and save in the table.

I load an image into the first, this saves it in the database without problems.
I copy it's image to the other with:

ImageEnDBView2.IEBitmap.Assign(ImageEnDBView1.IEBitmap);

You can see the image in the second DBView, but it does not store it in the table.

How to you assign an image and make it store in the table?

I am doing something stupid, but what?

ImageEn version 4.1.0

regards

Patrick
7   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Aug 27 2014 : 16:37:05

Note: Generic DB read/write functions are now available in iexHelperFunctions.pas (see your ImageEn source folder).

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
1995steve Posted - Aug 19 2014 : 09:47:17
If you are using an ADODataSet Instead of a TTable this will save a JPG to an image field

TBlobField( TblImg.FieldByName( '<fieldName>' )).LoadFromFile(<FileName>);

Donald S. Bossen
Patrick Quinn Posted - May 28 2012 : 15:33:49
In the past (before I started using ImageEn) I have used the Delphi TImage JPEG scale to make thumbnails. I prefer this way, though. It is really quick (even when tested on a netbook with a slow processor).

Also, some images I'm storing are scans of text, so I use png rather than JPEG, to avoid the artefacts that mess text up.

Also, most computers now have massive hard drives so file size is not much of an issue.



regards

Patrick
xequte Posted - May 26 2012 : 23:10:42
Hi Patrick

Another good way to speed up JPEG loading (if you are not displaying it full size) is to use TIOParams.JPEG_Scale:

http://www.imageen.com/help/TIOParams.JPEG_Scale.html

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Patrick Quinn Posted - May 26 2012 : 05:11:23
Hi Nigel, thanks for pointing me in the right direction.

I've got that code all working, it saves a full sized image as a blob, resize/resamples to thumbnail size (150x150 pixels) then saves that as a blob in another field.

Loading a TImageENView from small thumbnails rather than full sized images speeds up loading considerably.

regards

Patrick
Patrick Quinn Posted - May 24 2012 : 09:34:11
Thanks, Nigel.

I'll try this:

1) Create an IEBitmap, attach it to an ImageEnIO
2) Load an image via the ImageEnIO
3) Assign this image to the blob in the table's main 'image' field using the ImageEnIO.
4) Resize the IEBitmap with IEBitmap.Resize to (say) 150x150 for use as thumbnails
5) Assign this to the blob in the table's 'Thumb' field using the ImageEnIO.

I think this should do what I want.

I'm not using the BDE, but Absolute Database instead (no installation program needed for finished .exe).

http://www.componentace.com/bde_replacement_database_delphi_absolute_database.htm

It seems to work fine with ImageEn.
It works with a standard Delphi DataSource and most Delphi data controls will work with it. (some very slight differences, it uses a TABSBlobStream instead of TBlobStream for instance)

regards

Patrick
xequte Posted - May 23 2012 : 19:02:09
Hi Patrick

You do not need to use a visual control (TImageEnDBView) if all you want to is assign an image into a blob. You can do this in code using a memory stream:


// Inserts the specified bitmap into the database at the current cursor position
function TIEFunctions.InsertBlob_Bitmap(var ABitmap: TBitmap;
                                        TheTable: TTable; AField: TBlobField; 
                                        sFileExt: string): boolean;
begin
  try
    TempImageEnIO.Params.SetDefaultParams;
    TempImageEnIO.attachedbitmap := ABitmap;
    Result := InsertBlob_ImageEnIO(TempImageEnIO, TheTable, AField, sFileExt); 
  finally
    TempImageEnIO.attachedbitmap := nil;
  end;
end;

// Inserts the bitmap of the specified ImageEnIO into the database at the current cursor position
function TIEFunctions.InsertBlob_ImageEnIO(var AnImageEnIO: TImageEnIO; 
                                           TheTable: TTable; AField: TBlobField; 
                                           sFileExt: string): boolean;
var
  MemStream: TMemoryStream;
  BlobStream: TBlobStream;
  SaveFileType: TIOFileType;
begin
  Result := true;

  SaveFileType := IEExtToFileFormat(sFileExt);

  if SaveFileType = iounknown then
  begin
    Result := False;
    exit;
  end;

  try
    MemStream := TMemoryStream.create;
    try
      AnImageEnIO.SaveToStream(MemStream, SaveFileType);
      MemStream.position := 0;

      TheTable.Edit;
      BlobStream := TBlobStream.create(AField, bmwrite);
      try
        MemStream.SaveToStream(BlobStream); 
      finally
        BlobStream.Free;
        TheTable.Post;
      end;

    finally
      MemStream.free;
    end;
  except
    Result := false;
  end;
end;


Note: Untested with standard DB controls

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com