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 way to set a minimum zoom level
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bmesser

United Kingdom
224 Posts

Posted - Feb 05 2013 :  09:34:25  Show Profile  Reply
Hi

I have put in place a minimum zoom level like this...

procedure ImageViewChange(Sender: TObject; Change: Integer);
begin
  if Image.Zoom<50 then Image.Zoom:=50;
end;


I am getting fairly picky now and although it works, when the zoom is 50 and the user tries to go lower the zoom level, the overall effect is that the image 'bounces' between two zoom levels - is there any way I can stop that and don't do anything or is that how it is?

I've tried the
OnChanging
event without any luck either and there doesn't seem to be a minimum zoom level you can set which would solve my problem.

Bruce.

w2m

USA
1990 Posts

Posted - Feb 05 2013 :  10:06:04  Show Profile  Reply
If you use a TTrackbar or TSpinEdit to adjust the zoom the best way is to set the min property to 50. This way you do not get any flicker at all. At this point I do not see a way to eliminate flicker, but you might try:
procedure TForm1.ImageEnView1ViewChange(Sender: TObject; Change: Integer);
begin
  if Change = 1 then
  begin
    if ImageEnView1.Zoom < 50 then
      ImageEnView1.Zoom := 50;
  end;
  cxTrackBarZoom1.Position := Round(ImageEnView1.Zoom);
end;

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

bmesser

United Kingdom
224 Posts

Posted - Feb 06 2013 :  02:36:21  Show Profile  Reply
Hi Bill

I didn't want to use any extra controls and just rely on the mouse & keyboard. What I've done is disable the mouse wheel and take control of zooming myself - in that way zooming now just stops if its less than 50% and you don't get the 'bounce' as it resets back exactly to 50%.

Bruce.
Go to Top of Page

w2m

USA
1990 Posts

Posted - Feb 06 2013 :  09:17:34  Show Profile  Reply
You said you "take control of zooming myself". I am curious. How did you eliminate the bounce?

William Miller
Go to Top of Page

bmesser

United Kingdom
224 Posts

Posted - Feb 06 2013 :  10:40:59  Show Profile  Reply
procedure TfmMain.ImageMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
  if WheelDelta<0 then
  begin
    if Image.Zoom>50 then Image.Zoom:=Image.Zoom*0.9;
  end
  else Image.Zoom:=Image.Zoom*1.1;

  handled:=True;
end;
Go to Top of Page

xequte

38613 Posts

Posted - Feb 06 2013 :  22:01:07  Show Profile  Reply
And how about including a stop for "Fit to Window" (untested):
procedure TfmMain.ImageMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
  iNewZoom : Double;
begin
  iNewZoom := Image.Zoom;
  if WheelDelta > 0 then
  begin
    iNewZoom := iNewZoom * 1.1;
    if (Image.GetIdealZoom > Image.Zoom) and
       (Image.GetIdealZoom < iNewZoom) then
      iNewZoom := Image.GetIdealZoom;
  end
  else
  if iNewZoom > 50 then 
  begin
    iNewZoom := iNewZoom * 0.9;
    if (Image.GetIdealZoom > iNewZoom) and
       (Image.GetIdealZoom < Image.Zoom) then
    iNewZoom := Image.GetIdealZoom;
  end;

  Image.Zoom := iNewZoom;  
  handled := True;
end;



Also see:
http://www.imageen.com/help/TImageEnView.ZoomIn.html
http://www.imageen.com/help/TImageEnView.ZoomOut.html


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

bmesser

United Kingdom
224 Posts

Posted - Feb 07 2013 :  06:54:02  Show Profile  Reply
Thanks Nigel I'll give that a go!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: