Rank: Member
Groups: Guest
Joined: 1/12/2016(UTC) Posts: 23
Thanks: 8 times
|
Hello, When I'm converting any kind of image to svg and when I open the image, I get the following error: "error on line 1 at column 4934196: Extra content at the end of the document" code snippet: Code:
private static byte[] ConvertToSvg(byte[] bytes)
{
using (var imageReader = ImageReader.Create(new MemoryStream(bytes)))
using (var bitmap = imageReader.Frames[0].GetBitmap())
using (var exportedImageStream = new MemoryStream())
{
bitmap.Save(exportedImageStream, new SvgSettings());
return exportedImageStream.GetBuffer();
}
}
I'm using Graphics Mill v9.0.21 All my best, Bruno
Edited by user Thursday, January 5, 2017 8:49:42 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Hey, We confirm the problem (Aurigma Bug #0022944) and will fix it shortly. I will keep you informed of the status. |
Best regards, Fedor Skvortsov
|
|
|
|
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Here is a documentation of the MemoryStream.GetBuffer method: https://msdn.microsoft.c...o.memorystream.getbuffer MSDN wrote:Note that the buffer contains allocated bytes which might be unused. For example, if the string "test" is written into the MemoryStream object, the length of the buffer returned from GetBuffer is 256, not 4, with 252 bytes unused. To obtain only the data in the buffer, use the ToArray method; however, ToArray creates a copy of the data in memory. That's why you get null values in the SVG file and should use the MemoryStream.GetArray method to fix the problem: Corrected: Code:private static byte[] ConvertToSvg(byte[] bytes)
{
using (var imageReader = ImageReader.Create(new MemoryStream(bytes)))
using (var bitmap = imageReader.Frames[0].GetBitmap())
using (var exportedImageStream = new MemoryStream())
{
bitmap.Save(exportedImageStream, new SvgSettings());
return exportedImageStream.ToArray();
}
}
Edited by user Sunday, February 5, 2017 10:37:38 PM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.