By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

Resizing Images

Ali Rizwan
100+
P: 927
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 <<
May 9 '08 #1
Share this Question
Share on Google+
5 Replies


lotus18
100+
P: 866
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

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Image1.Picture = LoadPicture("C:\MyImage.bmp")
  3. End Sub
  4.  
  5. Private Sub Form_Resize()
  6.     Image1.Width = Me.Width
  7.     Image1.Height = Me.Height
  8. End Sub
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
May 10 '08 #2

Ali Rizwan
100+
P: 927
Hi

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Image1.Picture = LoadPicture("C:\MyImage.bmp")
  3. End Sub
  4.  
  5. Private Sub Form_Resize()
  6. Image1.Width = Me.Width
  7. Image1.Height = Me.Height
  8. End Sub
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 <<
May 10 '08 #3

pentahari
P: 60
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.
May 12 '08 #4

jamesd0142
100+
P: 469
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.
Expand|Select|Wrap|Line Numbers
  1.  Private Sub SaveResized
  2.  
  3.         Dim bm As New Bitmap(PictureBox2.Image)
  4.  
  5.         Dim myX As Integer
  6.  
  7.         Dim myY As Integer
  8.  
  9.         myX = 800
  10.  
  11.         myY = 600
  12.  
  13.         If myY = 0 Or myX = 0 Then Exit Sub Else 
  14.  
  15.         Dim thumb As New Bitmap(myX, myY)
  16.  
  17.         Dim g As Graphics = Graphics.FromImage(thumb)
  18.  
  19.         g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
  20.  
  21.         g.DrawImage(bm, New Rectangle(0, 0, myX, myY), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel)
  22.  
  23.         g.Dispose()
  24.  
  25.         Dim message, title, defaultValue As String
  26.  
  27.         'Dim myValue As String
  28.  
  29.         'message = "Enter File Name:" ' Set prompt.
  30.  
  31.         'title = "Save Resized Photo" ' Set title.
  32.  
  33.         defaultValue = "" ' Set default value.
  34.  
  35.         'get name to save resized image, using Inputbox
  36.  
  37.         'myValue = InputBox(message, title, defaultValue)
  38.  
  39.         'If myValue = "" Then bm.Dispose() : thumb.Dispose() : Exit Sub Else 
  40.  
  41.         thumb.Save("C:\temp\resized\" & i & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
  42.  
  43.         bm.Dispose()
  44.  
  45.         thumb.Dispose()
  46.  
  47.         'Dim caption As String = "Save Resized Photo"
  48.  
  49.         'MessageBox.Show("The Resized Photo has been saved as: " & i, caption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  50.  
  51.     End Sub
  52.  
This is vb2005 code

James
May 12 '08 #5

Ali Rizwan
100+
P: 927
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 <<
May 14 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.