[Webkit-unassigned] [Bug 49365] [chromium] Add canvas.toDataURL("image/jpeg", quality) support

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 1 23:34:17 PST 2010


https://bugs.webkit.org/show_bug.cgi?id=49365





--- Comment #15 from noel gordon <noel.gordon at gmail.com>  2010-12-01 23:34:17 PST ---
(In reply to comment #8)
> (From update of attachment 74360 [details])
> Thanks for taking this on!

more too it than I expected :)

> View in context: https://bugs.webkit.org/attachment.cgi?id=74360&action=review
> 
> > WebCore/ChangeLog:16
> > +        alpha channel when extracting an "image/jpeg".toDataURL().  The correct answer
> > +        needs more investigation.
> 
> I don't know if it helps for this particular test, but some of the canvas/philip tests require a different unpremultiply that the one implemented in SkUnPreMultiply, in order to achieve roundtrip lossless conversion on a certain set of colours.  See http://trac.webkit.org/changeset/71760, function mulDiv255Ceil() in ImageBufferSkia.cpp.  The test was canvas/philip/tests/2d.imageData.put.unchanged.html.  If this does fix the problem, it would be
ideal if you could upstream this function to Skia.

So mulDiv255Ceil() appears to premultiply, yes?  In my case, I'm doing the opposite -- I must unpremultiply much like getImageData().  I note that
getImageData() uses color-component * 255 / alpha to unpremultiply RGB values.  I believe SkUnPreMultiply does exactly that using a lookup table to
avoid integer division.  Please check, because I wondered why getImageData() uses an integer divide.

The test I mentioned, canvas/philip/tests/toDataURL.jpeg.alpha.html, suggests we should not unpremultiply at all, and instead ignore the alpha
channel and JPEG encode the premultiplied RGB.  Firefox and Safari unpremultiply first and JPEG encode the unpremultiplied RGB.  Don't know who's
right here, I asked ian to clarify the spec - http://www.w3.org/Bugs/Public/show_bug.cgi?id=11431


> > WebCore/platform/image-encoders/skia/JPGImageEncoder.cpp:107
> > +            SkColor unmultiplied = SkUnPreMultiply::PMColorToColor(*pixel++);
> 
> See above:  check if mulDiv255Ceil() fixes the JPEG+alpha case.

see above.

> > WebCore/platform/image-encoders/skia/JPGImageEncoder.cpp:117
> > +        out->m_buffer.resize(8192);
> 
> This magic value should be in a constant.

done.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list