Skip to content

Commit

Permalink
Removed ASP.NET dependency of SVG.NET library.
Browse files Browse the repository at this point in the history
  • Loading branch information
otuncelli committed Aug 1, 2021
1 parent a4121a7 commit a69ddd3
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 158 deletions.
Binary file not shown.
Binary file added LibrariesWithoutASPNETDependency/net461/Svg.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SVG elements can be rendered as a flat image file or each on a separate layer.

The plugin is a tiny wrapper around the [SVG.NET Library](https://github.com/vvvv/SVG) which does the actual SVG reading.

Tested on paint.net 4.2.13.
Tested on paint.net 4.2.16 stable & 4.3 alpha (4.300.7881.3082) releases.

To install the plugin perform the following steps:
* Put the DLL in the `<Paint.NET>\FileTypes` directory (default location is `C:\Program Files\paint.net\FileTypes`)
Expand Down
4 changes: 2 additions & 2 deletions SvgFileType.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
# Visual Studio Version 16
VisualStudioVersion = 16.0.31424.327
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgFileTypePlugin", "SvgFileType\SvgFileTypePlugin.csproj", "{C32235C8-90B3-4C43-B589-B821C84839E9}"
EndProject
Expand Down
8 changes: 8 additions & 0 deletions SvgFileType/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura CreateTemporaryAssemblies="false" ExcludeRuntimeAssemblies="true" IncludeDebugSymbols="false" PreloadOrder="Fizzler|Svg">
<IncludeAssemblies>
Svg
Fizzler
</IncludeAssemblies>
</Costura>
</Weavers>
141 changes: 141 additions & 0 deletions SvgFileType/FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
13 changes: 9 additions & 4 deletions SvgFileType/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SvgFileType")]
[assembly: AssemblyTitle("SVG (Scalable Vector Graphics) Import Plug-in for Paint.NET")]
[assembly: AssemblyDescription("SVG (Scalable Vector Graphics) Import Plug-in for Paint.NET")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SvgFileType")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
#if NETCORE
[assembly: SupportedOSPlatform("windows")]
#endif

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
Expand All @@ -31,5 +35,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion(SvgFileTypePlugin.SvgFileType.Version)]
[assembly: AssemblyFileVersion(SvgFileTypePlugin.SvgFileType.Version)]
[assembly: AssemblyInformationalVersion(SvgFileTypePlugin.SvgFileType.Version)]
24 changes: 13 additions & 11 deletions SvgFileType/SvgFileType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ namespace SvgFileTypePlugin
{
public class SvgFileType : FileType
{
// https://forums.getpaint.net/topic/117086-scalable-vector-graphics-filetype-alternative-plugin-svg-svgz

public const string Version = "1.0.3";

public SvgFileType() : base("Scalable Vector Graphics",
new FileTypeOptions
{
Expand All @@ -23,10 +27,11 @@ public SvgFileType() : base("Scalable Vector Graphics",
{
}

private const string WindowTitle = "SVG Import Plug-in v1.0.2";
private const string WindowTitle = "SVG Import Plug-in v" + Version;

// Don't change this text! It's used by a PSD import plugin to keep Photoshop's folder structure.
// https://forums.getpaint.net/topic/113742-photoshop-psd-file-plugin-with-layers-support/

public const string LayerGroupBegin = "Layer Group: {0}";
public const string LayerGroupEnd = "End Layer Group: {0}";

Expand Down Expand Up @@ -274,7 +279,7 @@ private void AfterImport(Task p)
{
if (p.Exception.InnerExceptions.Any(exception => exception is OutOfMemoryException))
{
dialog.Invoke((Action) (() =>
dialog.Invoke((MethodInvoker) (() =>
{
MessageBoxEx.Show(dialog, "Not enough memory to complete this operation.",
"Out of Memory", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand All @@ -283,7 +288,7 @@ private void AfterImport(Task p)
else
{
var innerExpection = p.Exception?.InnerException?.Message;
dialog.Invoke((Action) (() =>
dialog.Invoke((MethodInvoker) (() =>
{
MessageBoxEx.Show(dialog, p.Exception.Message + "\r\nMessage: " + innerExpection,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand All @@ -302,13 +307,12 @@ private void AfterImport(Task p)

#region Render Elements

private static int GetLayerCountToRender(IReadOnlyCollection<SvgVisualElement> elements,
bool importHiddenLayers)
private static int GetLayerCountToRender(IReadOnlyCollection<SvgVisualElement> elements, bool importHiddenLayers)
{
return importHiddenLayers ? elements.Count : elements.Count(IsVisibleOriginally);
}

private Document RenderElements(IReadOnlyCollection<SvgVisualElement> elements, bool setOpacityForLayer,
private Document RenderElements(IReadOnlyCollection<SvgVisualElement> elements, bool setOpacityForLayer,
bool importHiddenLayers, Action<int> progress, CancellationToken token)
{
// I had problems to render each element directly while parent transformation can affect child.
Expand Down Expand Up @@ -390,8 +394,7 @@ private Document RenderElements(IReadOnlyCollection<SvgVisualElement> elements,
return pdnDocument;
}

private void RenderElement(SvgElement element, bool setOpacityForLayer,
bool importHiddenLayers)
private void RenderElement(SvgElement element, bool setOpacityForLayer, bool importHiddenLayers)
{
float opacity = element.Opacity;
var visible = true;
Expand Down Expand Up @@ -501,7 +504,7 @@ private static string GetLayerTitle(SvgElement element, int maxLength = 32)
{
// Get child title tag
SvgTitle title = element.Children.OfType<SvgTitle>().FirstOrDefault();
if (title != null && !string.IsNullOrEmpty(title.Content))
if (!String.IsNullOrEmpty(title?.Content))
{
layerName = title.Content;
}
Expand Down Expand Up @@ -542,8 +545,7 @@ private static string GetLayerTitle(SvgElement element, int maxLength = 32)
return layerName == null ? elementName : String.Join(": ", elementName, layerName);
}

private static IEnumerable<SvgElement> PrepareFlatElements(SvgElementCollection collection,
string groupName = null)
private static IEnumerable<SvgElement> PrepareFlatElements(SvgElementCollection collection, string groupName = null)
{
if (collection == null)
{
Expand Down
Loading

0 comments on commit a69ddd3

Please sign in to comment.