Skip to main content Skip to footer

What's New in Documents for Imaging v5

GcImaging v5.2 - August 17, 2022

New GcImaging.Skia library for enhanced drawing performance and quality

GcImaging introduces new package GrapeCity.Documents.Imaging.Skia library that represents a new rendering engine for drawing text and graphics with a faster performance and enhanced rendering quality across platforms. The library is based on Skia - an open source 2D graphics library which provides common APIs that work across a variety of hardware and software platforms. GcImaging.Skia includes three main classes: GcSkiaBitmapGcSkiaImage, and GcSkiaGraphics

There are several advantages about using GcImaging.Skia library. You can use this library in following scenarios -

  • For rendering large/complex images
  • For rendering text with the best possible fidelity (with font hinting and subpixel rendering).
  • When you do not need access to individual pixels, DPI other than 96, EXIF/ICC profiles support, effects (e.g. dithering).

Following snapshot shows a comparison of complex text rendered using GcSkiaBitmap and other tools. Notice text rendered using GcSkiaBitmap has better fidelity.

Have a look on following resources.

View Help | Demo

Support for WebP image format

Images play an important role on any website. However, the file formats you use will influence how your images appear on the page and how fast they load. WebP is a modern image file format to showcase high-quality images without affecting website performance. By using either lossy or lossless compression, WebP lets you retain the rich appearance of your images while simultaneously reaping the benefits of smaller file sizes. The GcBitmap class now supports loading and saving images in WebP format. All existing methods that load images - Image.FromFile/FromStream/FromBytes also now support WebPThe class also supports SaveAsWebp(..) method to save image in WebP format. The overload takes a number of parameters such as lossy/lossless format, compression quality etc.

Following code loads a WebP image and saves to PNG format using GcBitmap class. Also, the GcBitmap class loads a PNG image and saves it to WebP format.

// Converting a WEBP image to PNG format.
using var bmp = new GcBitmap("RoundClip.webp");
bmp.SaveAsPng("RoundClip.png");
  
// Converting a PNG image to WEBP format.
bmp.Load("RoundClip.png");
bmp.SaveAsWebp("RoundClip.webp", null, true, 0,6);

Image below shows PNG image converted to WebP image. The size of WebP image is smaller than PNG, and in addition is of similar quality. 

View Help | Demo 

Support SVG Text element (basic support)

SVG images can contain text fragments. GcImaging now supports 'text' and 'tspan' elements with a limited set of attributes to SVG images. These elements give you greater control over the text display and it's position. To support these elements, GcImaging adds SvgTextElement, SvgTSpanElement, SvgTextPathElement classes to its object model. You can add these elements through these classes, or, if they are present in SVG string, the SVG can simply be loaded into GcSvgDocument and GcImaging object model. 

Following code loads svg image with text and tspan elements, draws it on GcBitmapGraphics and saves as PNG image - 

// Load an SVG with text and tspan:
var svgString =
"<svg width='12cm' height='3cm' viewBox='0 0 1000 300' xmlns='http://www.w3.org/2000/svg' version='1.1'>" +
"  <g font-family='Verdana' font-size='64' >" +
"    <text x='160' y='180' fill='blue'>Apples are not <tspan font-weight='bold' fill='orange'>oranges</tspan>.</text>" +
"  </g>" +
"</svg>";
using var svg = GcSvgDocument.FromString(svgString);
  
// Render the SVG image and a border around it:
var bmp = new GcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi);
using var g = bmp.CreateGraphics(Color.White);
var pt = new PointF(dpi, dpi);
g.DrawSvg(svg, pt);
var sz = svg.GetIntrinsicSize(SvgLengthUnits.Pixels);
g.DrawRectangle(new RectangleF(pt, sz), Color.MediumPurple);
bmp.SaveAsPng("SVGText.png")

View Help | Demo

Read the release blog for full details.

 


 

GrapeCity Documents for Imaging v5.1 - April 22, 2022

GrapeCity Documents (GcDocs) is excited to announce the new v5.1 release!

Updates included in this release:

Save documents to SVG

Compared to raster image formats such as JPEG and PNG, SVG is a vector format that can be rendered at any size without loss of quality. This format gives designers and developers a lot of control over the image appearance. It is also a standardized format for web graphics, designed to work with other web conventions like HTML, CSS, JavaScript, and the Document Object Model. Due to the many advantages of SVG, it is essential to use SVG images in documents, such as PDF and images.

Read the release blog for full details.


 

GcImaging v5 - December 14, 2021

GrapeCity Documents for Imaging (GcImaging)

SVG Support

Compared to classic bitmapped image formats such as JPEG, PNG, SVG-format vector images can be rendered at any size without loss of quality. This format gives designers and developers a lot of control over the image appearance.

It is also a standardized format for web graphics, designed to work with other web conventions like HTML, CSS, JavaScript, and the Document Object Model. Due to the many advantages of SVG, it is essential to use SVG images in documents, such as PDF and images.

With the v5 release, we introduce a new GcSvgDocument class that can create, load, inspect, and modify the internal structure of an SVG image. You can also obtain an Image from a File or stream, or byte array and draw the SVG image to the GcPdfDocumentGcBitmap, or GcWicBitmap classes using the GcGraphics.DrawSvg method.

All SVG features (including access to SVG DOM) are fully available in both GcPdf and GcImaging.

The code below draws SVG files from a folder to a rectangle grid defined in PDF document.

 

// Render all images within the grid, adding new pages as needed:
            var g = doc.NewPage().Graphics;
            for (int i = 0; i < images.Count(); ++i)
            {
                    var rect = new RectangleF(ip, new SizeF(sWidth - gapx, sHeight - gapy));
                    g.FillRectangle(rect, Color.LightGray);
                    g.DrawRectangle(rect, Color.Black, 0.5f);
                    rect.Inflate(-sMargin, -sMargin);
            
                    var svg = images[i].Item2;
                    var s = svg.GetSize(SvgLengthUnits.Points);
                    if (s.Width > 0 && s.Height > 0)
                    {
                        // If image proportions are different from our target rectangle,
                        // we resize the rectangle centering the image in it:
                        var qSrc = s.Width / s.Height;
                        var qTgt = rect.Width / rect.Height;
                        if (qSrc < qTgt)
                        rect.Inflate(rect.Width * (qSrc / qTgt - 1) / 2, 0);
                        else if (qSrc > qTgt)
                        rect.Inflate(0, rect.Height * (qTgt / qSrc - 1) / 2);
                     }
                     // Render the SVG:
                     g.DrawSvg(images[i].Item2, rect);
            }

 

 

pdf

You can also perform additional operations with SVG images. Check out full demos in the sample browser.

Create SVG Images and Render to PDF Documents

Create a full SVG image and render it to a PDF document. Check out this demo that creates SVG images with geometrical shapes and renders them to a PDF document.

pdf

Access the SVG DOM

The GcSvgDocument class provides full access to the SVG Document Object Model. The following elements are currently supported: svg, g, defs, style, use, symbol, image, path, circle, ellipse, line, polygon, polyline, rect, clipPath, linearGradient, stop, title, metadata, desc, and more. Find more information below:

GcPDF Help | GcImaging Help | GcPdf Demo | GcImaging Demo

Check out the release notes for GcPdf and GcImaging.

Read the release blog for full details.

Select Product Version...