mxGraph
Public Member Functions | Protected Attributes | Properties
com.mxgraph.mxImageBundle Class Reference

Maps from keys to base64 encoded images or file locations. All values must be URLs or use the format data:image/format followed by a comma and the base64 encoded image data, eg. "data:image/gif,XYZ", where XYZ is the base64 encoded image data. More...

List of all members.

Public Member Functions

void PutImage (String key, String value)
 Adds the specified entry to the map.
String GetImage (String key)
 Returns the value for the given key.

Protected Attributes

Dictionary< String, String > images = new Dictionary<String, String>()
 Maps from keys to images.

Properties

Dictionary< String, String > Images [get]
 Returns the images.

Detailed Description

Maps from keys to base64 encoded images or file locations. All values must be URLs or use the format data:image/format followed by a comma and the base64 encoded image data, eg. "data:image/gif,XYZ", where XYZ is the base64 encoded image data.

To add a new image bundle to an existing graph, the following code is used:

mxImageBundle bundle = new mxImageBundle(); bundle.PutImage("myImage", "data:image/gif,R0lGODlhEAAQAMIGAAAAAICAAICAgP" + "//AOzp2O3r2////////yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQBCgAHACwAAAAA" + "EAAQAAADTXi63AowynnAMDfjPUDlnAAJhmeBFxAEloliKltWmiYCQvfVr6lBPB1ggxN1hi" + "laSSASFQpIV5HJBDyHpqK2ejVRm2AAgZCdmCGO9CIBADs="); graph.AddImageBundle(bundle);

The image can then be referenced in any cell style using image=myImage.

To convert a given Image to a base64 encoded String, the following code can be used:

MemoryStream ms = new System.IO.MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); byte[] data = ms.ToArray(); Console.WriteLine("base64="+Convert.ToBase64String(data));

The value is decoded in mxUtils.LoadImage. The keys for images are resolved and the short format above is converted to a data URI in mxGraph.postProcessCellStyle.


Member Function Documentation

String com.mxgraph.mxImageBundle.GetImage ( String  key) [inline]

Returns the value for the given key.

void com.mxgraph.mxImageBundle.PutImage ( String  key,
String  value 
) [inline]

Adds the specified entry to the map.


Member Data Documentation

Dictionary<String, String> com.mxgraph.mxImageBundle.images = new Dictionary<String, String>() [protected]

Maps from keys to images.


Property Documentation

Dictionary<String, String> com.mxgraph.mxImageBundle.Images [get]

Returns the images.


The documentation for this class was generated from the following file: