In this getting started video, we’ll use GcImaging on Mac 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 Mac

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 Mac.

Step 1: Create an empty console application

Create an app using Visual Studio on Mac

  1. Create any application in .NET Core, ASP.NET Core, .NET Framework, or any target that supports .NET Standard 2.0.
  2. In the tree view on the left, right-click Dependencies and choose Add Packages.
  3. From the top left dropdown, choose nuget.org
  4. In the Search panel, type GrapeCity.
  5. From the list of packages displayed in the left panel, select GrapeCity.Documents.Imaging and click Add Packages.
  6. Click Accept.

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!