diff --git a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java
index 51851f5901..caab8e4bd1 100644
--- a/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java
+++ b/megamek/src/megamek/client/ui/swing/tooltip/PilotToolTip.java
@@ -218,19 +218,23 @@ private static StringBuilder crewPortraits(final Entity entity, boolean showDefa
String img = "";
if (!report) {
- // Write the scaled portrait to file
- // This is done to avoid using HTML rescaling on the portrait which does
- // not do any smoothing and has extremely ugly results
- String tempPath = Configuration.imagesDir() + TEMP_DIR + PORTRAIT_PREFIX
+ try {
+ // Write the scaled portrait to file
+ // This is done to avoid using HTML rescaling on the portrait which does
+ // not do any smoothing and has extremely ugly results
+ String tempPath = Configuration.imagesDir() + TEMP_DIR + PORTRAIT_PREFIX
+ crew.getExternalIdAsString() + "_" + i + PNG_EXT;
- File tempFile = new File(tempPath);
- if (!tempFile.exists()) {
- BufferedImage bufferedImage = new BufferedImage(portrait.getWidth(null),
+ File tempFile = new File(tempPath);
+ if (!tempFile.exists()) {
+ BufferedImage bufferedImage = new BufferedImage(portrait.getWidth(null),
portrait.getHeight(null), BufferedImage.TYPE_INT_RGB);
- bufferedImage.getGraphics().drawImage(portrait, 0, 0, null);
- ImageIO.write(bufferedImage, "PNG", tempFile);
+ bufferedImage.getGraphics().drawImage(portrait, 0, 0, null);
+ ImageIO.write(bufferedImage, "PNG", tempFile);
+ }
+ img = "";
+ } catch (Exception e) {
+ // when an error occurs, do not display any image
}
- img = "";
} else {
// span crew tag replaced later in Client.receiveReport with crew portrait
img = UIUtil.tag("span", "crew='" + entity.getId() + ":" + i + "'", "");