Hallo!
Ich möchte Bilder mit unterschiedlicher Größüe überblenden.
Das funktioniert hiermit ganz gut:
Imports System.Drawing.Imaging
Public Class Form1
Private ActivePic As Bitmap = New Bitmap("C:\...\xxx.jpg") _
' 1920/1080 - 1.7777...
Private NextPic As Bitmap = New Bitmap("C:\...\yyy.JPG") _
' 561/637
Private PicBoxRect As Rectangle = New Rectangle(0, 0, 624, 351) _
' 624/351 - 1.7777...
Private Alpha As Single = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim bmp As New Bitmap(PicBox1.Width, PicBox1.Height)
PicBox1.Image = ActivePic _
' 1920/1080 - 1.7777...
PicBox1.DrawToBitmap(bmp, New Rectangle(0, 0, PicBox1.Width, _
PicBox1.Height))
ActivePic = New Bitmap(bmp)
PicBox1.Image = ActivePic _
' 1920/1080 - 1.7777...
PicBox2.Image = NextPic _
' 1920/1080 - 1.7777...
bmp = New Bitmap(PicBox2.Width, PicBox2.Height)
PicBox2.DrawToBitmap(bmp, New Rectangle(0, 0, PicBox2.Width, _
PicBox2.Height))
NextPic = New Bitmap(bmp)
bmp.Dispose()
End Sub
Private Sub BtnFade_Click(sender As Object, e As EventArgs) Handles _
BtnFade.Click ' Timer!!!
Alpha += 0.05
If Alpha >= 1.0 Then
BtnFade.Enabled = False
ActivePic = NextPic
PicBox1.Image = PicBox2.Image '
' sonst kleine Fehlstellen ?????????
End If
Call Fade(Alpha)
TB1.Text = Alpha
End Sub
Private Sub Fade(ByVal Alpha As Single)
Dim ColMat As New ColorMatrix With {.Matrix33 = Alpha} '
' Farbmatrix anlegen
Dim imgAtt As New ImageAttributes() '
' Bildattribute anlegen
imgAtt.SetColorMatrix(ColMat)
Dim bm As New Bitmap(PicBoxRect.Width, PicBoxRect.Height) '
' Buffer Zeichenoperationen 624/351
Dim g2 As Graphics = Graphics.FromImage(bm) '
' Graphics-Objekt für Buffer holen
' Bild deckend in Buffer zeichnen
g2.DrawImage(ActivePic, PicBoxRect)
' neues Bild transparent
' in Buffer zeichnen
g2.DrawImage(NextPic, PicBoxRect, 0, 0, NextPic.Size.Width, _
NextPic.Size.Height, GraphicsUnit.Pixel, imgAtt)
Dim g As Graphics = PicBox1.CreateGraphics '
' Ergebnis auf Picturbox ausgeben
g.DrawImage(bm, PicBoxRect)
g2.Dispose() '
' entsorgungen
imgAtt.Dispose()
bm.Dispose()
End Sub
End Class wie entstehen die Fehlstellen?
was kann man vereinfachen, verbessern? |