In this getting started video, we’ll use GcImaging on Windows to create a company logo image with rounded rectangle.

 

First, visit this link to license GcImaging in your application: http://help.grapecity.com/gcdocs/gcimaging/onlinehelp/webframe.html#licenseinfo.html

How to get started with GcImaging on Windows

This guide explains how to create a program that uses Documents for Imaging (GcImaging) to generate and save to disk a company logo image. GcImaging API is built for .NET Standard 2.0, and can be used with any target that supports it. In this short tutorial, we show how to build a .NET Core console application and use GcImaging in Visual Studio for Windows.

Step 1: Create an empty console application

Create an app using Visual Studio on Windows

  1. Create any application (.NET Core, ASP.NET Core, .NET Framework - any target that supports .NET Standard 2.0).
  2. Right-click the project in Solution Explorer and choose Manage NuGet Packages.
  3. In the Package source on top right, choose nuget.org.
  4. Click the Browse tab on the top left and search for "Grapecity.Documents".
  5. On the left panel, choose GrapeCity.Documents.Imaging.
  6. On the right panel, click Install.
  7. Choose I Accept in the next screen.
  8. After the installation is complete, go to the NuGet folder under Dependencies in the solution explorer and confirm that the required packages have been added to your project.

Step 2: Add code to your application

Let’s create a new logo image for a company with GcImaging in .NET Core application. This example will draw a rounded rectangle and draw the company name text over it to generate a logo image.

  1. In the Program.cs file, include the following namespaces:
using System.IO;
using System.Drawing;
using GrapeCity.Documents.Drawing;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Imaging;
  1. Define the image parameters.
var blue = Color.FromArgb(46, 72, 132);
int pixelWidth = 350;
int pixelHeight = 100;
bool opaque = true;
float dpiX = 96;
float dpiY = 96;
float rx = 36, ry = 24;
float border = 4;
  1. Create a bitmap image object.
var bmp = new GcBitmap(pixelWidth, pixelHeight, opaque, dpiX, dpiY);
  1. Create graphics on the image.
var g = bmp.CreateGraphics(Color.Transparent); // PNG will preserve transparency
  1. Draw rounded Rectangle and fill it with desired color
var rEasy = new RectangleF(0, 0, pixelWidth, pixelHeight);
g.FillRoundRect(rEasy, rx, ry, Color.MediumPurple);
  1. Prepare the TextFormat object with text properties to add company name as text
var tf = new TextFormat()
{
          Font = Font.FromFile(Path.Combine("Resources", "Fonts", "times.ttf")),
          FontSize = 24,
          FontBold = true,
          ForeColor = Color.White
};

Note: To draw text with a Font from file, include a TTF font in the Resources folder in the project: Resources.zip

  1. Draw the text on the graphics.
g.DrawString("ACME INC.", tf, rEasy, TextAlignment.Center, ParagraphAlignment.Center, false);
  1. Save the image as PNG.
bmp.SaveAsPng("Logo.png");

Step 3: Run the application

Click the "start debugging" button in Visual Studio.

That's all it takes to generate an Image using GcImaging. The ‘Logo.png’ is created in your project folder.

In order to understand in detail, how to create/modify/save an Image with advanced features and effects, refer to the GcImaging sample demo.

Try GrapeCity Documents for Imaging 30-day trial

To learn about GcImaging product architecure and features in detail, visit the GcImaging documentation.

Try GrapeCity Documents for Imaging

Download the latest version of GrapeCity Documents for Imaging

Download Now!