Closed Gamebuster19901 closed 1 year ago
I'm leaning towards removing the registration system in this pr and just making a getInterpolation(int type)
method in AWTInterpolation
if users need to convert an int representing an JDK operation type into an interpolation type.
Oh wow, I've been working on this the past days too, documenting the entire Imaging class while I was at it. Was planning to push today 😅 My approach was more simplistic, only allowing to pass an int to the scaling method that represents one of the AffineTransformOp.TYPE_XXX values. Do you think that customized interpolations are really a requirement? I really respect the effort, but so far I'm not quite seeing the benefit for 99% of our users here. Also, I haven't tested your implementation yet. I'll raise a PR with my proposed changes for comparison and ping you when that's ready.
Oh wow, I've been working on this the past days too, documenting the entire Imaging class while I was at it. Was planning to push today sweat_smile My approach was more simplistic, only allowing to pass an int to the scaling method that represents one of the AffineTransformOp.TYPE_XXX values. Do you think that customized interpolations are really a requirement? I really respect the effort, but so far I'm not quite seeing the benefit for 99% of our users here. Also, I haven't tested your implementation yet. I'll raise a PR with my proposed changes for comparison and ping you when that's ready.
It's definitely something only for advanced users who either want to use custom interpolation, or want to use an interpolation from a library (such as that image scaling library you mentioned in #471 )
Just a note, I'm going to remove the registration system in this PR when I get off work, I don't see any benefits for it.
Thank you very much for the proposed changes! I've reviewed them now and come to the conclusion that your proposal introduces a level of complexity that most of our users will neither fully understand nor use. For now, I prefer the straightforward way of simply using overloads with AffineTransformOp
to scale images with interpolation. My implementation is now ready and will be pushed later for comparison. Sorry we've been working on this at the same time, that was an unlucky coincidence and I hope it doesn't discourage further help - we really appreciate your support!
PR goal:
Allow developers to use custom interpolation algorithms with LitiEngine's Imaging API. (Relates to #471)
The implementation:
This PR adds 3 default interpolations that are automatically bundled with the standard JDK,
NEAREST_NEIGHBOR
,BILINEAR
, andBICUBIC
. The result of these interpolations shall always be the exact same as their JDK counterparts, any deviation should be considered a bug.All methods in
/litiengine/util/Imaging
that perform affine transformations can now take an additional parameter that accepts anInterpolation
instance.Custom interpolation instances can be created by extending
Interpolation
and registering an instance of it by callingInterpolations.registerInterpolation()
AfflineTransformOperation
will need to be created by the developer in order to use a custom interpolation. An instance of their custom transform operation should be returned by their custom Interpolation (by overridingInterpolation.of(AfflineTransform)
)Caveats and issues this current implementation