Hi,
I’m looking for a way to show a picture (PNG or JPEG) in a circle. I suspect one has to use a mask. Anyone to point me in a direction?
Thanks.
Hi,
I’m looking for a way to show a picture (PNG or JPEG) in a circle. I suspect one has to use a mask. Anyone to point me in a direction?
Thanks.
If you’re Picture has an alpha channel first draw it to a masked Picture. Then create the mask like this (white is transparent, black is opaque)
[code] dim mg As Graphics = pic.Mask.Graphics
mg.ForeColor = &cFFFFFF
mg.FillRect(0, 0, mg.Width, mg.Height)
mg.ForeColor = &c000000
mg.FillOval(0, 0, mg.Width, mg.Height)[/code]
This modifies Picture pic to have an oval mask.
Thanks,
will try this.
This sounds like a fail for alpha channel?
I wonder if there is some way to directly amend the alphachannel to make all but the circle part transparent?
Pixel allows changing the alpha part. But a mask is far easier in this example.
Will,
I have created a mask in Photoshop. How do I write the pricture to the mask?
[quote=238289:@Alexander van der Linden]Will,
I have created a mask in Photoshop. How do I write the pricture to the mask?[/quote]
Edit: found out already. Thanks.
Maybe others would like to know how to too?
Actually I brain farted last night and there is a way with Alpha Pictures: ApplyMask.
If your alpha channel Pic is fully opaque you can do it like this
[code] dim m As new Picture(pic.Width, pic.Height, 32) //masked pics start all white
m.Graphics.ForeColor = &c000000
m.Graphics.FillOval(0, 0, m.Width, m.Height)
pic.ApplyMask(m)[/code]
If Pic has alpha info that you need to preserve it takes a bit more noodling. Create a picture that will only draw white outside the circle region, then copy the mask, draw the white outside to that and apply back.
[code] //create a white picture with transparent hole
dim wout As new Picture(pic.Width, pic.Height, 32)
wout.Mask.Graphics.ForeColor = &cFFFFFF
wout.Mask.Graphics.FillOval(0, 0, wout.Width, wout.Height)
//get pics mask and draw the white outside
dim m As Picture = pic.CopyMask
m.Graphics.DrawPicture(wout, 0, 0)
//apply mask back to alpha
pic.ApplyMask(m)[/code]