이미지의 크기를 조정하여 그림 상자 (64x64 픽셀)에 표시하려고합니다. 원본 이미지는 8x8 픽셀이지만 64x64 픽셀로 크기를 조정하면 흐리게 보입니다. 나는 왜, 모든 것이 비례적인지를 보지 못한다. 페인트를 사용하여 테스트 한 결과 이미지가 흐려지지 않고 크기가 조정되었으므로 왜 보이지 않습니다. 여기에 코드가 있습니다. 먼저 다른 이미지에서 이미지를 가져와야합니다. (화소의 확대를위한)크기를 조정할 때 이미지가 흐림
Public Function GetPicturePart(ByVal SourceImage As Bitmap, ByVal Region As Rectangle) As Bitmap
Dim ImagePart As Bitmap = New Bitmap(Region.Width, Region.Height)
Using G As Graphics = Graphics.FromImage(ImagePart)
Dim TargetRect As Rectangle = New Rectangle(0, 0, Region.Width, Region.Height)
Dim SourceRect As Rectangle = Region
G.DrawImage(SourceImage, TargetRect, SourceRect, GraphicsUnit.Pixel)
End Using
Return ImagePart
End Function
Private Function SizeImage(ByVal img As Bitmap, ByVal width As Integer, ByVal height As Integer) As Bitmap
Dim newBit As New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(newBit)
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
g.DrawImage(img, 0, 0, width, height)
Return newBit
End Function
Private Sub AssembleSkin(ByVal Image As Image, ByVal Head As PictureBox, ByVal Body As PictureBox, ByVal LeftArm As PictureBox, ByVal RightArm As PictureBox, ByVal RightLeg As PictureBox, ByVal LeftLeg As PictureBox)
Head.Image = SizeImage(GetPicturePart(My.Resources.james222, New Rectangle(New Point(8, 8), New Size(8, 8))), 64, 64)
End Sub
원본 크기가 64 픽셀이므로 크기를 조정할 때 4096 픽셀의 공간을 채워야하므로 당연히 흐릿합니다. – Plutonix
나는 본다. 어떻게 해결할 수 있을지에 대한 의구심이 있습니까? – user3163534