[]
The following quick start sections help you in getting started with the DsImaging library:
This quick start covers how to create an image and draw string on it in a specified font using a .NET Core or .NET Standard application. Follow the steps below to get started:
Create a new application (.NET Core Console App\Windows Forms App) and add the references.
Include the following namespaces
using GrapeCity.Documents.Imaging;
Create a new image using an instance of GcBitmap class, through code.
//Create GcBitmap
var bmp = new GcBitmap(1024, 1024, true, 96, 96);
//Create a graphics for drawing
GcBitmapGraphics g = bmp.CreateGraphics();
Add the following code to draw a rectangle using the RectangleF class, and then add text to it using the DrawString method of GcBitmapGraphics class.
//Add a radial gradient
RadialGradientBrush r= new RadialGradientBrush(Color.Beige,
Color.RosyBrown, new PointF(0.5f, 0.5f), true);
//Draw a rectangle
var rc = new RectangleF(0, 0, bmp.Width, bmp.Height);
//Fill the rectangle using specified brush
g.FillRectangle(rc, r);
// Create a text format for the "Hello World!" string:
TextFormat tf = new TextFormat();
//Pick a font size, color and style
tf.FontSize = 80;
tf.FontStyle = FontStyle.BoldItalic;
tf.ForeColor = Color.Chocolate;
//Draw the string (text)
g.DrawString("Hello World!", tf, rc, TextAlignment.Center,
ParagraphAlignment.Center, false);
Save the image using SaveAsJpeg method of the GcBitmap class.
//Save bitmap as JPEG image
bmp.SaveAsJpeg("HelloWorld.jpg");
This quick start covers how to load an existing image, modify and save it using a .NET Core or .NET Standard application. Follow the steps below to get started:
Create a new application (.NET Core Console App\Windows Forms App) and add the references.
Include the following namespace
using GrapeCity.Documents.Imaging;
Load an existing image using Load method of the GcBitmap class.
//Create GcBitmap
var bmp = new GcBitmap();
var fs = new FileStream(Path.Combine("puffins-small.jpg"), FileMode.Open, FileAccess.ReadWrite);
//Load image
bmp.Load(fs);
Add the following code that to add a text using the DrawString method of GcBitmapGraphics class to draw string.
//Create a graphics for drawing
GcBitmapGraphics g = bmp.CreateGraphics();
// Create a text format for the string:
TextFormat tf = new TextFormat();
// Pick a font size, color and style
tf.FontSize = 10;
tf.ForeColor = Color.Red;
tf.FontStyle = FontStyle.BoldItalic;
//Draw the string (text)
g.DrawString("Penguins", tf, new PointF(10, 10));
Save the image using SaveAsJpeg method of the GcBitmap class.
//Save bitmap
bmp.SaveAsJpeg("NewImage.jpg");