Results 1 to 7 of 7

Thread: Facing Issues With Draw Image Method

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Posts
    340

    Exclamation Facing Issues With Draw Image Method

    Greetings...
    hope all are fine..
    i am trying to making a image effect.
    Let say:
    there is 3 picture box
    when i click on a button picture1 drawn on picture3
    now to do the effect again i set pic3=pic2
    and click the button again. it's drawn the pic on on pic3
    but the issue is it also change pic2 to pic1 (or may be to pic3) why

    so, please download the attached file and help me out. I am stuck..

    i had experience that many one don't want to download attachment for them: (but better if you download the vb.net source files)
    Steps:
    1. Create a new vb.net project (winform)
    2. Place 3 Picturebox (size Mode Property to stretch image)
    3. Now Add 3 Different Picture On The Picture boxes
    3. Add A Button

    Now Use Bellow Source Code:

    Code:
    Public Class Form1
        Dim bmp1 As Bitmap
        Dim bmp2 As Bitmap
        Dim grpDst As Graphics
        Dim FromRect As Rectangle
        Dim ToRect As Rectangle
    
        Private Sub cmd1_Click(sender As System.Object, e As System.EventArgs) Handles cmd1.Click
            bmp1 = New Bitmap(PictureBox1.Image)
            bmp2 = New Bitmap(PictureBox2.Image)
            grpDst = Graphics.FromImage(PictureBox3.Image)
            SDrawTest()
            PictureBox3.Image = PictureBox2.Image REM to load another image on pic3 to set pic 1 again
            PictureBox2.Refresh()
            PictureBox3.Refresh()
        End Sub
    
        Sub SDrawTest()
            FromRect = New Rectangle(0, 0, bmp1.Width, bmp1.Height)
            ToRect = New Rectangle(0, 0, bmp1.Width, bmp1.Height)
            grpDst.DrawImage(bmp1, ToRect, FromRect, GraphicsUnit.Pixel)
            PictureBox3.Refresh()
            System.Threading.Thread.Sleep(1000) REM to show what the effect does
        End Sub
    
    End Class
    Now just run and press the button 2 time (better if you gap few sec)

    on 2nd run picture 2 changes to picture 1 (or may be 3) i don't know

    but why?

    i just want to show/draw the source image on target image

    (May main gold is manipulating vb6 PaintPicture method)

    any help would be highly appreciated

    best regards
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width