Skip to content

Set colorspace of raw bitmaps using ImageDescriptor.raw #173889

@mertalev

Description

@mertalev

Use case

When creating a ui.Image in the following way:

final buffer = await ImmutableBuffer.fromUint8List(data);
final descriptor = ui.ImageDescriptor.raw(
  buffer,
  width: actualWidth,
  height: actualHeight,
  pixelFormat: ui.PixelFormat.rgba8888,
);
final codec = await descriptor.instantiateCodec();
final frame = await codec.getNextFrame();
return frame.image;

The bitmap is assumed to be sRGB with seemingly no way to make Flutter consider it as Display P3. This is an unfortunate limitation as it means there is no way to pass a raw bitmap from platform to Dart without having it interpreted as sRGB.

Proposal

It would be great to have a colorSpace option so that one could describe the image like such:

final descriptor = ui.ImageDescriptor.raw(
  buffer,
  width: actualWidth,
  height: actualHeight,
  pixelFormat: ui.PixelFormat.rgba8888,
  colorSpace: ColorSpace.displayP3,
);

I have never worked with Flutter internals before, but I may be able to contribute this feature with some guidance on how this could be implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: imagesLoading, displaying, rendering imagesc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterengineflutter/engine repository. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.team-engineOwned by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions