2013-05-03 116 views
0

我想知道如何去增加一个上下颠倒梯度反射,与此类似:透明渐变反射 - VB.NET?

iPhone Reflection

我会推论第一反射的位图是颠倒了。然后,在Photoshop中,我会为图像添加一个alpha蒙版,并使用黑色/白色渐变的顶部到底部。

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

+1

Alpha混合... – matzone 2013-05-03 16:58:10

+0

是一种方式,但我要如何做到这一点的渐变? – yttrium 2013-05-03 17:02:01

回答

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 
+0

当我在PictureBox中查看此图像时,它具有黑色背景。有什么办法解决这个问题吗? 另外,我怎样才能使它产生的新反射位图只有原始高度的1/3,所以它反映了src的底部三分之一? – yttrium 2013-05-06 14:13:25

+0

这个问题的后半部分没有关系。 有什么方法可以提高性能?对于大型位图而言,每像素绘制速度令人难以置信。 – yttrium 2013-05-06 14:28:00

+0

提前制作图像,然后只显示它们,如果您不需要它们的动态。 – OneFineDay 2013-05-06 17:04:48