Ok need your help again 
This is the drawing part of a layer:
Code:
Private OldTransform As New System.Drawing.Drawing2D.Matrix
Private OldSize As New Size(0, 0)
Public Sub Draw(ByRef g As Graphics)
If Me.Changed = True Then UpdateRegion(OldTransform, OldSize)
g.TranslateTransform(Me.PictureNode.CenterPoint.X + 400, Me.PictureNode.CenterPoint.Y + 300)
g.RotateTransform(Val(Me.PictureNode.RotateVariable.Value))
g.TranslateTransform((Me.PictureNode.Location.X + Val(Me.PosXHandler.Value)) - Me.PictureNode.CenterPoint.X - 400 + Me.PictureNode.Size.Width * 0.5, (Me.PictureNode.Location.Y + Val(Me.PosYHandler.Value)) - Me.PictureNode.CenterPoint.Y - 300 + Me.PictureNode.Size.Height * 0.5)
g.RotateTransform(Me.PictureNode.Rotation.Value)
g.TranslateTransform(Me.PictureNode.Size.Width * -0.5, Me.PictureNode.Size.Height * -0.5)
'drawing and updating
g.DrawImage(PictureNode.SizedImage, New Rectangle(0, 0, PictureNode.SizedImage.Width, PictureNode.SizedImage.Height), 0, 0, PictureNode.SizedImage.Width, PictureNode.SizedImage.Height, GraphicsUnit.Pixel, Color.ToImageAttribute)
OldTransform = g.Transform
OldSize = Me.PictureNode.Size.Value
If Me.Changed = True Then UpdateRegion(OldTransform, OldSize)
Me.Changed = False
End Sub
UpdateRegion sub:
Code:
Public Sub UpdateRegion(ByVal Tdata As System.Drawing.Drawing2D.Matrix, ByVal Size As Size)
Dim r As New System.Drawing.Region(New Rectangle(New Point(0, 0), Size))
r.Transform(Tdata)
Form1.MainScreen.Invalidate(r)
End Sub
When I move the image of this layer around, the edges deform/are cut off. As example, I move a square 200 x 200 image to the right and on the left and right part of the image disappears. Moving up/down and the top and lower part deform.
Why is part of the image being cut-off when I move the image around and how can I stop it from happening?
Note: it doesn't happens when I invalidate the entire screen, but I can't use that (lag)
Now I read your posts (that were on a different page I haven't read
), is it because I am invalidating <inside> the onpaint sub?
EDIT
Wow that is one mistake I'll never make again.
it was checking for changed nodes using the onpaint sub, but when it did find something changed it invalidated it, causing a new onpaint. This onpaint gave a different type of region, causing some very weird bugs like this.