-
-
Notifications
You must be signed in to change notification settings - Fork 854
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
Expose ImageProcessor internals to unblock externalizing ImageSharp.Drawing #967
Comments
I feel we should also take the opportunity to remove the passing of a |
@tocsoft Yeah, I had a good dig through the code there and I don't think there's any reason why we cannot do that. |
Been looking at the open PR regarding this and we need to fix up the way we use the term |
@tocsoft @JimBobSquarePants I had a deeper look at the source, now I'm unsure whether this is the right thing to do. In my understanding the majority of the processors actually do honor I think we could even generalize this logic, and introduce class ImageFrameArea<T>
{
public ImageFrame<T> Frame { get; }
public Rectangle Rectangle { get; }
public Span<T> GetPixelRowSpan(int y); // gets the subspan inside the area.
// y = 0 is at row Rectangle.Top
// etc.
} Am I missing an important point? Are there other exceptions? |
Added an update to the issue description. |
@antonfirsov having had a good dig through via refactoring I tend to agree. We can handle that once I finish implementing IDisposable |
Just pushed a PR to clean up the way we were implementing |
I've started working on exposing the pixel blenders. The lack of method documentation is a chore though! |
Great news! I will be available for reviews in the next days. |
These APIs are basically the last two methods I think we should expose. They're not currently used in Drawing but I think would be very useful elsewhere. I'm definitely going to rename anything **Helper to **Utils for the sake of my sanity anyway.
|
I think we can close this since ImageSharp.Drawing is now in an external repository with no internal access. |
Plans to externalize SixLabors.ImageSharp.Drawing
The main library, SixLabors.ImageSharp almost reached Release Candidate quality, however we realized, that it will take much more time to bring SixLabors.ImageSharp.Drawing and it's base libraries SixLabors.Shapes and SixLabors.Fonts to the same level.
In order to unblock the release of ImageSharp, we decided to externalize SixLabors.ImageSharp.Drawing. It shall be:
We are afraid that Drawing, Shapes, Fonts will reach RC status only after the 1.0 release of the main library.
Blockers
Unfortunately, externalizing ImageSharp.Drawing is not a trivial job, since it depends on certain internals of the main library by using
[InternalsVisibleTo(...)]
, namely:Buffer2D<T>
ImageProcessor<T>
PixelBlender<T>
andPixelOperations<T>.GetPixelBlender(...)
IImageVisitor
andImage.AcceptVisitor(...)
ParallelExecutionSettings
,configuration.GetParallelSettings()
andParallelHelper
These issues are actually well-known to anyone trying to implement Image Processors, and complaining about classes being internal. (Hi there @Sergio0694 😄!) This turns the issue of ImageSharp.Drawing into an API-cleanup problem.
Suggested solution
Buffer2D<T>
with a minimal subset of public methods. KeepMemorySource<T>
hidden. Consider reintroducingIBuffer2D<T>
.ImageProcessor<T>
but consider refactoring the "processor application" logic. See follow-up explanation.PixelBlender<T>
andPixelOperations<T>.GetPixelBlender(...)
IImageVisitor
to theAdvanced
subnamespace, exposeIImageVisitor
andImage.AcceptVisitor(...)
Proposal to refactor current ImageProcessor logic
IQuantizer
is a good example for the interaction and lifecycle rules of non-generic (pixel agnostic) objects and their generic (pixel-specific) counterparts:I think we should fully adapt this pattern for Image Processors:
constructor logic:BeforeImageApply
should be replaced withIImageProcessor.CreatePixelSpecificProcessor()
should takeImage<T>
and aRectangle
which is then passed toImageProcessor<T>
constructor, initialization and resource allocation could be done here.AfterImageApply
should be replaced withDispose()
(to clean up temporary resources)Image<T>
,SourceRectangle
andConfiguration
can be membersIImageProcessor<TPixel>.Apply()
should be non-parametric. Consider renaming it toExecute()
UPDATE: I no longer think that constructor/
Dispose
are replacements forBefore/After ImageApply
. Those should exist side-by side.UPDATE 2:
Further, "nice to have" points
SourceRectangle
(and maybeTargetRectangle
) behavior. See: commentsIImageProcessor
vsICloningImageProcessor
behavior. Expose(I)CloningImageProcessor
UPDATE 3:
PixelOperations<T>.To/FromVector4(...)
(nice to have, currently not used by Drawing)To avoid a longer delay, I'm fine if we can't address them within the current API cleanup process, since these are no trivial topics.
The text was updated successfully, but these errors were encountered: