|
-
Oct 3rd, 2002, 02:57 PM
#1
Thread Starter
Addicted Member
Image Manipulation in Vb.nET
I have a picture box loaded with an image.
I want to take part of that image say a 20 square pixel region to y+10 and copy that into an Image object ( so I can do stuff with it).
Then I want to take that and overlay it on another image, and be able to move it around and stuff.
Unfortunately I have no idea how to even start in VB.NET.
How do I chop out the part of the image that I want?
Eiredrake
-
Oct 3rd, 2002, 03:55 PM
#2
yay gay
the graphic things in vb.net is in the system.drawing and system.drawing.drawing2d namespaces(gdi+)
-
Oct 3rd, 2002, 05:06 PM
#3
PowerPoster
www.c-sharpcorner.com
That site is C# oriented, but they have a graphics section that has a lot of sample code. Most of the graphics stuff will be the same in C# and VB.Net.
-
Oct 3rd, 2002, 05:27 PM
#4
Re: Image Manipulation in Vb.nET
Originally posted by Eiredrake
I have a picture box loaded with an image.
I want to take part of that image say a 20 square pixel region to y+10 and copy that into an Image object ( so I can do stuff with it).
Then I want to take that and overlay it on another image, and be able to move it around and stuff.
Unfortunately I have no idea how to even start in VB.NET.
How do I chop out the part of the image that I want?
Eiredrake
I dont know what you mean by overlay...but to take out a part of it and copy it to a variable... here's a sample code I wrote:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' The cut-out portion will be 20 by 20 pixels
Dim cutWidth As Integer = 20
Dim cutHeight As Integer = 20
' Portion of the original image that is going to be cut out
Dim srcRect As New Rectangle(50, 50, cutWidth, cutheight)
Dim destRect As New Rectangle(0, 0, cutWidth, cutHeight)
' Saves the part of the image what will be cut out
Dim bmpSelection As New Bitmap(cutWidth, cutHeight)
Dim gr As Graphics = Graphics.FromImage(bmpSelection)
' The rectangle represents the part of the picture that you want to cut out
gr.DrawImage(picSrc.Image, destRect, srcRect, GraphicsUnit.Pixel)
' bmpSelection contains the cutout now...
' Do this if you want to replace the cutout with a blank rectangle
Dim myBrush As New SolidBrush(picSrc.BackColor)
gr = Graphics.FromImage(picSrc.Image)
gr.FillRectangle(myBrush, srcRect)
picSrc.Invalidate(srcRect)
gr.Dispose()
picTest.Image = bmpSelection
End Sub
make a windows app project and put two picboxes in it with a button. Name a picturebox "picSrc" and put the original image in it. Rename the other picturebox to "picTest"
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
|