Results 1 to 3 of 3
  1. #1
    Geometrical's Avatar
    Join Date
    Jul 2012
    Gender
    male
    Location
    In the middle of nowhere.
    Posts
    1,034
    Reputation
    331
    Thanks
    10,335
    My Mood
    Chatty

    Changing the size of an image

    Here a detailed tutorial on how to successfully resize an image.



    ●First of all you do not do this:

    John has an image with the dimensions 300 x 200 and he wants to increase each by 100. He loads an image into a picturebox and does the following:

    Code:
    PictureBox1.Size = New Size(400, 300)
    PictureBox1.Image.Save("Cute Dog.png")
    It will not work since the save functions saves the image as it is and also John does not know Visual Basic.

    __________________________________________________ _____________________________________________

    And now lets get to what you should do.

    ●First of all we need to import namespace 'Drawing' which has some handy elements such as classes, functions etc.

    Code:
    Imports System.Drawing
    ●Now lets create the function that will resize the image you want with the the original image and the new size as input.

    Code:
    Function ResizeImage(Byval Image As Image, Byval NewSize As Size) As Image
    ●Create a new blank bitmap.

    Code:
    Dim _Image As Image = New Bitmap(NewSize)
    ●Now create the graphics handle to the image.

    Code:
    Dim _Graphics As Graphics = Graphics.FromImage(_Image)
    ●Now we draw the original image onto to the blank bitmap using the handle.

    Code:
    _Graphics.DrawImage(Image, 0, 0, Size.Width, Size.Height)
    ●Now to end the function.

    Code:
    End Function
    ●Heres the code in actions:

    You have an image of 400 x 50 and want to change the dimensions to 200 x 50. So heres what you can do:

    Code:
    PictureBox1.Image = ResizeImage(My.Resources.MyImage, New Size(200 x 50))
    PictureBox1.Imge.Save("Cute Dog.png")
    And thats all.
    Last edited by Geometrical; 12-15-2013 at 11:34 PM.

  2. #2
    abuckau907's Avatar
    Join Date
    Dec 2012
    Gender
    male
    Location
    other side of the wire
    Posts
    1,342
    Reputation
    162
    Thanks
    239
    My Mood
    Cold
    Don't forget to call
    Code:
    _Graphics.Dispose()
    and ofc
    Code:
    Return _Image
    Thnx for sharing.
    'Some things that can be counted, don't matter. And some things that matter, can't be counted' - A.E.
    --
     

    My posts have some inaccuracies/are wrong/wrong keyword(s) used.
    They're (maybe) pretty close, and I hope they helped you, not created confusion. Take with grain of salt.

    -if you give rep, please leave a comment, else it means less.

  3. #3
    Geometrical's Avatar
    Join Date
    Jul 2012
    Gender
    male
    Location
    In the middle of nowhere.
    Posts
    1,034
    Reputation
    331
    Thanks
    10,335
    My Mood
    Chatty
    Quote Originally Posted by abuckau907 View Post
    Don't forget to call
    Code:
    _Graphics.Dispose()
    and ofc
    Code:
    Return _Image
    Thnx for sharing.
    Oh yes, thx for reminding. And also add on:

    Code:
    CompositingQuality = CompositingQuality.HighQualityBicubic
    For a better result on the output.

Similar Threads

  1. How to Change the Start-Bar in Windows XP
    By Jackal in forum General
    Replies: 31
    Last Post: 05-31-2015, 08:29 PM
  2. [Tutorial] How to change the store purchase .gif image [default is Katarina dancing]
    By Aiden98 in forum League of Legends Guides
    Replies: 1
    Last Post: 08-02-2013, 02:23 AM
  3. [Help Request] How can I change the screen size of Rotmg to higher so i can see more
    By piekiller19 in forum Realm of the Mad God Help & Requests
    Replies: 0
    Last Post: 03-27-2013, 09:49 PM
  4. [Help] Changing the size of your crosshair?
    By b3njam1n in forum All Points Bulletin Reloaded Hacks
    Replies: 13
    Last Post: 05-23-2012, 06:30 AM
  5. How do you change the size of the signature?
    By Xarian in forum Suggestions, Requests & General Help
    Replies: 0
    Last Post: 10-25-2008, 09:36 PM