Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Image cause an System.NullReferenceException #16

Open
Markus1397 opened this issue Jan 30, 2018 · 12 comments
Open

Adding Image cause an System.NullReferenceException #16

Markus1397 opened this issue Jan 30, 2018 · 12 comments

Comments

@Markus1397
Copy link

When ever I try to add a Image my program always crash.
There is no difference if I use ImageSource or XImage and also if I use FromBinary,FromFile or FromStream. Everytime I get (nearly) the same Exception.
Object reference not set to an instance of an object.
In case of using ImageSource.FromBinary the next line is:

at MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes.ImageSource.FromBinary(String name, Func1 imageSource, Nullable1 quality)

Before opening the file I check if the file is existing with System.IO.File.Exists;
Im using .Net Core 2.0, with Visual Studio Community on Mac OS.

@groege
Copy link
Owner

groege commented Jan 30, 2018 via email

@Markus1397
Copy link
Author

Yes I did.
using(FileStream fs = info.OpenRead())
 {
 fs.Read(bytesOfImg,0,(int)info.Length);
 }
 IImageSource imgSource = ImageSource.FromBinary(info.Name,()=>bytesOfImg);

@groege
Copy link
Owner

groege commented Feb 6, 2018 via email

@groege
Copy link
Owner

groege commented Feb 6, 2018 via email

@groege
Copy link
Owner

groege commented Feb 6, 2018 via email

@gtaylor44
Copy link

Do you have implementations of ImageSourceImpl for each platform? Or is it up to us?

Default System.NullReferenceException is a bit confusing. Notes on setting font source impl are there but no documentation for image source impl.

@groege
Copy link
Owner

groege commented Feb 9, 2018 via email

@groege
Copy link
Owner

groege commented Feb 9, 2018 via email

@gtaylor44
Copy link

I just found this implementation in the repository, which works for my platform (.net core 2.0)

PdfSharpCore/PdfSharpCore.ImageSharp/ImageSharpImageSource.cs

@gtaylor44
Copy link

I'm using the latest ImageSharp library but I think it's still a bit buggy. Doesn't handle transparency very well when importing from png format.

@groege
Copy link
Owner

groege commented Feb 9, 2018 via email

@dobestar
Copy link

Hi, I am trying to do this on a .net core web app, how do I set the ImageSourceImpl so I can set ImageSource.FromFile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants