There are many TPixel types in ImageSharp.
Conversion between types can be done currently as a "push" or a "pull":
Let s be a pixel from ANY TPixel type be the source and t be the pixel of ANY TPixel type target.
Then getting the corresponding color of s converted to the target format and stored in the variable t can be done in two different ways:
t.PackFromSource(s) s.ToTarget(ref t)
both do the same: they change the value of t to the converted value of s.
Wherever one of both is used now, this can be exchanged by the other one.
I propose to only keep the first for two reasons:
- less "special" syntax by not needing the ref keyword here.
- here
s is a parameter and the operation is done on t, which seems to be more obvious this way around when reading code.
For better compatibility there could even be a smooth transition between these two to keep existing code working:
All ToTarget(ref t) can be generated by using t.PackFromSource(this). Generating in partial classes still allows custom implementations of everything else. The generated methods could be marked as obsolete with a hint to use the other variant.