Bitmap manipulation as a referenced object

Posted by John Maloney on Stack Overflow See other posts from Stack Overflow or by John Maloney
Published on 2010-03-19T20:26:29Z Indexed on 2010/03/19 20:31 UTC
Read the original article Hit count: 165

I am working with a Bitmap object that I add annotations or copyright material to the image and then return the modified bitmap. My problem is that the Bitmap won't hold the changes made to it as it moves along the chain. I am treating it as a reference type and would assume that as it gets passed to each class it would carry the changes made to it. I have verified that the code inside of the MarkImage() classes does function, but which ever one gets called last is the one that has changes.

Public Shared Function GetImage(ByVal imageDef As IImageDefinition) As Bitmap
    Dim image As Bitmap = Drawing.Image.FromFile(imageDef.Path)

    If Not imageDef.Authorization.IsAllowed(AuthKeys.CanViewWithoutCopyright) Then
        image = New MarkCopyrightImage(image).MarkImage()
    End If

    If Not imageDef.Authorization.IsAllowed(AuthKeys.CanViewWithoutAnnotations) Then
        image = New MarkAnnotateImage(image).MarkImage()
    End If

    Return image
End Function

How do I write changes to a bitmap object and then pass that object to another class while maintaining the changes?

Answers in C# or VB are fine? Thanks

© Stack Overflow or respective owner

Related posts about bitmapimage

Related posts about pass-by-reference