Skip to content

Commit

Permalink
Fix #263
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol authored and nicol committed Jan 12, 2024
1 parent f32fa05 commit 2a54ab2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,7 @@ protected ImageIcon doInBackground() throws Exception {
@Override
protected void done() {
try {
if(get().getIconHeight()>369)
lblThumbnail.setIcon(ImageTools.resize(get(),266,369));
else
lblThumbnail.setIcon(get());
lblThumbnail.setIcon(ImageTools.resize(get(),MTGControler.getInstance().getPictureProviderDimension()));
}
catch(InterruptedException ex)
{
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/org/magic/services/tools/ImageTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public static void initGraphics(Graphics2D g2d)
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);

}

public static BufferedImage resize( Image img, int newH, int newW) {

if(img==null)
Expand Down Expand Up @@ -348,6 +348,11 @@ public static ImageIcon resize(Icon icon, int newH, int newW) {
return new ImageIcon(ic);
}

public static ImageIcon resize(Icon icon, Dimension d) {
var ic = ((ImageIcon)icon).getImage().getScaledInstance((int)d.getHeight(), (int)d.getWidth(), Image.SCALE_SMOOTH);
return new ImageIcon(ic);
}


public static BufferedImage readBase64(String base) throws IOException
{
Expand Down

0 comments on commit 2a54ab2

Please sign in to comment.