Professional Web Applications Themes

Best way to resize an image in a NSScrollView - Mac Programming

Hi, I would like to put a "resizable" image in a NSScrollView, giving a variable zoom factor. I saw many posts about problems arising: - when the size of the image is less than the frame - due to centering issues Could someone tell me which is the best way to do it in a clean way. Thank you very much ! Loc...

Sponsored Links
  1. #1

    Default Best way to resize an image in a NSScrollView

    Hi,

    I would like to put a "resizable" image in a NSScrollView, giving a
    variable zoom factor.

    I saw many posts about problems arising:
    - when the size of the image is less than the frame
    - due to centering issues

    Could someone tell me which is the best way to do it in a clean way.

    Thank you very much !

    Loc
    Sponsored Links
    Loic Guest

  2. #2

    Default Re: Best way to resize an image in a NSScrollView

    In article <google.com>,
    fr (Loic BERTRAND) wrote:
     

    You have two ways to deal with the image being smaller than the frame.
    One is to make sure that never happens by always resizing the window to
    be at most as large as your image plus the size of the scroll bars. In
    your NSWindow delegate, you can get a message that allows you to control
    resizing to make sure that the user can't resize larger than a certain
    amount. This is what I do in a similar situation, although you may not
    like it.

    For centering, I can't say for sure what it would take. You may simply
    be able to see if [[self superview] bounds] is larger than [self frame],
    and if so, change your frame origin or your superview's bounds origin
    appropriately. If that doesn't work, you may need to put your view
    inside another view which resizes itself dynamically to always be at
    least as large as the enclosing scroll view, and you then center
    yourself inside it.

    This is about as clean as it comes as far as I'm aware. There's no
    checkbox or anything, but these solutions aren't too bad.
    Michael Guest

  3. #3

    Default Re: Best way to resize an image in a NSScrollView

    Thank you for your answer.

    Actually I really need to have an image bigger than its frame (and
    then be able to scroll). My application is a scientific one and I want
    to give the user the ability to zoom and to render the image in a 1:1
    ratio, whatever the original size of the image.

    Thank you,

    Loc
    Loic Guest

  4. #4

    Default Re: Best way to resize an image in a NSScrollView

    In article <google.com>,
    fr (Loic BERTRAND) wrote:
     

    If your image is larger than the frame then things are really easy. Put
    your view inside an NSScrollView and your job is done, everything is
    handled for you. Things only get tricky when your image is smaller than
    the enclosing scroll view. Handling the zoom is as simple as changing
    your view's frame without changing its bounds, to make its contents
    larger or smaller.
    Michael Guest

  5. #5

    Default Re: Best way to resize an image in a NSScrollView

    Yes... of course... I could have tried it directly.

    Thank you very much,

    Loc
    Loic Guest

  6. #6

    Default Re: Best way to resize an image in a NSScrollView

    .... and it works perfectly.
    Loic Guest

Similar Threads

  1. Resize Bitmap image in image control in flex3
    By mousumi_78 in forum Macromedia Flex General Discussion
    Replies: 2
    Last Post: May 5th, 06:07 PM
  2. Resize image on the fly
    By ignandis in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: May 10th, 08:58 PM
  3. Dynamic image resize with php
    By Giovanni in forum PHP Development
    Replies: 1
    Last Post: December 19th, 03:03 PM
  4. Image Resize does not work
    By Sandwick in forum PHP Development
    Replies: 3
    Last Post: July 3rd, 04:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139