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
 Auto Crop
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Gordon Ham

USA
10 Posts

Posted - Sep 03 2019 :  23:47:48  Show Profile  Reply
Im sorry my question is so basic..

I have a TImageEnView on my form. I set the height and width to be my desired size..

I open and load a Jpg.. I zoom it it and out of the window until it is where I want it to be in the window. Now I want to save it as a BMP file.. ONLY the viewable area of my component. I want it to automatically crop the area that is visible in my component, then save it.

Can you guide me?

xequte

38615 Posts

Posted - Sep 04 2019 :  03:21:56  Show Profile  Reply
Hi Gordon

This should do it:

// Save the visible bitmap as a TBitmap
iebmp := TIEBitmap.create( IERectangle( ImageEnView1.VisibleBitmapRect ).Width, IERectangle( ImageEnView1.VisibleBitmapRect ).Height );
ImageEnView1.IEBitmap.DrawToTIEBitmap( iebmp, 0, 0, IERectangle( ImageEnView1.VisibleBitmapRect ) );
iebmp.Write( 'D:\image.bmp' );
iebmp.Free;



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

Gordon Ham

USA
10 Posts

Posted - Sep 04 2019 :  11:32:17  Show Profile  Reply
Works perfect! Thanks!
Go to Top of Page

Gordon Ham

USA
10 Posts

Posted - Sep 04 2019 :  12:02:57  Show Profile  Reply
I guess I spoke too soon.. It crops perfectly.. but I guess what I really need is for it to not only crop, but to resize for the size of the screen. Is there a way to resize too?
Go to Top of Page

xequte

38615 Posts

Posted - Sep 04 2019 :  16:12:43  Show Profile  Reply
Hi

To scale an image, use:
https://www.imageen.com/help/TIEBitmap.Resample.html

e.g.
mbmp.Resample(Screen.Width, Screen.Height, rfFastLinear, True);

Note: I have set MaintainAspectRatio as true, so you may then need to resize the image (not the content) to screen size, using:
https://www.imageen.com/help/TIEBitmap.resize.html

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

Gordon Ham

USA
10 Posts

Posted - Sep 04 2019 :  16:47:24  Show Profile  Reply
So, After the last code, just resize it before saving? Can you jot down a quick example? This is all so new to me.
Go to Top of Page

xequte

38615 Posts

Posted - Sep 05 2019 :  16:33:55  Show Profile  Reply

MyIEBitmap.Resize( Screen.Width, Screen.Height, clBlack, 255, iehCenter, ievCenter );

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