|
-
Jul 30th, 2003, 06:10 AM
#1
Thread Starter
Hyperactive Member
Image and panel (RESOLVED)
Hi,
I'm a complete newbee to vb.Net.
I have a form with a panel.
That panel displays an image.
On top of this panel I have a picturebox that 'highlights' a part of the image.
I'm using drag and drop to position the picturebox on the panel-image.
This is working (needs some debugging, but hey I'm a newbee :-) )
Here comes the question:
Now I want this image in my picturebox to be displayed in another picturbox on my form, so the user can see the final result of his action. And of course be able to save it.
How do I achieve this?
Last edited by mvrp350; Jul 31st, 2003 at 09:21 AM.
-
Jul 30th, 2003, 06:39 AM
#2
if you have an image in a picturebox , you can put it in another picturebox and save it quite easily , here's an example :
VB Code:
With PictureBox2
.Image = PictureBox1.Image
.Image.Save("D:\someimage.jpg")
End With
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jul 30th, 2003, 07:03 AM
#3
Thread Starter
Hyperactive Member
I understand, but the image in my picturebox isn't an actual image, it's background is set to transparent.
Basicly it's the a portion of my panel your looking at.
-
Jul 30th, 2003, 07:19 AM
#4
you would have to get the rectangle area of your " virtual image " ( the first picturebox's image of the panel ) then create an actuall image of it , here's an example of creating an image from a dimension :
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bmp As New Bitmap(100, 100) ' /// the area of your picturebox's virtual image ( ie: the tab's image area ).
Dim g As Graphics = Graphics.FromImage(bmp)
Dim rct As New Rectangle(0, 0, bmp.Width, bmp.Height)
g.FillRectangle(New SolidBrush(Color.Red), rct)
g.Save()
g.Dispose()
With PictureBox2
.Image = bmp
.Image.Save("D:\someimage.jpg")
End With
End Sub
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jul 30th, 2003, 08:29 AM
#5
Thread Starter
Hyperactive Member
It works, but for 50% ;-)
it only draw a red rectangle on my screen, not the desired image.
I've tried to resolve this, but I didn't manage.
Any help please
-
Jul 31st, 2003, 09:20 AM
#6
Thread Starter
Hyperactive Member
A few modifications and it works 
VB Code:
Dim newBitmap As Bitmap = Nothing
Dim g1 As Graphics = Nothing
newBitmap = New Bitmap(thePic1.Width, thePic1.Height, PixelFormat.Format32bppArgb)
g1 = Graphics.FromImage(newBitmap)
g1.FillRectangle(New SolidBrush(Color.White), New Rectangle(0, 0, thePic1.Width, thePic1.Height))
DrawImageRectRect2(g1)
g1.Save()
g1.Dispose()
With PictureBox1
.Image = newBitmap
.Refresh()
End With
'------------------------------------------------
Public Sub DrawImageRectRect2(ByRef g1 As Graphics)
' Create image.
Dim newImage As Image = pnlBackground.BackgroundImage
' Create rectangle for displaying image.
Dim destRect As New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height)
' Create rectangle for source image.
Dim srcRect As New Rectangle(thePic1.Left, thePic1.Top, thePic1.Width, thePic1.Height)
Dim units As GraphicsUnit = GraphicsUnit.Pixel
' Draw image to screen.
g1.DrawImage(newImage, destRect, srcRect, units)
End Sub
thePic1 = the picturebox that shows my target
PictureBox1 = the destination of my image
Kind regards
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
|