WHATWG spec allows users to pass cropping area while creating an ImageBitmap.
interface ImageBitmapFactories {
Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image);
Promise<ImageBitmap> createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh);
};
And for those pixels that are outside of the source image, fill them as transparent black. Spec.
If either sw or sh are negative, then the top-left corner of this rectangle will be to the left or above the (sx, sy) point. If any of the pixels on this rectangle are outside the area where the input bitmap was placed, then they will be transparent black in output.
This is reasonable since the ImageBitmap is used to be drawn onto canvas. However, we are now extending the ImageBitmap to be accessible in several kinds of format (via mapDataInto method) and some formats do not support alpha-channel (for example, YUV444P), so we are not able to return "transparent black" in these formats.
@ChiahungTai proposes that we should throw if users call mapDataInto on an ImageBitmap which was created with cropping area that is outside the original source image. With this error message, users should then create another ImageBitmap with a cropping area that is completely inside the source image.
@rocallahan, @anssiko and @smaug----, may I have your comments on this bug?
WHATWG spec allows users to pass cropping area while creating an
ImageBitmap
.And for those pixels that are outside of the source image, fill them as transparent black. Spec.
This is reasonable since the
ImageBitmap
is used to be drawn onto canvas. However, we are now extending theImageBitmap
to be accessible in several kinds of format (viamapDataInto
method) and some formats do not support alpha-channel (for example, YUV444P), so we are not able to return "transparent black" in these formats.@ChiahungTai proposes that we should throw if users call
mapDataInto
on anImageBitmap
which was created with cropping area that is outside the original source image. With this error message, users should then create anotherImageBitmap
with a cropping area that is completely inside the source image.@rocallahan, @anssiko and @smaug----, may I have your comments on this bug?