fromPixels static method

Texture2D fromPixels(
  1. Uint8List pixels,
  2. int width,
  3. int height, {
  4. TextureContent content = TextureContent.color,
  5. TextureSampling sampling = const TextureSampling(),
})

Builds a texture from RGBA8888 pixels (straight alpha, row-major) of width x height.

Implementation

static Texture2D fromPixels(
  Uint8List pixels,
  int width,
  int height, {
  TextureContent content = TextureContent.color,
  TextureSampling sampling = const TextureSampling(),
}) => Texture2D._(
  uploadMipLevels(
    sampling.mipmaps && mipChainsAreSampled
        ? generateMipChain(pixels, width, height, content)
        : <MipLevel>[MipLevel(width, height, pixels)],
    width,
    height,
    maxMipmapLevels: sampling.maxMipmapLevels,
  ),
  sampling.toSamplerOptions(),
);