Resizing Images

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ali Rizwan
    Banned
    Contributor
    • Aug 2007
    • 931

    Resizing Images

    Hi all,
    I was busy for a long time for a project.
    Now my question is that how can i resize any image like Jpg or bmp to the size of my form or screen resolution for example if screen resolution is 1024 x 768 then image resized to 1024 x 768.
    Is there any other way except Paintpicture???

    Thanx

    >> ALI <<
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    Originally posted by Ali Rizwan
    Hi all,
    I was busy for a long time for a project.
    Now my question is that how can i resize any image like Jpg or bmp to the size of my form or screen resolution for example if screen resolution is 1024 x 768 then image resized to 1024 x 768.
    Is there any other way except Paintpicture???

    Thanx

    >> ALI <<
    Hi

    [CODE=vb]Private Sub Form_Load()
    Image1.Picture = LoadPicture("C: \MyImage.bmp")
    End Sub

    Private Sub Form_Resize()
    Image1.Width = Me.Width
    Image1.Height = Me.Height
    End Sub[/CODE]

    I'm just using an image control. Note: place the control at point 0,0 of your form and make your control (Image1) stretch property = true : )

    Rey Sean

    Comment

    • Ali Rizwan
      Banned
      Contributor
      • Aug 2007
      • 931

      #3
      Originally posted by lotus18
      Hi

      [CODE=vb]Private Sub Form_Load()
      Image1.Picture = LoadPicture("C: \MyImage.bmp")
      End Sub

      Private Sub Form_Resize()
      Image1.Width = Me.Width
      Image1.Height = Me.Height
      End Sub[/CODE]

      I'm just using an image control. Note: place the control at point 0,0 of your form and make your control (Image1) stretch property = true : )

      Rey Sean
      Thanx lotus but i dont mean like this i mean actual resizing. Actually i m creating a virtual desktop app and i want to add wallpaper features like in windows desktop, in which we can center, tile and stretch any wallpaper.

      I hope you understand my problem.

      Thanx
      >> ALI <<

      Comment

      • pentahari
        New Member
        • Dec 2007
        • 60

        #4
        Originally posted by Ali Rizwan
        Hi all,
        I was busy for a long time for a project.
        Now my question is that how can i resize any image like Jpg or bmp to the size of my form or screen resolution for example if screen resolution is 1024 x 768 then image resized to 1024 x 768.
        Is there any other way except Paintpicture???

        Thanx

        >> ALI <<
        you can get the screen size from screen.width and screen.height coding and you use the height and width to your form and image.

        Comment

        • jamesd0142
          Contributor
          • Sep 2007
          • 471

          #5
          Hi,

          what version are you using these days?
          I think i remember you saying you moved onto vb2008?

          See if this code is any use i use it to good effect.
          [code=vb]
          Private Sub SaveResized

          Dim bm As New Bitmap(PictureB ox2.Image)

          Dim myX As Integer

          Dim myY As Integer

          myX = 800

          myY = 600

          If myY = 0 Or myX = 0 Then Exit Sub Else

          Dim thumb As New Bitmap(myX, myY)

          Dim g As Graphics = Graphics.FromIm age(thumb)

          g.Interpolation Mode = Drawing2D.Inter polationMode.Hi ghQualityBicubi c

          g.DrawImage(bm, New Rectangle(0, 0, myX, myY), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pi xel)

          g.Dispose()

          Dim message, title, defaultValue As String

          'Dim myValue As String

          'message = "Enter File Name:" ' Set prompt.

          'title = "Save Resized Photo" ' Set title.

          defaultValue = "" ' Set default value.

          'get name to save resized image, using Inputbox

          'myValue = InputBox(messag e, title, defaultValue)

          'If myValue = "" Then bm.Dispose() : thumb.Dispose() : Exit Sub Else

          thumb.Save("C:\ temp\resized\" & i & ".jpg", System.Drawing. Imaging.ImageFo rmat.Jpeg)

          bm.Dispose()

          thumb.Dispose()

          'Dim caption As String = "Save Resized Photo"

          'MessageBox.Sho w("The Resized Photo has been saved as: " & i, caption, MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)

          End Sub
          [/code]

          This is vb2005 code

          James

          Comment

          • Ali Rizwan
            Banned
            Contributor
            • Aug 2007
            • 931

            #6
            Thanx James.
            I ll convert this to vb6 format.
            and i m also using vb2008 but i make my applications on vb6 till i got full control on vb2008.

            Thanx
            >> ALI <<

            Comment

            Working...