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
 Best method to add image to ImageEnMView
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

chambers120

USA
4 Posts

Posted - Apr 17 2015 :  07:00:32  Show Profile  Reply
I'm acquiring an image from a scanner and displaying in the
ImageEnView component. I also want to add the acquired image to the ImageEnMView component.

This code works but...
//Add Acquire Image to TImageEnMView
//Probably better method of moving image to ImageEnMView?
if cbAcqImagEnM.Checked=True then //Checkbox to allow adding image
begin
BMP:=TBitmap.Create;
BMP.Assign(ImageEnView1.Bitmap);
S:=GetTmpInternetDir; //Temporary internet file directory Win7
BMP.SaveToFile(S+'!Tmp.bmp');
ImageEnMView1.MIO.LoadFromFile(S+'!Tmp.bmp');
BMP.Free;
DeleteFile(S+'!Tmp.bmp');
end;

What is a better method to accomplish this?
Thanks as always,
Charlie Chambers

w2m

USA
1990 Posts

Posted - Apr 17 2015 :  08:18:43  Show Profile  Reply
There are a number of ways to do this. Here is one way:
Copy TIEBitmap from TImageEnView To TImageEnMView

  { AppendImage appends a new image at last position
  in the list and returns the new image position (SelectedImage). }
  ImageEnMView1.AppendImage;
  if ImageEnMView1.SelectedImage <> -1 then
  begin
    { Set the ImageEnView image to the ImageEnMView SelectedImage. }
    ImageEnMView1.SetIEBitmap(ImageEnMView1.SelectedImage,
    ImageEnView1.IEBitmap);
    { Whenever an image (Bitmap) within a TImageEnMView changes, you
    must update the thumbnail with TImageEnMView.UpdateImage to make
    sure the thumbnail is visible. }
    ImageEnMView1.UpdateImage(ImageEnMView1.SelectedImage);
    { Assign the ImageEnView.IO.Params to the ImageEnMView.MIO.Params
    incase the params are needed.  Assign does not assign the IO
    params because the image is copied from memory. }
    ImageEnMView1.MIO.Params[ImageEnMView1.SelectedImage].Assign(ImageEnView1.IO.Params);
    { Update the display to show the current content and properties. }
    ImageEnMView1.Update;
  end;

You could also scan the image into TImageEnMView directly then copy the thumbnail to TImageEnView with GetIEBitmap:
Copy the selected TIEBitmap from TImageEnMView to TImageEnView
{ Create a TIEBitmap object from the image at index. }
try
  ImageEnView1.IEBitmap.Assign
  (ImageEnMView1.GetTIEBitmap(ImageEnMView1.SelectedImage));
finally
  { Release or Free the TIEBitmap }
  ImageEnMView1.ReleaseBitmap(ImageEnMView1.SelectedImage);
end;
ImageEnView1.IO.Params.Assign(ImageEnMView1.MIO.Params
  [ImageEnMView1.SelectedImage]);
ImageEnView1.Update;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

chambers120

USA
4 Posts

Posted - Apr 17 2015 :  11:57:17  Show Profile  Reply
Thank you Bill - Just what I was wanting.
All my best,
Charlie
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: