Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ImportedProjects
SVG
Commits
4ba5243e
Commit
4ba5243e
authored
May 25, 2016
by
Tebjan Halm
Browse files
Merge pull request #233 from dittodhole/hotfix/image-data-uri
fixed SvgImage.GetImage
parents
3bb22f1e
0959752a
Changes
4
Show whitespace changes
Inline
Side-by-side
Source/Basic Shapes/SvgImage.cs
View file @
4ba5243e
...
@@ -234,9 +234,20 @@ namespace Svg
...
@@ -234,9 +234,20 @@ namespace Svg
protected
object
GetImage
(
string
uriString
)
protected
object
GetImage
(
string
uriString
)
{
{
string
safeUriString
;
if
(
uriString
.
Length
>
65519
)
{
safeUriString
=
uriString
.
Substring
(
0
,
65519
);
}
else
{
safeUriString
=
uriString
;
}
try
try
{
{
var
uri
=
new
Uri
(
u
riString
.
Substring
(
0
,
65519
)
);
//Uri MaxLength is 65519 (https://msdn.microsoft.com/en-us/library/z6c2z492.aspx)
var
uri
=
new
Uri
(
safeU
riString
);
//Uri MaxLength is 65519 (https://msdn.microsoft.com/en-us/library/z6c2z492.aspx)
// handle data/uri embedded images (http://en.wikipedia.org/wiki/Data_URI_scheme)
// handle data/uri embedded images (http://en.wikipedia.org/wiki/Data_URI_scheme)
if
(
uri
.
IsAbsoluteUri
&&
uri
.
Scheme
==
"data"
)
if
(
uri
.
IsAbsoluteUri
&&
uri
.
Scheme
==
"data"
)
...
...
Tests/Svg.UnitTests/Resources/hotfix-image-data-uri/Speedometer.svg
0 → 100644
View file @
4ba5243e
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"100%"
height=
"100%"
viewBox=
"0 0 452 440"
>
<g
id=
"SFixTitle"
/>
<g
id=
"SContent"
>
<g
transform=
"scale(1.33333)"
>
<g
transform=
"matrix(1,0,0,1,0,0)"
>
<g>
<defs>
<clipPath
id=
"CLIP0"
>
<path
d=
"M0,0 L339,0 L339,330 L0,330 Z "
/>
</clipPath>
</defs>
<g
clip-path=
"url(#CLIP0)"
>
<g
transform=
"matrix(1,0,0,1,0,0)"
>
<image
Id=
"Image1"
x=
"0"
y=
"0"
width=
"339"
height=
"330"
xlink:href=
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABh0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC45bDN+TgAAAPtJREFUKFMtjsFLhEAUh/1TO3YJOkYdg2DbXVqaZrNrBduiBuuhQ+jBNsXDBlI06jrm0EhsdYxu6vQz/fjN48374PE0pVTTNF0tZSmlrOsa3w4NU+AHwdw0w5UVPlkz01guH3uN54PA/vne+/iy3zeLz9/9h5XteV6rsep8SqW9xZKEizIX5WuSWvHByWQMpQkhDP04mh+yOImTFGFxeuXT0fUgy7JWL/ShmA3Wa57+B40eXR7djDjnWlVVU0o3O7sseuF5gTwzth0MJ+QUqj3Ndd07QsW9mxfirRBOHI6NCwz7y4HjOOSMmuYtQgjtHOg1wCrcAdD0I6X+AFY0+G5kPytUAAAAAElFTkSuQmCC"
/>
</g>
</g>
<g>
<path
d=
"M170.25,165.75 L225.007827759,88.731620789 L225.007827759,88.731620789 C226.193939209,89.574920654 227.360412598,90.445503235 228.506332397,91.342681885 Z "
stroke=
"none"
stroke-width=
"0"
fill=
"#C0504D"
fill-opacity=
"1"
transform=
"matrix(1,0,0,1,0,0)"
/>
</g>
<g
/>
<g
transform=
"matrix(1,0,0,1,0,0)"
>
<defs>
<clipPath
id=
"CLIP2"
>
<path
d=
"M153.75,240 L183.75,240 L183.75,261 L153.75,261 Z "
/>
</clipPath>
</defs>
<g
clip-path=
"url(#CLIP2)"
>
<g
transform=
"matrix(1,0,0,1,156.57810974,259.06246948)"
>
<text
x=
"0"
y=
"-2.9615624"
font-family=
"Impact"
font-size=
"14.03999996"
fill=
"#568ED4"
>
64%
</text>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
<defs
/>
</svg>
Tests/Svg.UnitTests/SmallEmbeddingImageTest.cs
0 → 100644
View file @
4ba5243e
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
namespace
Svg.UnitTests
{
/// <summary>
/// Test Class of rendering SVGs with a large embedded image
/// Based on Issue 225
/// </summary>
/// <remarks>
/// Test use the following embedded resources:
/// - Issue225_LargeUri\Speedometer.svg
/// </remarks>
[
TestClass
]
public
class
SmallEmbeddingImageTest
:
SvgTestHelper
{
protected
override
string
TestResource
{
get
{
return
this
.
GetFullResourceString
(
"hotfix_image_data_uri.Speedometer.svg"
);
}
}
protected
override
int
ExpectedSize
{
get
{
return
160000
;
}
}
[
TestMethod
]
public
void
TestImageIsRendered
()
{
this
.
LoadSvg
(
this
.
GetXMLDocFromResource
());
}
}
}
\ No newline at end of file
Tests/Svg.UnitTests/Svg.UnitTests.csproj
View file @
4ba5243e
...
@@ -61,6 +61,7 @@
...
@@ -61,6 +61,7 @@
<Compile
Include=
"MultiThreadingTest.cs"
/>
<Compile
Include=
"MultiThreadingTest.cs"
/>
<Compile
Include=
"PrivateFontsTests.cs"
/>
<Compile
Include=
"PrivateFontsTests.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"SmallEmbeddingImageTest.cs"
/>
<Compile
Include=
"SvgTestHelper.cs"
/>
<Compile
Include=
"SvgTestHelper.cs"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
@@ -85,6 +86,9 @@
...
@@ -85,6 +86,9 @@
<ItemGroup>
<ItemGroup>
<EmbeddedResource
Include=
"Resources\Issue225_LargeUri\Speedometer.svg"
/>
<EmbeddedResource
Include=
"Resources\Issue225_LargeUri\Speedometer.svg"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<EmbeddedResource
Include=
"Resources\hotfix-image-data-uri\Speedometer.svg"
/>
</ItemGroup>
<Import
Project=
"$(MSBuildBinPath)\Microsoft.CSharp.targets"
/>
<Import
Project=
"$(MSBuildBinPath)\Microsoft.CSharp.targets"
/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Other similar extension points exist, see Microsoft.Common.targets.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment