透明渐变反射 - VB.NET?

时间:2013-05-03 16:55:57

标签: vb.net bitmap alpha

我想知道如何添加倒置渐变反射,类似于:

iPhone Reflection

我会理论化,首先反映一个位图是颠倒的。然后,在Photoshop中,我会为图像添加一个alpha蒙版,其中包含从上到下的黑/白渐变。

如何在VB.NET中添加alpha蒙版/渐变组合?我似乎无法找到任何功能。

1 个答案:

答案 0 :(得分:0)

以下是使用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