ImageByteFormat enum

The format in which image bytes should be returned when using Image.toByteData.

Inheritance

Constructors

ImageByteFormat()
const

Values

rawRgba → const ImageByteFormat

Raw RGBA format.

Unencoded bytes, in RGBA row-primary form with premultiplied alpha, 8 bits per channel.

rawStraightRgba → const ImageByteFormat

Raw straight RGBA format.

Unencoded bytes, in RGBA row-primary form with straight alpha, 8 bits per channel.

rawUnmodified → const ImageByteFormat

Raw unmodified format.

Unencoded bytes, in the image's existing format. For example, a grayscale image may use a single 8-bit channel for each pixel.

rawExtendedRgba128 → const ImageByteFormat

Raw extended range RGBA format.

Unencoded bytes, in RGBA row-primary form with straight alpha, 32 bit float (IEEE 754 binary32) per channel.

Example usage:

import 'dart:ui' as ui;
import 'dart:typed_data';

Future<Map<String, double>> getFirstPixel(ui.Image image) async {
  final ByteData data =
      (await image.toByteData(format: ui.ImageByteFormat.rawExtendedRgba128))!;
  final Float32List floats = Float32List.view(data.buffer);
  return <String, double>{
    'r': floats[0],
    'g': floats[1],
    'b': floats[2],
    'a': floats[3],
  };
}
png → const ImageByteFormat

PNG format.

A loss-less compression format for images. This format is well suited for images with hard edges, such as screenshots or sprites, and images with text. Transparency is supported. The PNG format supports images up to 2,147,483,647 pixels in either dimension, though in practice available memory provides a more immediate limitation on maximum image size.

PNG images normally use the .png file extension and the image/png MIME type.

See also:

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

values → const List<ImageByteFormat>
A constant List of the values in this enum, in order of their declaration.