I way trying to change the opacity of one bitmap by using the following code
Dim image as New Aurigma.GrphicMaill.Bitmap("C:\mypic.jpg") Dim TransBitmap As New Aurigma.GraphicsMill.Bitmap(image.Width, image.Height, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb)
Current implementation of the Graphics Mill for .NET doesn't change alpha channel of the destination bitmap, so you cannot perform this with Bitmap.Draw(...) method.
But! 😉 If you are loading image without alpha channel and want to create partially-transparent image you can do this that way:
Dim image As New Aurigma.GraphicsMill.Bitmap("x:\allformats\24bppRgb.jpg")
image.Channels.AddAlpha(0.7)
Current implementation of the Graphics Mill for .NET doesn't change alpha channel of the destination bitmap, so you cannot perform this with Bitmap.Draw(...) method.
But! 😉 If you are loading image without alpha channel and want to create partially-transparent image you can do this that way:
Dim image As New Aurigma.GraphicsMill.Bitmap("x:\allformats\24bppRgb.jpg")
image.Channels.AddAlpha(0.7)
Cool.. But is there any way to detect the Alpha Value from a bitmap? Please advice.
What do you mean by phrase "detect the Alpha Value"? If you want to determine whether bitmap has alpha channel or not - you may use Bitmap.HasAlpha property. Or you mean something else?
What do you mean by phrase "detect the Alpha Value"? If you want to determine whether bitmap has alpha channel or not - you may use Bitmap.HasAlpha property. Or you mean something else?
What I want to know is the value we set for the Alpha (example 0.7F)
You can read any bitmap's pixel color and check the alpha value. Of course, if you sure that alphas of all pixels are the same (e.g. if you set it by Bitmap.Channels.AddAlpha(...) call).
You can read any bitmap's pixel color and check the alpha value. Of course, if you sure that alphas of all pixels are the same (e.g. if you set it by Bitmap.Channels.AddAlpha(...) call).
Thanks.... But, for unknown reason, the getPixel only work once
Public Function getAlphaValue(ByVal backgroundImage As Aurigma.GraphicsMill.Bitmap) As Double Dim _color As System.Drawing.Color Dim dblRet As Double = 1 Dim myBitmap As Aurigma.GraphicsMill.Bitmap
Try myBitmap = CType(backgroundImage, Aurigma.GraphicsMill.Bitmap) _color = myBitmap.GetPixel(10, 10) dblRet = _color.A / 255 Catch ex As Exception
Finally dblRet = dblRet * 100 End Try
Return dblRet
End Function
I had a function as above, while, the backgroundImage will be called from a VObject.tag
It works fine while I am working on it. While I save the file (serialized the .tag, and deserialized the bitmap back to the vobject.tag) then @ this line _color = myBitmap.GetPixel(10, 10) I will get the err.Description of "Object reference not set to an instance of an object."
Seems like the issue is still there. It will still goes into same error message on Aurigma.GraphicsMill.RgbColor pixColor = (Aurigma.GraphicsMill.RgbColor)imageData.GetPixel(0, 0);
Public Function getAlphaValue(ByVal backgroundImage As Aurigma.GraphicsMill.Bitmap) As Double
Dim _color As System.Drawing.Color
Dim dblRet As Double = 1
'Dim myBitmap As Aurigma.GraphicsMill.Bitmap
Dim imageData As Aurigma.GraphicsMill.BitmapData = backgroundImage.LockBits(0, 0, 1, 1)
Try
_color = backgroundImage.GetPixel(0, 0)
dblRet = _color.A / 255
Catch ex As Exception
Finally
backgroundImage.UnlockBits(imageData)
dblRet = dblRet * 100
End Try
Return dblRet
End Function
You should call GetPixel(...) method of the Aurigma.GraphicsMill.BitmapData class, not Aurigma.GraphicsMill.Bitmap one. Please, look at the code sample I've posted above.