w3c / mediacapture-worker

MediaStream with worker
Other
9 stars 12 forks source link

Call mapDataInto() on an ImageBitmap which was created with a cropping area that is outside of the source image. #43

Closed kakukogou closed 8 years ago

kakukogou commented 8 years ago

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?

rocallahan commented 8 years ago

That sounds reasonable

anssiko commented 8 years ago

LGTM. Submitted PR #44 (19f2fa3) to fix -- does this align with your thinking?

kakukogou commented 8 years ago

Thank you, Anssi, and yes, the PR matches the idea here.