forked from External/mage
Load croped image from Wizard images. fixes display issue
When resizing image to fit the BigCard panel, scale it to fit width. The result is better.
This commit is contained in:
parent
f539d9d5ec
commit
1f72804968
11 changed files with 53 additions and 46 deletions
|
|
@ -49,6 +49,7 @@ import mage.client.components.arcane.UI;
|
|||
import mage.view.CardView;
|
||||
|
||||
import com.mortennobel.imagescaling.ResampleOp;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -168,6 +169,29 @@ public class ImageHelper {
|
|||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image scaled to fit width
|
||||
* panel
|
||||
*/
|
||||
public static BufferedImage getResizedImage(BufferedImage original, int width) {
|
||||
if (width != original.getWidth()) {
|
||||
double ratio = width / (double) original.getWidth();
|
||||
int height = (int) (original.getHeight() * ratio);
|
||||
return getResizedImage(original, width, height);
|
||||
} else {
|
||||
return original;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image scaled to the needed size
|
||||
*/
|
||||
public static BufferedImage getResizedImage(BufferedImage original, Rectangle sizeNeed) {
|
||||
ResampleOp resampleOp = new ResampleOp(sizeNeed.width, sizeNeed.height);
|
||||
BufferedImage image = resampleOp.filter(original, null);
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image using relative path in resources.
|
||||
* @param path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue