低质量渲染旋转图像

时间:2018-03-10 13:59:44

标签: java swing graphics rotation jframe

我有import static org.mockito.Mockito.when; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; class Employee { public void getAddress() { Address add = new Address(); String a = add.addAddress(); System.out.println(a); } } class Address { public String addAddress() { return "Emp Address"; } } @RunWith(PowerMockRunner.class) @PrepareForTest(Employee.class) public class MockitoTest { @Mock Address add; @Test public void testEmployee() throws Exception { when(add.addAddress()).thenReturn("mocked address"); PowerMockito.whenNew(Address.class).withNoArguments().thenReturn(add); Employee e = new Employee(); e.getAddress(); } } ,并定期使用JFrame在屏幕上绘制PNG图像。图像按照鼠标指针旋转。 当图像旋转时,它的质量非常糟糕(在照片中)。

PNG是20x10像素。

Photo Quality

怎么办?

paintComponent

1 个答案:

答案 0 :(得分:0)

不确定它会有所帮助,但您可以尝试更改某些图形属性。例如:

g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);