Add simpler api for creating a dart:ui Image of a given width and height and by setting individual pixel values #148597
Labels
a: images
Loading, displaying, rendering images
c: new feature
Nothing broken; request for a new capability
engine
flutter/engine repository. See also e: labels.
r: solved
Issue is closed as solved
team-engine
Owned by Engine team
Use case
Currently in flutter there is not a convenient way to create an
Image
of a given width and height, and then set individual pixels on saidImage
before displaying it.Consider the following example program:
As far as I know, this is the only available api for this in flutter today. It is a bit awkward because you have to use a 1 dimensional array (
Int32List
), when conceptually anImage
is a 2 dimensional array. You want to be able to easily set the value of a pixel at a givenx
andy
coordinate. AlsodecodeImageFromPixels
feels a bit awkward as well, having to use aCompleter
to retrieve theImage
.You can compare this program to the same program written in many other languages and frameworks: https://rosettacode.org/wiki/Barnsley_fern. In many other languages there is a an api for this along the lines of
image = Image(width, height)
andimage.setPixel(x, y, color)
, for example theBufferedImage
in the Java example.There aren't any existing packages on pub.dev for this (as far as I can tell), It would be possible to write a package to help with this, but it seems like something that should be in the framework itself.
Proposal
If there was a class for this, lets say we call it
ImageBuffer
, it's usage might look like the following:The text was updated successfully, but these errors were encountered: