In-place color conversion in of ImageBitmaps |
||||
Issue descriptionIn codereview.chromium.org/2522693002 -> ImageBitmap.cpp -> applyColorSpaceConversion we draw the source image into a surface with destination color space and then take a snapshot from the surface to retrieve the color converted SkImage. Also we do the color conversion even if the color space of the source SkImage is the same as the destination color space. Instead, we like to have an in-place color conversion here and we also must ignore the call if the conversion is not needed. Resolving this problem probably needs in-place color correction support in Skia.
,
Nov 28 2016
SkColorSpaceXform supports in place color conversion. Ex: SkColorSpace* src, dst; void* buffer; int len; SkColorSpaceXform::ColorFormat dstFormat; SkColorSpaceXform::ColorFormat srcFormat; std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(src, dst); // Size of dstFormat pixel must equal size of srcFormat pixel xform->apply(dstFormat, buffer, srcFormat, buffer, len, kUnpremul_SkAlphaType); This will memcpy() in the case where color spaces are equal. Alternatively, you can use SkColorSpace::Equals(src, dst) to skip the xform altogether. I'm guessing that there is a complication I am missing? Dooes the client not have access to the pixels in the SkImage?
,
Nov 29 2016
Thanks for the update. I assume that you can send the same buffer to the SkColorSpaceXform for in-place conversion only if the SkColorTypeBytesPerPixel() is the same for both color spaces, right? The complexity here is that currently we only have a SkImage here and we cannot extract the source color space and color type from that. Is there a way to do that so we can directly use SkColorSpaceXform?
,
Nov 29 2016
> Thanks for the update. I assume that you can send the same buffer to the > SkColorSpaceXform for in-place conversion only if the > SkColorTypeBytesPerPixel() is the same for both color spaces, right? Yes, with the caveat that the xform takes a ColorFormat (not an SkColorType). > The complexity here is that currently we only have a SkImage here and we > cannot extract the source color space and color type from that. Is there a > way to do that so we can directly use SkColorSpaceXform? For some SkImages (ex: backed by SkPicture), it is a little strange to report a colorType/colorSpace. How was the SkImage created?
,
Nov 30 2016
The specific SkImage that I'm dealing with now comes from a call to createImageBitmap and is created by ImageDecoder. Anyway, I set this bug to won't fix as it isn't a valid bug.
,
Nov 27 2017
|
||||
►
Sign in to add a comment |
||||
Comment 1 by zakerinasab@chromium.org
, Nov 28 2016