【发布时间】:2013-04-28 03:52:30
【问题描述】:
我想知道如何添加倒置渐变反射,类似于:
我会首先推测将位图倒置。然后,在 Photoshop 中,我会为图像添加一个 alpha 蒙版,从上到下的黑色/白色渐变。
如何在 VB.NET 中添加 alpha 蒙版/渐变组合?我似乎找不到任何功能。
【问题讨论】:
-
是的,但是如何使用渐变?
我想知道如何添加倒置渐变反射,类似于:
我会首先推测将位图倒置。然后,在 Photoshop 中,我会为图像添加一个 alpha 蒙版,从上到下的黑色/白色渐变。
如何在 VB.NET 中添加 alpha 蒙版/渐变组合?我似乎找不到任何功能。
【问题讨论】:
这是使用Bitmaps的一种方式
Dim bm_src1 As Bitmap = CType(pb1.Image.Clone, Bitmap)
Dim bm_out As New Bitmap(bm_src1.Width, bm_src1.Height)
Using gr As Graphics = Graphics.FromImage(bm_out)
'Flip image
gr.TranslateTransform(CSng(bm_src1.Width / 2), CSng(bm_src1.Height / 2))
gr.RotateTransform(180)
gr.TranslateTransform(-CSng(bm_src1.Width / 2), -CSng(bm_src1.Height / 2))
' Give the images alpha gradients.
Dim alpha As Integer
For x As Integer = 0 To bm_src1.Width - 1
For y As Integer = 0 To bm_src1.Height - 1
alpha = (255 * y) \ bm_src1.Height
Dim clr As Color = bm_src1.GetPixel(x, y)
clr = Color.FromArgb(alpha, clr.R, clr.G, clr.B)
bm_src1.SetPixel(x, y, clr)
Next
Next
' Draw the images onto the result.
gr.DrawImage(bm_src1, 0, 0)
End Using
' Display the result.
pbResult.Image = bm_out 'picturebox output
【讨论】: