Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
Public Class Form1
Public Function InvertColors(ByVal Image As Image) As Image
Dim ImgAttr As New Imaging.ImageAttributes()
'Standard-ColorMatrix für Invertierung
Dim ColorMatrix As New Imaging.ColorMatrix(New Single()() {New Single() {-1, 0, 0, 0, 0}, New Single() {0, -1, 0, 0, 0}, New Single() {0, 0, -1, 0, 0}, New Single() {0, 0, 0, 1, 0}, New Single() {0, 0, 0, 0, 1}})
'ColorMatrix an ImageAttribute-Objekt übergeben
ImgAttr.SetColorMatrix(ColorMatrix)
'Neue 32bit Bitmap erstellen
Dim NewBitmap = New Bitmap(Image.Width, Image.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
'Resolution (DPI) vom Quellbitmap auf Zielbitmap übertragen
NewBitmap.SetResolution(Image.HorizontalResolution, Image.VerticalResolution)
'Graphicsobjekt von NewBitmap erstellen
Dim NewGraphics As Graphics = Graphics.FromImage(NewBitmap)
'NewBitmap auf NewGraphics zeichnen
NewGraphics.DrawImage(Image, New Rectangle(0, 0, NewBitmap.Width, NewBitmap.Height), 0, 0, Image.Width, Image.Height, GraphicsUnit.Pixel, ImgAttr)
'Ressource freigeben
NewGraphics.Dispose()
ImgAttr.Dispose()
Return NewBitmap
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image = InvertColors(PictureBox1.Image)
End Sub
End Class
Public Class Form1
Public Function InvertColors(ByVal Image As Image) As Image
Dim ImgAttr As New Imaging.ImageAttributes()
'Standard-ColorMatrix für Invertierung
Dim ColorMatrix As New Imaging.ColorMatrix(New Single()() {New Single() {-1, 0, 0, 0, 0}, New Single() {0, -1, 0, 0, 0}, New Single() {0, 0, -1, 0, 0}, New Single() {0, 0, 0, 1, 0}, New Single() {1, 1, 1, 1, 1}})
'ColorMatrix an ImageAttribute-Objekt übergeben
ImgAttr.SetColorMatrix(ColorMatrix)
'Neue 32bit Bitmap erstellen
Dim NewBitmap = New Bitmap(Image.Width, Image.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
'Resolution (DPI) vom Quellbitmap auf Zielbitmap übertragen
NewBitmap.SetResolution(Image.HorizontalResolution, Image.VerticalResolution)
'Graphicsobjekt von NewBitmap erstellen
Dim NewGraphics As Graphics = Graphics.FromImage(NewBitmap)
'NewBitmap auf NewGraphics zeichnen
NewGraphics.DrawImage(Image, New Rectangle(0, 0, NewBitmap.Width, NewBitmap.Height), 0, 0, Image.Width, Image.Height, GraphicsUnit.Pixel, ImgAttr)
'Ressource freigeben
NewGraphics.Dispose()
ImgAttr.Dispose()
Return NewBitmap
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image = InvertColors(PictureBox1.Image)
End Sub
End Class