This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
bma  
#1 Posted : Thursday, January 5, 2017 8:48:38 AM(UTC)
bma

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

error.PNG

Edited by user Thursday, January 5, 2017 8:49:42 AM(UTC)  | Reason: Not specified

Fedor  
#2 Posted : Thursday, January 5, 2017 9:58:39 PM(UTC)
Fedor

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

Fedor  
#3 Posted : Sunday, February 5, 2017 10:36:40 PM(UTC)
Fedor

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

Users browsing this topic
Guest
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.