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
Solution design - Image formats #384
Comments
With Greenshot 1.3, I've rewritten most of the file output and input logic, using modularization it now is possible to easily add new file formats or improve the current ones. This investment, mostly done in #385, will pay out to for example feature request #347 What changed? I've added a new interface IFileFormatHandler, which will be used throughout Greenshot for handling many different file formats for different use-cases. All implementations are registered with a service provider during startup, when something is needed the best match is retrieved. So IFileFormatHandler describes the use-case, which provide:
There are extension methods available to provide the basic logic of getting the best fit, but also retrying the next when there is an issue. I also made a few implementations of IFileFormatHandler:
This doesn't cover webp, as was requested in #347. But it leaves the way open to add for example an ImageSharpFileFormatHandler which would bring:
And maybe more, it's a super interesting project. |
Besides having support for multiple new file formats, and better support for vector graphics in the editor, I've also added some additional logic which uses the new zoom in the editor to auto fit it when opening a file. Additionally adding files, by using draw & drop or copy & paste, to the editor will make sure these will fit better on the capture (before they might have been HUGE). |
Actually there is one more file format supported, that is the Greenshot templates (.gst). About the .greenshot file format, and .gst for that matter, this will be done via #375 |
Webp would be a great feature, perhaps it can be done as an optional plugin? If size is a concern we can choose not to install but for those of us that use webp daily, it would be fantastic to skip a conversion step |
It's trivial to repeat this request about WebP support. And the answer is probably still the same, since GDI+ built-in encoders and decodes still haven't changed (https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/using-image-encoders-and-decoders-in-managed-gdi?view=netframeworkdesktop-4.8) ? WebP is ideal for screenshots in emails and web pages. It will typically reduce the data size of emails by 50-100% or even more compared to JPG, so the need is very real. |
In Greenshot before 1.3 all the image loading and saving is done by using System.Drawing (part of Windows Forms) which is GDI+. This also restricts the possible file formats, and any shortcomings of the file formats that are supported.
On top of this, the code paths for those formats were very interwoven, that means that if we wanted to add a new format by adding a new dependency making this possible, that would need to be very integrated and those may cause issues or have limited support.
GDI+ has limited support, the following formats are supported by Greenshot in 1.2:
".png", ".bmp", ".gif", ".jpg", ".jpeg", ".tiff" (or ".tif") and finally ".ico".
The .ico format is enhanced by my own code, to help support a few more.
This is all documented here: https://docs.microsoft.com/en-us/dotnet/desktop/winforms/advanced/using-image-encoders-and-decoders-in-managed-gdi?view=netframeworkdesktop-4.8
The formats above can be opened from file, using the tray icon, or dragged / copied upon the drawing surface of the editor.
Additionally there is .greenshot, which is in fact a PNG with customer stuff appended to it.
The way that format works, is actually a big issue as for that format we just serialize .NET classes, causing compatibility issues when we change something.
WHAT, REALLY? You might ask, yes, we never really made a real defined file format, we just didn't get to it.
There are two additional formats, which someone were supported:
.emf & .wmf
These image files contain some sort of vector graphics, and you were able to use them like the other formats, BUT the image was rasterized (drawn to pixels) only once. So any advantages these formats would bring, was neglected.
In Greenshot 1.2 I added some basic SVG, as this was needed for JIRA icons. This is a vector graphics format, but the way it was implemented was similar to emf / wmf.
The text was updated successfully, but these errors were encountered: