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
 Resampling images
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Dany

45 Posts

Posted - Jul 04 2018 :  08:41:43  Show Profile  Reply
Hello!

I am really new in images processing so very sorry if this is to basic question. I am adding a collection of images from any source in a ImageEnMView but I want to insert each image pre-processed in the same way as WhatsApp does. For example, the two attached files, ORIGINAL is the one I catched with cell camera, and RESAMPLED is the result of sendig ORIGINAL via WhatsApp. It changed from 2MB to 100KB but if I print RESAMPLE I get an acceptable quality for reading, and full proportional.





I have to insert each image into the collection with the minor possible size but with acceptable printing quality and full proportional. Is it good example for doing this?

Thank you!

xequte

38217 Posts

Posted - Jul 04 2018 :  21:42:03  Show Profile  Reply
You can use Resample to proportionally reduce the size of images:

https://www.imageen.com/help/TImageEnProc.Resample.html


// Resize the image so that it is no higher or wider than 1000px, but maintains the original aspect ratio (e.g. a 4:3 portrait image would have the new dimensions 100 x 75)
ImageEnView1.Proc.Resample(1000, 1000, rfLanczos3, True);




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

Dany

45 Posts

Posted - Jul 12 2018 :  09:16:54  Show Profile  Reply
Thank you!. I see there are more than one way for adding images on a TImageEnMView component (e.g. loading a snapshot, loading a file, etc etc); is there a unique instance in where we can process each image (for resampling) just before it is added (regardless the way images are being added)?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Jul 12 2018 :  09:35:18  Show Profile  Reply
TImageEnMView.OnImageAdded

Declaration

property OnImageAdded: TIEMViewImageNotifyEvent;

Description

Occurs whenever an image has been added to the control.

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

Dany

45 Posts

Posted - Jul 12 2018 :  13:52:24  Show Profile  Reply
Yes I saw it, but it is giving an index as the only one parameter, so is "after" the image was added. I mean, for example if I load from a TIFF that has lots of images, may I process each one just before it will be added to the component?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Jul 13 2018 :  11:12:23  Show Profile  Reply
procedure TForm1.Open1Click(Sender: TObject);
var
  iImageENIO: TImageEnIO;
  iIEBitmap: TIEBitmap;
begin
  if OpenPictureDialog1.Execute then
  begin
    iImageENIO := TImageEnIO.Create(Self);
    try
      iIEBitmap := TIEBitmap.Create;
      try
        iImageENIO.AttachedIEBitmap := iIEBitmap;
        { Load the bitmap}
        iImageENIO.LoadFromFile(OpenPictureDialog1.FileName);
        { Resample the bitmap }
        iIEBitmap.Resample(1000, 1000, rfLanczos3, True, True);
        { Add the bitmap }
        ImageEnMView1.AppendImage(iIEBitmap);
        StatusBar1.Panels[0].Text :=
          ExtractFileDir(OpenPictureDialog1.FileName);
        StatusBar1.Panels[1].Text :=
          ExtractFileName(OpenPictureDialog1.FileName);
        StatusBar1.Panels[2].Text := 'Width: ' + IntToStr(iIEBitmap.Width);
        StatusBar1.Panels[3].Text := 'Height: ' + IntToStr(iIEBitmap.Height);
      finally
        iIEBitmap.Free;
      end;
    finally
      iImageENIO.Free;
    end;
  end;
end;

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

Dany

45 Posts

Posted - Jul 13 2018 :  14:01:49  Show Profile  Reply
Many thaks for your example Bill, and very sorry for asking again but what I am searchig for is which is the unique point (if any) in where I can process any image that is added to ImageEnMView, regardless the procedure used for adding it. For example, you can insert images doing ImgNavigate.MIO.LoadFromFile(..) or doing ImgNavigate.MIO.LoadFromFileTIFF(..) or doing ImgNavigate.MIO.Acquire; in all the cases (I guess) the component will add one by one, the images that are comming from each source. Do we have at that point an oportunity to process each one just before? (very sorry for my poor english !!!).
Go to Top of Page

w2m

USA
1990 Posts

Posted - Jul 13 2018 :  14:13:11  Show Profile  Reply
If I knew how to do that I would have done so. In looking over the events in the help file I can not determine if there is an event that executes before the bitmap is added. I may have missed something, so have a look for yourself.

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

xequte

38217 Posts

Posted - Jul 16 2018 :  01:47:44  Show Profile  Reply
Hi Dany

OnImageAdded is not called for loading of individual frames of an image, but we will address that for 8.0.2. It is is called *after* the insertion into TImageEnMView, but from a performance perspective (as the image is already loaded into the bitmap) it should not make any difference if you use "GetBitmap" to modify the added bitmap.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: