190607 c1
- Add Pilz.Drawing.Drawing3D.OpenGLFactory - Fix small bugs in Pilz.UI.PaintingControl
This commit is contained in:
@@ -31,21 +31,33 @@ Public Class DefaultDrawMethodes
|
||||
Public Shared Sub DrawPicture(e As PaintingObjectPaintEventArgs)
|
||||
Dim obj As PaintingObject = e.PaintingObject
|
||||
Dim objImg As Image
|
||||
Dim objImgSize As Size
|
||||
Dim result As RectangleF
|
||||
Dim image As Bitmap
|
||||
Dim zoomf As SizeF
|
||||
Dim hasNoParent As Boolean = e.PaintingObject.Parent Is Nothing
|
||||
Dim syncObj As Object
|
||||
|
||||
SyncLock e.PaintingObject.Parent
|
||||
If hasNoParent Then
|
||||
zoomf = New SizeF(1, 1)
|
||||
Static newSyncObj As New Object
|
||||
syncObj = newSyncObj
|
||||
Else
|
||||
zoomf = e.PaintingObject.Parent.ZoomFactor
|
||||
syncObj = e.PaintingObject.Parent
|
||||
End If
|
||||
|
||||
SyncLock syncObj
|
||||
If obj?.Image Is Nothing Then Return
|
||||
objImg = obj.Image
|
||||
objImgSize = objImg.Size
|
||||
End SyncLock
|
||||
|
||||
image = obj.BufferedImage
|
||||
result = CalculateImageResolution(obj, objImg.Size)
|
||||
result = CalculateImageResolution(obj, objImgSize, zoomf)
|
||||
|
||||
If obj.ImageProperties.Rotate = 90 OrElse obj.ImageProperties.Rotate = 270 Then
|
||||
result = CalculateImageResolution(obj, New SizeF(objImg.Size.Height, objImg.Size.Width))
|
||||
Else
|
||||
result = result
|
||||
result = CalculateImageResolution(obj, New SizeF(objImgSize.Height, objImgSize.Width), zoomf)
|
||||
End If
|
||||
|
||||
If image Is Nothing Then
|
||||
@@ -71,7 +83,7 @@ Public Class DefaultDrawMethodes
|
||||
End If
|
||||
|
||||
If needRescaleImageBecauseRot Then
|
||||
result = CalculateImageResolution(obj, New SizeF(objImg.Size.Height, objImg.Size.Width))
|
||||
result = CalculateImageResolution(obj, New SizeF(objImgSize.Height, objImgSize.Width), zoomf)
|
||||
image = DrawToNewImage(image, result.Size)
|
||||
End If
|
||||
|
||||
@@ -79,12 +91,15 @@ Public Class DefaultDrawMethodes
|
||||
End If
|
||||
|
||||
If image IsNot Nothing Then
|
||||
e.Graphics.DrawImageUnscaled(image, New Rectangle(New Point(obj.Location.X + result.Location.X - e.Offset.X, obj.Location.Y + result.Location.Y - e.Offset.Y), result.Size.ToSize))
|
||||
SyncLock syncObj
|
||||
e.Graphics.DrawImageUnscaled(image, New Rectangle(New Point(obj.Location.X + result.Location.X - e.Offset.X, obj.Location.Y + result.Location.Y - e.Offset.Y), result.Size.ToSize))
|
||||
End SyncLock
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Shared Function DrawToNewImage(image As Bitmap, newSize As SizeF) As Bitmap
|
||||
Dim bmp As New Bitmap(CInt(newSize.Width), CInt(newSize.Height))
|
||||
Dim bmp As New Bitmap(CInt(If(newSize.Width < 0, newSize.Width * -1, newSize.Width)),
|
||||
CInt(If(newSize.Height < 0, newSize.Height * -1, newSize.Height)))
|
||||
Dim gimage As Graphics = Graphics.FromImage(bmp)
|
||||
gimage.SmoothingMode = SmoothingMode.HighQuality
|
||||
gimage.PixelOffsetMode = PixelOffsetMode.HighQuality
|
||||
@@ -103,10 +118,10 @@ Public Class DefaultDrawMethodes
|
||||
e.Graphics.DrawLine(p2, no, no + obj.Size)
|
||||
End Sub
|
||||
|
||||
Private Shared Function CalculateImageResolution(obj As PaintingObject, imageSize As SizeF) As RectangleF
|
||||
Private Shared Function CalculateImageResolution(obj As PaintingObject, imageSize As SizeF, zoom As SizeF) As RectangleF
|
||||
Dim result As New RectangleF
|
||||
Dim objrect As New RectangleF(obj.Location, obj.Size)
|
||||
Dim size As SizeF = imageSize
|
||||
Dim size As SizeF = New SizeF(imageSize.Width * zoom.Width, imageSize.Height * zoom.Height)
|
||||
Dim clientRectangle As RectangleF = objrect
|
||||
Dim val As Single = clientRectangle.Width / size.Width
|
||||
|
||||
|
||||
Reference in New Issue
Block a user