<< Click to Display Table of Contents >> Navigation: Programming > User Interface > Modify the look and feel of the editor > SVG Toolbar Icons > SVG methods of TWPImageList |
function LoadSVGFromStream( Stream : TStream; Compressed : Boolean ; ColCount, RowCount : Integer ) : Boolean;
This function creates an internal SVGRender class and loads the SVG data.
You need to provide the count of rows and columns of single glyphs the SVG image represents.
function LoadSVGFromResource( ResourceName : String; Compressed : Boolean; ColCount, RowCount : Integer ) : Boolean;
This works like LoadSVGFromStream but it locates the data from the application resources.
The resource can be compressed which reduces the data size and also a lot
Sample code to compress:
var mem,mem2 : TMemoryStream;
c : TZCompressionStream;
begin
mem := TMemoryStream.Create;
mem2 := TMemoryStream.Create;
mem.LoadFromFile( source_data_file );
mem.Position := 0;
c := TZCompressionStream.Create(mem2);
c.CopyFrom(mem, mem.Size);
c.Free;
mem2.SaveToFile( destinatein_data_file );
mem.Free;
mem2.Free;
To create a RES file which can be easily added to a project using {$R SOMENAME.RES} you need to create a RC file first, i.e. SOMENAME.RC
MYICONSNAME RCDATA MyIconsSVGFile.svg
and compile it using
brcc32.exe SOMENAME.RC
procedure SVGAddParamOverride( idname, param, value : string );
This method changes how certain elements in the SVG are rendered. All elements which use a id-name which start with the provided idname will use the parameter and the value provided here, i.e.
SVGAddParamOverride( 'car', 'fill', 'red' )
will make sure the object with id="car" will be filled in red instead of any color or shading the originally was selected.
Parameter names which make sense here
'fill', 'stroke', 'fill-opacity', 'stroke-opacity', 'line-width'
To clear the list of overrides call
SVGAddParamOverride( '', '', '' )
If you use our product WPSvgPRO more options can be used.