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
 Square Thumbnails
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
234 Posts

Posted - Mar 16 2012 :  04:19:05  Show Profile  Reply
I have looked at the thumbnail demo and tried to adapt it to generate a square thumbnail! Is there anyway that I can shrink and crop the image to generate a 160x160 thumbnail instead of the one in the demo that maintains the aspect ratio?

fab

1310 Posts

Posted - Mar 16 2012 :  10:58:37  Show Profile  Reply
Images aspect ratio cannot be disabled. You have to put a 160x160 image (or resize/crop already added images).
For example this code resamples all images to 160x160:
var
  i:integer;
begin
  for i:=0 to ImageEnMView1.ImageCount-1 do
  begin
    ImageEnMView1.SelectedImage := i;
    ImageEnMView1.Proc.Resample(160, 160);
  end;
end;
Go to Top of Page

xequte

39056 Posts

Posted - Mar 17 2012 :  02:10:58  Show Profile  Reply
Hi

Images without maintained AR tend to look odd, so you may prefer to resize and then crop as follows:

If the source image is portrait shaped call:

ImageEnProc.Resample(160, -1, rfLanczos3)

ELSE { Landscape }

ImageEnProc.Resample(-1, 160, rfLanczos3);


Then resize the image cropping off the outlying pixels:

ImageEnProc.ImageResize(160, 160, iehCenter, ievCenter);


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

bmesser

United Kingdom
234 Posts

Posted - Mar 17 2012 :  10:25:08  Show Profile  Reply
Nigel

Thanks for the advice that snippet works fine.

Bruce.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: