Originally, the library only has a Decode function that would always return an *image.NRGBA. This is a minor inconvenience, as some other functions (such as libjpeg's) can only do RGBA or other image types.
As a fix for the above inconvenience, a DecodeDraw function was added:
Originally, the library only has a
Decode
function that would always return an*image.NRGBA
. This is a minor inconvenience, as some other functions (such aslibjpeg
's) can only doRGBA
or other image types.As a fix for the above inconvenience, a
DecodeDraw
function was added:This function decodes the given hash and punch (which is now float64 for granularity) and draws the decoded image onto the given
draw.Image
.The older
Decode
function now callsDecodeDraw
internally on an*image.NRGBA
. This ensures that the API isn't broken.Benchmarks
After the changes, with
Decode
now callingDecodeDraw
:Before the changes:
Note: the performance is roughly the same, as the compiler is probably smart enough to know and inline the function call.