src/main/java/com/mxgraph/util/mxUtils.java
public static BufferedImage loadImage(String url)
	{
		BufferedImage img = null;

		if (url != null)
		{
			// Parses data URIs of the form data:image/format;base64,xxx
			if (url.startsWith("data:image/"))
			{
				try
				{
					int comma = url.indexOf(',');
					byte[] data = mxBase64.decode(url.substring(comma + 1));
					ByteArrayInputStream is = new ByteArrayInputStream(data);
					img = ImageIO.read(is);
				}
				catch (Exception e)
				{
					log.log(Level.SEVERE, "Failed to load a data URI image", e);
				}
			}
			else
			{
				URL realUrl = null;

				try
				{
					realUrl = new URL(url);
				}
				catch (Exception e)
				{
					realUrl = mxUtils.class.getResource(url);
				}

				if (realUrl != null)
				{
					try
					{
						img = ImageIO.read(realUrl);
					}
					catch (Exception e1)
					{
						log.log(Level.SEVERE, "Failed to read the image from " + realUrl, e1);
					}
				}
				else
				{
					log.log(Level.SEVERE, "Failed to load image from " + url);
				}
			}
		}

		return img;
	}
/**
	 * Loads an image from the local filesystem, a data URI or any other URL.
	 */
Loads an image from the local filesystem, a data URI or any other URL.
Loads an image from the local filesystem a data URI or any other URL .
public static BufferedImage loadImage(String url)
	{
		BufferedImage img = null;
		if (url != null)
		{
			if (url.startsWith("data:image/"))
			{
				try
				{
					int comma = url.indexOf(',');
					byte[] data = mxBase64.decode(url.substring(comma + 1));
					ByteArrayInputStream is = new ByteArrayInputStream(data);
					img = ImageIO.read(is);
				}
				catch (Exception e)
				{
					log.log(Level.SEVERE, "Failed to load a data URI image", e);
				}
			}
			else
			{
				URL realUrl = null;
				try
				{
					realUrl = new URL(url);
				}
				catch (Exception e)
				{
					realUrl = mxUtils.class.getResource(url);
				}
				if (realUrl != null)
				{
					try
					{
						img = ImageIO.read(realUrl);
					}
					catch (Exception e1)
					{
						log.log(Level.SEVERE, "Failed to read the image from " + realUrl, e1);
					}
				}
				else
				{
					log.log(Level.SEVERE, "Failed to load image from " + url);
				}
			}
		}
		return img;
	}
public static BufferedImage loadImage ( String url ) { BufferedImage img = null ; if ( url != null ) { if ( url . startsWith ( "data:image/" ) ) { try { int comma = url . indexOf ( ',' ) ; byte [ ] data = mxBase64 . decode ( url . substring ( comma + 1 ) ) ; ByteArrayInputStream is = new ByteArrayInputStream ( data ) ; img = ImageIO . read ( is ) ; } catch ( Exception e ) { log . log ( Level . SEVERE , "Failed to load a data URI image" , e ) ; } } else { URL realUrl = null ; try { realUrl = new URL ( url ) ; } catch ( Exception e ) { realUrl = mxUtils . class . getResource ( url ) ; } if ( realUrl != null ) { try { img = ImageIO . read ( realUrl ) ; } catch ( Exception e1 ) { log . log ( Level . SEVERE , "Failed to read the image from " + realUrl , e1 ) ; } } else { log . log ( Level . SEVERE , "Failed to load image from " + url ) ; } } } return img ; }
Loads an image from the local filesystem, a data URI or any other URL.
Loads an image from the local filesystem a data URI or any other URL .
// Parses data URIs of the form data:image/format;base64,xxx