ImageEn, unit iexHelperFunctions |
|
IEVectorizeImageToSVG
Declaration
procedure IEVectorizeImageToSVG(Bitmap: TIEBitmap;
const OutFilename: string;
ColorCount: Integer;
RemoveIsolatedPixels: Integer = 5;
BackgroundColor: TColor = -1;
StrokeOverlap: Double = 0.5;
PolygonSimplificationTolerance: Double = 0;
PointReductionRate: Double = 0;
PreviewResult: Boolean = False);
Description
Create an SVG file from a raster file by extracting all of the color polygons that it contains.
This method works best with small, simple images of few colors. Full color images will create huge SVG files.
Parameter | Description |
Bitmap | The image to output |
OutFilename | The full path to a destination file (should have a .svg extension) |
ColorCount | The number of colors to reduce the image to. Typical range is 2-32. Max value is 256. Less colors will create a smaller file |
RemoveIsolatedPixels | Removes any small areas of pixels that are isolated. The default value of 5 removes any blocks of color smaller than 5 pixels |
BackgroundColor | The background color of the image. If -1 is specified then it is calculated from the corners of the image. This value is used to create a rect of the background color to reduce the size of the file |
StrokeOverlap | If >0 a stroke is used to to prevent gaps between neighboring polygons due to anti-aliasing. Default is 0.5 |
PolygonSimplificationTolerance | If > 0 then vertices that contribute very little to a polygon's shape are removed (typical value: 1.3). It also reduces the size of the SVG file. This options should NOT be used if your image contains neighboring polygons (as gaps will appear) |
PointReductionRate | If > 0 then the number of points in the polygon will be removed to reduce the size of the SVG file, e.g. 0.5 will halve the number of points. This options should NOT be used if your image contains neighboring polygons (as gaps will appear) |
PreviewResult | If true, the SVG file is not created, only the image is shown with the following parameters applied: ColorCount, RemoveIsolatedPixels, BackgroundColor |
Note:
◼You must add the iexHelperFunctions unit to your uses clause
◼If the image contains an
AlphaChannel the created SVG will have a transparent background
◼You can convert an image to SVG using embedding with
IEConvertImageToSVG
| Demos\InputOutput\VectorizeToSVG\VectorizeToSVG.dpr |
// Convert an image to SVG
IEVectorizeImageToSVG( ImageEnView1.IEBitmap, 'D:\VectorizedImage.svg', 32 );
// Show a preview of the result
IEVectorizeImageToSVG( ImageEnView1.IEBitmap, '', 32, 5, -1, 0.5, 0, 0, TRUE );
// Convert a logo to PNG
IEVectorizeImageToSVG( ImageEnView1.IEBitmap, 'D:\CC.svg', 4, 7, -1, 0, 0.9, 0 );

Source File Size: 35 KB

SVG File Size: 11 KB