fixed images looking bad
This commit is contained in:
parent
b4176d0dfa
commit
da67278e7f
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2018 <@Seil0>
|
* Copyright 2016-2018 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -845,7 +845,7 @@ public class MainWindowController {
|
||||||
vlcNotInstalled = getBundle().getString("vlcNotInstalled");
|
vlcNotInstalled = getBundle().getString("vlcNotInstalled");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO rework to material design
|
// TODO remove after #19 has landed
|
||||||
public void showErrorMsg(String msg, Exception exception) {
|
public void showErrorMsg(String msg, Exception exception) {
|
||||||
Alert alert = new Alert(AlertType.ERROR);
|
Alert alert = new Alert(AlertType.ERROR);
|
||||||
alert.setTitle("Error");
|
alert.setTitle("Error");
|
||||||
|
|
|
@ -1,6 +1,27 @@
|
||||||
|
/**
|
||||||
|
* Project-HomeFlix
|
||||||
|
*
|
||||||
|
* Copyright 2018 <@Seil0>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
package kellerkinder.HomeFlix.controller;
|
package kellerkinder.HomeFlix.controller;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -82,10 +103,8 @@ public class OMDbAPIController implements Runnable {
|
||||||
//resize the image to fit in the posterImageView and add it to the cache
|
//resize the image to fit in the posterImageView and add it to the cache
|
||||||
try {
|
try {
|
||||||
BufferedImage originalImage = ImageIO.read(new URL(responseString[18])); //change path to where file is located
|
BufferedImage originalImage = ImageIO.read(new URL(responseString[18])); //change path to where file is located
|
||||||
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
|
|
||||||
BufferedImage resizeImagePNG = resizeImage(originalImage, type, 198, 297);
|
|
||||||
posterPath = main.getPosterCache() + "/" + mainWindowController.getTitle() + ".png";
|
posterPath = main.getPosterCache() + "/" + mainWindowController.getTitle() + ".png";
|
||||||
ImageIO.write(resizeImagePNG, "png", new File(posterPath));
|
ImageIO.write(originalImage, "png", new File(posterPath));
|
||||||
LOGGER.info("adding poster to cache: "+posterPath);
|
LOGGER.info("adding poster to cache: "+posterPath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error(e);
|
LOGGER.error(e);
|
||||||
|
@ -104,21 +123,4 @@ public class OMDbAPIController implements Runnable {
|
||||||
dbController.readCache(mainWindowController.getStreamUrl());
|
dbController.readCache(mainWindowController.getStreamUrl());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* resize a image
|
|
||||||
* @param originalImage is the original image
|
|
||||||
* @param type of the original image
|
|
||||||
* @param IMG_WIDTH width to resize
|
|
||||||
* @param IMG_HEIGHT heigth to resize
|
|
||||||
* @return resized image
|
|
||||||
*/
|
|
||||||
private static BufferedImage resizeImage(BufferedImage originalImage, int type, int IMG_WIDTH, int IMG_HEIGHT) {
|
|
||||||
BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
|
|
||||||
Graphics2D g = resizedImage.createGraphics();
|
|
||||||
g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
|
|
||||||
g.dispose();
|
|
||||||
|
|
||||||
return resizedImage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue