Этот код VB.Net будет
- Создать изображение формы,
- Добавить размытие к изображению
- Добавить изображение в поле для картинок
- Добавьте обработчик кликов, который удаляет картинку при нажатии.
- Добавьте коробку с картинками в форму и установите в качестве заносить
Единственное, что размытие довольно медленное.Так что я бы работал над этим.
Imports System.Drawing.Imaging
Public Class Form1
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
ShowBlurredPicture()
End Sub
Sub ShowBlurredPicture()
Dim blurredpic As Bitmap = gausianBlur(False, New Size(5, 5), GetFormPic)
Dim p As New PictureBox
p.Image = blurredpic
p.Location = New Point(-System.Windows.Forms.SystemInformation.FrameBorderSize.Width, -(System.Windows.Forms.SystemInformation.CaptionHeight + System.Windows.Forms.SystemInformation.FrameBorderSize.Height))
p.Size = New Size(Me.Size)
Me.Controls.Add(p)
p.Visible = True
p.BringToFront()
AddHandler p.Click, AddressOf picclick
End Sub
Sub picclick(ByVal sender As Object, ByVal e As System.EventArgs)
Me.Controls.Remove(sender)
End Sub
Function GetFormPic() As Bitmap
Dim ScreenSize As Size = Me.Size
Dim screenGrab As New Bitmap(Me.Width, Me.Height)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)
g.CopyFromScreen(Me.Location, New Point(0, 0), Me.Size)
Return screenGrab
End Function
Private Function Average(ByVal Size As Size, ByVal imageSize As SizeF, ByVal PixelX As Integer, ByVal Pixely As Integer, ByVal theimage As Bitmap) As Color
Dim pixels As New ArrayList
Dim x As Integer, y As Integer
Dim bmp As Bitmap = theimage.Clone
For x = PixelX - CInt(Size.Width / 2) To PixelX + CInt(Size.Width / 2)
For y = Pixely - CInt(Size.Height / 2) To Pixely + CInt(Size.Height / 2)
If (x > 0 And x < imageSize.Width) And (y > 0 And y < imageSize.Height) Then
pixels.Add(bmp.GetPixel(x, y))
End If
Next
Next
Dim thisColor As Color
Dim alpha As Integer = 0
Dim red As Integer = 0
Dim green As Integer = 0
Dim blue As Integer = 0
For Each thisColor In pixels
alpha += thisColor.A
red += thisColor.R
green += thisColor.G
blue += thisColor.B
Next
Return Color.FromArgb(alpha / pixels.Count, red / pixels.Count, green / pixels.Count, blue / pixels.Count)
End Function
Private Function gausianBlur(ByVal alphaEdgesOnly As Boolean, ByVal blurSize As Size, ByVal theimage As Bitmap) As Bitmap
Dim PixelY As Integer
Dim PixelX As Integer
Dim bmp As Bitmap = theimage.Clone
For PixelY = 0 To bmp.Width - 1
For PixelX = 0 To bmp.Height - 1
If Not alphaEdgesOnly Then ' Blur everything
bmp.SetPixel(PixelX, PixelY, Average(blurSize, bmp.PhysicalDimension, PixelX, PixelY, theimage))
ElseIf bmp.GetPixel(PixelX, PixelY).A <> 255 Then ' Alpha blur channel check
bmp.SetPixel(PixelX, PixelY, Average(blurSize, bmp.PhysicalDimension, PixelX, PixelY, theimage))
End If
Application.DoEvents()
Next
Next
Return bmp.Clone
bmp.Dispose()
End Function
End Class

Я нашел код для создания GasuianBlur здесь: http://www.codeproject.com/KB/GDI-plus/GausianBlur.aspx
И код для копированияФорма для растрового изображения здесь: http://www.daniweb.com/forums/thread94348.html