Rank: Newbie
Groups: Guest
Joined: 1/15/2008(UTC) Posts: 4
|
Hi, I am looking for a solution of the following. We have an image where we want to create rounded edges. These edges must be transparant. Therefore I see two possible solutions: 1) Draw an polygoon and fill that with transparancy 2) Use a sort of mask to lay above the image. For that last method I have added see these example. The problem is that for both methods I am not sure they are possible, because the edges must be transparant. Have you an example for the way this can be done? And may be there is another solution? Kind regards, Eelze Eelze attached the following image(s):
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 1/15/2008(UTC) Posts: 4
|
Has someone an suggestion?
|
|
|
|
Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
You may consider using the MaskTransform feature. Put black color in the mask picture on where you would like it to be transparent, while white color on the area you would prefer to keep the image. Hope this will help. Code: Dim UserImage As New Aurigma.GraphicsMill.Bitmap(Image)
Dim MaskImage As New Aurigma.GraphicsMill.Bitmap(Image2)
Dim resultImage As New Aurigma.GraphicsMill.Bitmap(UserImage.Width, UserImage.Height, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb)
MaskImage.ColorManagement.Convert(PixelFormat.Format8bppGrayScale)
Dim rf As New RectangleF(0, 0, UserImage.Width, UserImage.Height)
Using combiner As New Combiner(UserImage, rf, rf, CombineMode.Copy, 1, InterpolationMode.HighSpeed)
combiner.ApplyMaskTransform(resultImage, MaskImage, BitmapViewerMainView.Bitmap)
End Using
Edited by user Thursday, January 17, 2008 7:00:44 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 Eelse, Here is another small code sample: Code://
// Loading source image.
//
Aurigma.GraphicsMill.Bitmap image =
new Aurigma.GraphicsMill.Bitmap("x:/allformats/24bppRgb.jpg");
//
// In your case you will load mask from some external source.
// Just for demonstration I'll create it by myself here:
//
Aurigma.GraphicsMill.Bitmap mask = new Aurigma.GraphicsMill.Bitmap(
image.Width,
image.Height,
Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);
using (System.Drawing.Graphics g = mask.GetGdiplusGraphics())
g.FillEllipse(
System.Drawing.Brushes.White,
0,
0,
mask.Width,
mask.Height);
//
// Now we should just add alpha channel and assign mask into it.
// Please note, that mask should have the same dimensions, as image and
// it should be 8bppGrayscale.
//
mask.ColorManagement.Convert(
Aurigma.GraphicsMill.PixelFormat.Format8bppGrayScale);
image.Channels.AddAlpha(0);
image.Channels[Aurigma.GraphicsMill.ColorChannel.Alpha] = mask;
// Thats all, saving the result.
image.Save("y:/maskedImage.png");
|
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 1/15/2008(UTC) Posts: 4
|
Both thanks for you reaction. @undead80. Replacing a color in an alpha-channel is not useable for me, because there is a chance that in the result also transparancy is added inside the elipse. @alex. With the solution you suggested, the edges (outside the elips) will not become transparent. Do I see that right?
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Hello, Hm... Are you sure? I've checked the result in Adobe Photoshop - it had transparency. Edited by user Thursday, January 17, 2008 4:39:11 PM(UTC)
| Reason: Not specified |
|
|
|
|
Rank: Newbie
Groups: Guest
Joined: 1/15/2008(UTC) Posts: 4
|
@Alex I have tested it, and it works great! When I use an image as mask, it also work fine. Thanks for your input! Kind regards, Eelze
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
|
|
|
|
|
Rank: Member
Groups: Guest
Joined: 1/7/2008(UTC) Posts: 28
|
Cool... But is there any way to check if the photo already having an alpha channel? As image.Channels.AddAlpha(0); <- this line will get into error if the image already having an alpha channel. Please advice.
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 1/31/2005(UTC) Posts: 458
Was thanked: 5 time(s) in 5 post(s)
|
Aurigma.GraphicsMill.Bitmap.HasAlpha?... |
|
|
|
|
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.