Forums

Welcome Guest Search | Active Topics | Members

Watermark Image Options
undead80
Posted: Sunday, February 03, 2008 5:59:26 PM
Rank: Member
Groups: Member

Joined: 1/8/2008
Posts: 28
Points: 84
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.
Alex Kon
Posted: Tuesday, February 05, 2008 2:44:04 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
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)



Best wishes, Alex.
undead80
Posted: Wednesday, February 06, 2008 5:48:37 AM
Rank: Member
Groups: Member

Joined: 1/8/2008
Posts: 28
Points: 84
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
Alex Kon
Posted: Wednesday, February 06, 2008 6:09:27 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
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?



Best wishes, Alex.
undead80
Posted: Wednesday, February 06, 2008 3:44:21 PM
Rank: Member
Groups: Member

Joined: 1/8/2008
Posts: 28
Points: 84
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)
Alex Kon
Posted: Thursday, February 07, 2008 1:51:45 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
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.




Best wishes, Alex.
undead80
Posted: Saturday, February 09, 2008 11:07:01 PM
Rank: Member
Groups: Member

Joined: 1/8/2008
Posts: 28
Points: 84
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.
Alex Kon
Posted: Monday, February 11, 2008 3:08:35 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
Hello,

We confirm the issue with Bitmap.GetPixel() method after object's deserialization. If this is critical for you, please submit case.


Best wishes, Alex.
undead80
Posted: Wednesday, February 13, 2008 8:51:34 AM
Rank: Member
Groups: Member

Joined: 1/8/2008
Posts: 28
Points: 84
beside getPixel, is there any alternative way to get the Alpha Value of the image?

Please advice.
Alex Kon
Posted: Wednesday, February 13, 2008 11:58:11 PM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
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);
}


Best wishes, Alex.
undead80
Posted: Thursday, February 14, 2008 11:04:44 PM
Rank: Member
Groups: Member

Joined: 1/8/2008
Posts: 28
Points: 84
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);
Alex Kon
Posted: Friday, February 15, 2008 5:39:18 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
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?



Best wishes, Alex.
undead80
Posted: Sunday, February 17, 2008 9:04:58 AM
Rank: Member
Groups: Member

Joined: 1/8/2008
Posts: 28
Points: 84
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
Alex Kon
Posted: Sunday, February 17, 2008 10:18:15 PM
Rank: Advanced Member
Groups: Administration , Member

Joined: 1/31/2005
Posts: 385
Points: 400
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.



Best wishes, Alex.
Users browsing this topic
Guest


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.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.