Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

Fix WMF and EMF being converted to PNG In ExcelPicture #490

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aesalazar
Copy link

-[] Write a detailed description of your what you have implemented or changed.

Currently, ExcelPicture uses ImageConverter to convert _image to bytes. The converter eventually will call Image.Save() as part of the process. This is a problem with vector-based images formats EMF and WMF. Since there is noImageFormat loaded from the GDI for those formats Image.Save() will fall back to using the PNG.

This PR proposes to change from ImageConverter to using the existing image stream and re-traversing in the two associated constructors. This will properly store the vector images. This is compatible with both .NET Legacy and .NET Core - no need for compile IF.

-[] Attach unit tests in the testproject to test implemented functionallity.

Seven (7) unit tests were added to the DrawingTests class for the image formats: png, bmp, jpg, gif, tif, emf, and wmf. They create a Package in memory and then extract the image using a ZipArchive to confirm the RawFormat. The EMF and WMF tests were red in the prior version and are now green.

-[] Make sure no tests fail in the test project.

All tests in DrawingTests pass. All but one test in the EEPlusTest library pass. The one test that fails has to do with Issue 333 which failed prior.

-[] Verify that you only check in the files intended for the pull request.

Several new test images were added to the project in order to test all of the above formats. Otherwise, it is only the ExcelPicture.cs that was changed.

-[] Do not change dotnet version, include new dependencies unless you explicitly talked to someone in the project about doing so.

The only project-level change was adding was to EPPlusTests:

<Reference Include="System.IO.Compression" />

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

Successfully merging this pull request may close these issues.

1 participant