Results 1 to 20 of 20

Thread: Resizing images proportionately?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    5
    Is there a routine or call to resize images on a form or do
    I have to do the math myself? In case this isn't clear,
    setting the stretch property to TRUE deforms the image.
    I want to resize it to the size of my image box yet keep
    the right proportions.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    well, you could try setting something up like this:

    Code:
    Dim gfAspect as Single
    Private Sub Form_Load()
        gfAspect = (4 / 3) ' Screen proportions
    End Sub
    Private Sub MyResizer(fWidth as Single)
        imgThePicture.Width = CLng(fWidth)
        imgThePicture.Height = CLng(fWidth * (1 / gfAspect))
    End Sub
    I think that should work, but I'm not sure what you want though. If you just want to neatly stretch an Image control, then you can set the aspect, then alter the width and the height will sort itself out!

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    5
    Thanks for replying. Shortly after I posted this, I went
    ahead and did the math myself, doing something similar to
    what you suggested. My dilema now is that changing the size
    of the image and then saving it doesn't actually change
    the dimensions of the saved image. I tried both with a
    picture box and an image to a picture box. If I pop a msgbox
    with the height and width of the image, it reflects the
    modified size. But as soon as I save it, the size is back
    to its original size. Any ideas?

  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Save it's Image:
    Code:
    SavePicture Picture1.Image FileName

  5. #5
    Guest
    Code:
    SavePicture Picture1.Picture, "C:\MyFileName.bmp"


  6. #6
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Megatron, I think that's wrong...

  7. #7

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    5
    Tried that. It saves the same picture that loaded in
    LoadPicture regardless of how I change the dimensions.
    I also tried loading it into an image, changing dimensions,
    then sticking it in an imagebox and saving it. Same deal.

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    saving it in that way doesn't change the image data, only the way it's displayed. you'll need to store the larger bitmap yourself, then paint it onto the picturebox, and save to a bmp.

  9. #9
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    In fact if you stretch the picture with StretchBlt you can store it's image...

  10. #10
    Guest
    No, Fox, it's right, trust me.

  11. #11
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Wink

    But you don't save the stretched or redrawn picture then... just the one you loaded into the box.

  12. #12
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Fox is right meg, image is the persistent graphics, the output of a graphics method.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  13. #13
    Guest
    Hold on, let me try it...

    Yeah, it does. I guess you were right!


  14. #14
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Sure

  15. #15
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hehe
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  16. #16
    Guest
    What's with the one word replies?

  17. #17
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    maybe they got tired

  18. #18
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    maybe

  19. #19
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yeah.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  20. #20
    Guest

    Wink

    whooaa

Posting Permissions

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



Click Here to Expand Forum to Full Width