diff options
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java index 6a4c0e8..2bf04a4 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -1263,27 +1263,6 @@ public class ImageLoader } /** - * Loads an image from a given bytes array. - * @param imageBytes The bytes array to load the image from. - * @return The image for the given bytes array. - */ - public static Image getBytesInImage(byte[] imageBytes) - { - Image image = null; - try - { - image = ImageIO.read( - new ByteArrayInputStream(imageBytes)); - - } - catch (Exception e) - { - logger.error("Failed to convert bytes to image.", e); - } - return image; - } - - /** * Returns the URI corresponding to the image with the given image * identifier. * @@ -1326,13 +1305,13 @@ public class ImageLoader Image statusImage; if (presence != null) { - statusImage = ImageLoader.getBytesInImage( + statusImage = GuiUtils.getBytesInImage( presence.getPresenceStatus().getStatusIcon()); } else { statusImage - = ImageLoader.getBytesInImage(pps.getProtocolIcon().getIcon( + = GuiUtils.getBytesInImage(pps.getProtocolIcon().getIcon( ProtocolIcon.ICON_SIZE_16x16)); if (!pps.isRegistered()) @@ -1430,4 +1409,34 @@ public class ImageLoader { loadedImages.clear(); } + + /** + * Returns the icon corresponding to the given <tt>protocolProvider</tt>. + * + * @param protocolProvider the <tt>ProtocolProviderService</tt>, which icon + * we're looking for + * @return the icon to show on the authentication window + */ + public static ImageIcon getAuthenticationWindowIcon( + ProtocolProviderService protocolProvider) + { + Image image = null; + + if(protocolProvider != null) + { + ProtocolIcon protocolIcon = protocolProvider.getProtocolIcon(); + + if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_64x64)) + image = GuiUtils.getBytesInImage( + protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_64x64)); + else if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_48x48)) + image = GuiUtils.getBytesInImage( + protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_48x48)); + } + + if (image != null) + return new ImageIcon(image); + + return null; + } } |