![](/img/trans.png)
[英]How to get the display/visual image size (not the actual image size) in JSOUP?
[英]Get the size of the drawn image, not the actual one
在我的游戲中,我使用g2d.scale(scale, scale);
縮放Graphics2D對象g2d.scale(scale, scale);
使游戲在所有分辨率下看起來都一樣 問題在於圖像將無法正確旋轉,因為它們被視為比實際大小更大或更小的圖像。 我想知道是否有一種方法可以獲取繪制圖像的寬度和高度而不是實際圖像,或者是否必須根據屏幕的分辨率手動更改寬度和高度變量?
看一下下面的功能。
public void picture(File pictureFile) {
Image theImage = null;
try {
theImage = getToolkit().getImage(pictureFile.getAbsolutePath());
getToolkit().prepareImage(theImage, -1, -1, this);
while ((getToolkit().checkImage(theImage, -1, -1, this) & this.ALLBITS) == 0) {
}
} catch (Exception e) {
}
// these lines will return Height and Width of image
theImage.getWidth(this);
theImage.getHeight(this);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.