小编Gan*_*mme的帖子

如何在Java中旋转非正方形图像?

我最近看到这个问题,就如何在Java中旋转图像。我直接从该答案中复制/粘贴了它。在实现时,似乎只旋转正方形的图像(即具有相同的大小,宽度和高度)。当我尝试将其用于非正方形图像时,如果可以的话,似乎会切断将其变成矩形的部分。像这样

我该如何解决/解决这个问题?

编辑:我正在使用的代码。另外,我不会有滚动条,因为这将是“游戏”,也不会一直处于全屏状态。

public class Player extends Entity { //Entity has basic values such as (float) x & y values, along with some getters and setters
   double theta;    

   Reticle reticle; //draws a reticle where the cursor was(basically just replaces java.awt.Cursor due to something not neccessary for me to get into)
   Sprite currentImage; //basically just a BufferedImage that you can apply aspect ratios to

   //constructor

   @Override
   public void tick() {
      //(this line) gets the Reticle from the main-method class …
Run Code Online (Sandbox Code Playgroud)

java

4
推荐指数
1
解决办法
1203
查看次数

标签 统计

java ×1