Bitmap manipulation as a referenced object
- by John Maloney
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