Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
Hi, 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) image.Draw(TransBitmap, 0, 0, image.Width, image.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Alpha, 0.3F, Aurigma.GraphicsMill.Transforms.InterpolationMode.HighQuality) What I would like to do is load this semi transparent image into VObject so that it could be use in the multilayer viewer. but seems like it doesn't work. Anyone could help out with this please? Thanks. Edited by user Sunday, February 3, 2008 10:07:59 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hi, 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: Code:Dim image As New Aurigma.GraphicsMill.Bitmap("x:\allformats\24bppRgb.jpg")
image.Channels.AddAlpha(0.7)
Edited by user Monday, February 4, 2008 6:45:10 PM(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
Alex Kon wrote:Hi, 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: Code: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. Regards
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, 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? |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
Alex Kon wrote:Hello, 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)
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, 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 use Bitmap.GetPixel(...) method to read color value. Edited by user Monday, February 25, 2008 6:29:28 PM(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
Alex Kon wrote:Hello, 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 use Bitmap.GetPixel(...) method to read color value. Hi, 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." Please advice. Edited by user Monday, February 25, 2008 6:29:50 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, We confirm the issue with Bitmap.GetPixel() method after object's deserialization. If this is critical for you, please submit case. Edited by user Thursday, May 22, 2008 2:41:31 PM(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
beside getPixel, is there any alternative way to get the Alpha Value of the image? Please advice.
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, Yeap, here is workaround code: Code:Aurigma.GraphicsMill.Bitmap image =
new Aurigma.GraphicsMill.Bitmap("x:/allformats/24bppRgb.jpg");
image.Channels.AddAlpha(0.5f);
Aurigma.GraphicsMill.BitmapData imageData = image.LockBits(0, 0, 1, 1);
try
{
Aurigma.GraphicsMill.RgbColor pixColor =
(Aurigma.GraphicsMill.RgbColor)imageData.GetPixel(0, 0);
System.Windows.Forms.MessageBox.Show(pixColor.ToString());
}
finally
{
image.UnlockBits(imageData);
}
|
|
|
|
|
Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
Alex Kon wrote:Hello, Yeap, here is workaround code: Code:Aurigma.GraphicsMill.Bitmap image =
new Aurigma.GraphicsMill.Bitmap("x:/allformats/24bppRgb.jpg");
image.Channels.AddAlpha(0.5f);
Aurigma.GraphicsMill.BitmapData imageData = image.LockBits(0, 0, 1, 1);
try
{
Aurigma.GraphicsMill.RgbColor pixColor =
(Aurigma.GraphicsMill.RgbColor)imageData.GetPixel(0, 0);
System.Windows.Forms.MessageBox.Show(pixColor.ToString());
}
finally
{
image.UnlockBits(imageData);
}
Hi, 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);
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, Its very strange! Which version of Graphics Mill for .NET do you use? Here is full code of my test application: Code:Aurigma.GraphicsMill.Bitmap image =
new Aurigma.GraphicsMill.Bitmap("x:/allformats/24bppRgb.jpg");
image.Channels.AddAlpha(0.5f);
//Serialization
System.IO.FileStream fs =
new System.IO.FileStream("y:/data.dat", System.IO.FileMode.Create);
image.Serialize(fs);
image.Dispose();
//Deserialization
image = new Aurigma.GraphicsMill.Bitmap();
fs = new System.IO.FileStream("y:/data.dat", System.IO.FileMode.Open);
image.Deserialize(fs);
fs.Close();
//Now this code throws NullReference exception
//System.Windows.Forms.MessageBox.Show(image.GetPixel(10, 10).ToString());
Aurigma.GraphicsMill.BitmapData imageData = image.LockBits(10, 10, 1, 1);
try
{
//And this code works correctly on my machine
//with 4.1.11, 4.5.16 and 4.5.17 versions
Aurigma.GraphicsMill.RgbColor pixColor =
(Aurigma.GraphicsMill.RgbColor)imageData.GetPixel(0, 0);
System.Windows.Forms.MessageBox.Show(pixColor.ToString());
}
finally
{
image.UnlockBits(imageData);
}
Could you test this sample and let me know whether the issue can be reproduced on your machine? |
|
|
|
|
Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
Code: 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
Edited by user Monday, February 25, 2008 6:30:10 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, 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. |
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.