View Single Post
  #1 (permalink)  
Old 07-09-2009, 8:53 AM
scdevils2 scdevils2 is offline
VB.NET Forum Newbie
.NET Framework: .NET 2.0
 
Join Date: Jun 2007
Posts: 7
Reputation: 0
scdevils2 is on a distinguished programming path ahead
Default Are Cloned Images Disjoint From original Image?

If I set CloneFirst =True, the image is displayed as expected. If i Set CloneFirst =False the image is displayed pixelated. Can someone please explain to me why this is happening.

Code:
    Private Const FILE_PATH As String = "staticmap.jpeg"
    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        Dim imageFile As New IO.FileInfo(FILE_PATH)
        Dim newBitMap As Bitmap = CType(Bitmap.FromStream(imageFile.OpenRead), Bitmap)
        Dim clonedBitMap As Bitmap

        clonedBitMap = getBitMap(newBitMap, ckbCloneFirst.Checked)
        pbImage.Image = clonedBitMap



    End Sub


    Private Function getBitMap(ByVal BottomImage As Bitmap, ByVal CloneFirst As Boolean) As Bitmap

        Dim CopiedBottomImage As Bitmap = DirectCast(BottomImage.Clone(), Bitmap)
        Dim CopiedImageGraphics As Graphics
        Dim otherImage As Bitmap


        If CloneFirst Then
            otherImage = DirectCast(BottomImage.Clone(), Bitmap)
            CopiedImageGraphics = Graphics.FromImage(CopiedBottomImage)
        Else
            CopiedImageGraphics = Graphics.FromImage(CopiedBottomImage)
            otherImage = DirectCast(BottomImage.Clone(), Bitmap)
        End If

        'otherImage.Dispose()
        'BottomImage.Dispose()
        '' secondImage.Dispose()
        'CopiedImageGraphics.Dispose()

        Return CopiedBottomImage
    End Function
Reply With Quote