|
-
Jul 2nd, 2003, 12:26 PM
#1
Thread Starter
Lively Member
GDI+ image zoom
Hey guys, I rarely have to deal with images so excuse my noobness. Anyway I downloaded the 101 examples from MS for vb.net and opened the GDI image manipulation.
' Make the PictureBox dimensions larger by 25% to effect the Zoom.
picImage.Width = CInt(picImage.Width * 1.25)
picImage.Height = CInt(picImage.Height * 1.25)
This zoom works great, the only problem is that it increases the size of the picturebox. I want to ZOOM in and out on the image, leaving the picturebox the same size. Anyone have any ideas?
-
Jul 2nd, 2003, 01:17 PM
#2
Hyperactive Member
Re: GDI+ image zoom
Originally posted by Iamthewalrus15
Hey guys, I rarely have to deal with images so excuse my noobness. Anyway I downloaded the 101 examples from MS for vb.net and opened the GDI image manipulation.
' Make the PictureBox dimensions larger by 25% to effect the Zoom.
picImage.Width = CInt(picImage.Width * 1.25)
picImage.Height = CInt(picImage.Height * 1.25)
This zoom works great, the only problem is that it increases the size of the picturebox. I want to ZOOM in and out on the image, leaving the picturebox the same size. Anyone have any ideas?
I think the easiest way is to just put the picture box inside a Panel control.
However, there's got to be a way to do this without using Windows Forms controls.
-
Jul 3rd, 2003, 03:59 AM
#3
Lively Member
Panel1 is used for options
Panel2 contain PictureBox
PictureArray is an array with pictures ;-)
I load the listbox with x items corresponding to X images in array
VB Code:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim Width As Integer
Dim Height As Integer
Dim Ratio As Decimal
If ListBox1.SelectedIndex > -1 Then
If RadioButton1.Checked = True Then 'ZOOM 100%
Height = PictureArray(ListBox1.SelectedIndex).Height
Width = PictureArray(ListBox1.SelectedIndex).Width
PictureBox1.Height = PictureArray(ListBox1.SelectedIndex).Height
PictureBox1.Width = PictureArray(ListBox1.SelectedIndex).Width
Else 'ZOOM to Fit into Panel2
PictureBox1.Height = Panel2.Height
PictureBox1.Width = Panel2.Width
Ratio = PictureArray(ListBox1.SelectedIndex).width / PictureArray(ListBox1.SelectedIndex).height
If Ratio < (PictureBox1.Width / PictureBox1.Height) Then
Height = PictureBox1.Height
Width = PictureBox1.Width * Ratio
Else
Height = PictureBox1.Height / Ratio
Width = PictureBox1.Width
End If
End If
PictureBox1.Image = PictureArray(ListBox1.SelectedIndex).GetThumbnailImage(Width, Height, Nothing, Nothing)
PictureBox1.Tag = ListBox1.SelectedIndex
End If
End Sub
Hope this will help you
-
Jul 3rd, 2003, 08:36 PM
#4
you have to use the drawimage function and only draw the visible portion of the image on the picturebox (without resizing the picturebox). Do this if you wanna be a little more efficient
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|