convert<R> method

P convert<R>(
  1. R pixel, {
  2. required PixelFormat<R, void> from,
})

Converts a pixel from one another format to this format.

The default implementation of this method is to convert the pixel to either ABGR8888 or FLOAT_RGBA, and then convert it to this format; formats may override this method to provide more efficient conversions for popular conversions.

Implementation

P convert<R>(R pixel, {required PixelFormat<R, void> from}) {
  if (pixel is int) {
    return fromAbgr8888(from.toAbgr8888(pixel));
  }
  return fromFloatRgba(from.toFloatRgba(pixel));
}