As follows:Code, Put it in this place, and then you can view how to write such code .....
1: write on the image and set the background color
# Region tree node creation icon
/// <Summary>
/// Create a tree node icon
/// </Summary>
/// <Param name = "TXT"> </param>
/// <Param name = "txtcolor"> </param>
/// <Returns> </returns>
Private bitmap createnodeimg (string txt, color txtcolor)
{
If (txtcolor = color. Transparent)
Txtcolor = color. Black;
Bitmap newbitmap = new Bitmap (12, 14 );
Graphics G = graphics. fromimage (newbitmap );
If (txtcolor! = Color. Black)
{
G. Clear (txtcolor); // background color
}
G. textrenderinghint = system. Drawing. Text. textrenderinghint. antialias;
Fontfamily fm = new fontfamily ("Arial ");
Font font = new font (FM, 12, fontstyle. Regular, graphicsunit. pixel );
Solidbrush sb = new solidbrush (color. Black );
G. drawstring (txt, Font, Sb, new pointf (0, 0 ));
G. Dispose ();
Return newbitmap;
}
2. Merge Images
# Region merge Images
/// <Summary>
/// Merge Images
/// </Summary>
/// <Param name = "maps"> </param>
/// <Returns> </returns>
Private bitmap mergerimg (Params bitmap [] maps)
{
Int I = maps. length;
If (I = 0)
Throw new exception ("the number of images cannot be 0 ");
// Create an image object to be displayed and set the width based on the number of parameters
Bitmap backgroudimg = new Bitmap (I * 12, 16 );
Graphics G = graphics. fromimage (backgroudimg );
// Clear the canvas and set the background to white
G. Clear (system. Drawing. color. White );
For (Int J = 0; j <I; j ++)
{
G. drawimage (maps [J], J * 11, 0, maps [J]. Width, maps [J]. Height );
}
G. Dispose ();
Return backgroudimg;
}
# Endregion
# Region merge Images
/// <Summary>
/// Merge Images
/// </Summary>
/// <Param name = "bitmapdic"> </param>
/// <Returns> </returns>
Private bitmap mergerimg (Dictionary <string, bitmap> bitmapdic)
{
If (bitmapdic = NULL | bitmapdic. Count = 0)
Throw new exception ("the number of images cannot be 0 ");
// Create an image object to be displayed and set the width based on the number of parameters
Bitmap backgroudimg = new Bitmap (bitmapdic. Count * 12, 16 );
Graphics G = graphics. fromimage (backgroudimg );
// Clear the canvas and set the background to white
G. Clear (system. Drawing. color. White );
Int J = 0;
Foreach (keyvaluepair <string, bitmap> entry in bitmapdic)
{
Bitmap map = entry. value;
G. drawimage (MAP, J * 11, 0, map. Width, map. Height );
J ++;
}
G. Dispose ();
Return backgroudimg;
}
You can also merge images:
// Int I = maps. length;
// If (I = 0)
// Throw new exception ("the number of images cannot be 0 ");
//// Create the image object to be displayed and set the width based on the number of parameters
// Bitmap backgroudimg = new Bitmap (I * 16, 16 );
// Graphics G = graphics. fromimage (backgroudimg );
/// Clear the canvas and set the background to white
// G. Clear (system. Drawing. color. White );
// G. drawimageunscaled (maps [0], 0, 0 );
// G. drawimageunscaled (maps [1], maps [0]. Width, 0 );
// G. Dispose ();
// Return backgroudimg;