Closed
Bug 823243
Opened 13 years ago
Closed 13 years ago
PNG decoding is not precise
Categories
(Firefox :: Untriaged, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: vik.nuckchady, Unassigned)
Details
Attachments
(6 files, 1 obsolete file)
User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
Build ID: 20121128204232
Steps to reproduce:
I created a PNG image file and loaded it in a <Canvas> for pixels processing. The values RGBA channels for a given pixel in the <Canvas> are slightly different to the corresponding pixel in the actual image file. The fact that <Canvas> slightly modifies the pixels makes Firefox an unstable platform for my web application. For comparison, IE10 behaves correctly while Chrome (Version 23.0.1271.97 m) behaves just like Firefox (ver 17.0.1). I did not test on other firefox versions.
Actual results:
When i open the image file in an editor and examine say the 1st pixel, i get the RGBA values of 0, 13, 48, 254. When i look at that corresponding pixel (i.e. pixel at 'coordinate' (0,0)) i obtain the values 0, 12, 47, 254. As you can notice the Green and Blue channel deviate from the true color by 1.
Expected results:
Well in case of correct behavior, the RGBA channels of the pixels in the canvas should be exactly equal to the one in the image file
Comment 1•13 years ago
|
||
Please attach a testcase.
Comment 2•13 years ago
|
||
Have you turned off antialiasing? see mozImageSmoothingEnabled in https://developer.mozilla.org/en-US/docs/DOM/CanvasRenderingContext2D#Gecko-specific_attributes
Comment 3•13 years ago
|
||
PNG uses a unpremultiplied alpha while canvas 2D uses a premultiplied one. It's inevitable that the exact RGB values are lost for pixels whose alpha values are not 255 as long as you use canvas 2D.
WebGL has an unpremultiplied alpha mode. Is it reproducible with WebGL? (Contrary to the impression, WebGL is also usable for 2D graphics.)
| Reporter | ||
Comment 4•13 years ago
|
||
| Reporter | ||
Comment 5•13 years ago
|
||
| Reporter | ||
Comment 6•13 years ago
|
||
| Reporter | ||
Comment 7•13 years ago
|
||
| Reporter | ||
Comment 8•13 years ago
|
||
| Reporter | ||
Comment 9•13 years ago
|
||
| Reporter | ||
Comment 10•13 years ago
|
||
(In reply to Matthias Versen (Matti) from comment #1)
> Please attach a testcase.
Thanks Matti for your reply. I have attached to the report a test case (test code + data. Ref: attachment 694242 [details] and 694243). There are also additional attachment with screenshots demonstrating the problem in FF and the correct behavior in IE.
| Reporter | ||
Comment 11•13 years ago
|
||
(In reply to Robert Longson from comment #2)
> Have you turned off antialiasing? see mozImageSmoothingEnabled in
> https://developer.mozilla.org/en-US/docs/DOM/CanvasRenderingContext2D#Gecko-
> specific_attributes
Thanks Robert for the tip. I have tried setting on and off the antialiasing behavior but to no avail. Please find attached to the report screenshots demonstrating the problem. I have also attached sample code + data in case you want to have a deeper look.
| Reporter | ||
Comment 12•13 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #3)
> PNG uses a unpremultiplied alpha while canvas 2D uses a premultiplied one.
> It's inevitable that the exact RGB values are lost for pixels whose alpha
> values are not 255 as long as you use canvas 2D.
> WebGL has an unpremultiplied alpha mode. Is it reproducible with WebGL?
> (Contrary to the impression, WebGL is also usable for 2D graphics.)
Thanks for the explanation Masatoshi. However, my point is that the behavior of a neutral code which is suppose to be cross-browser compatible has different results on different. So, on IE10 it runs fine (i.e. is correct) while on Firefox it is incorrect. I am simply reporting the issue here as a problem in Firefox. I have attached to this case several screenshots to demonstrate this as well as test code and data for you to explore further in case you are interested. Sadly, I do not have a computer where i can run WebGL.
| Reporter | ||
Comment 13•13 years ago
|
||
Comment on attachment 694246 [details]
This is not the correct image i wanted to upload.
As i have no idea how to remove attachments, i am stating here that this is attachment should ignored for this bug.
Attachment #694246 -
Attachment description: Screenshot of correct behavior when running same test code in IE10 → This is not the correct image i wanted to upload.
Attachment #694246 -
Attachment is obsolete: true
Comment 14•13 years ago
|
||
(In reply to vik.nuckchady from comment #12)
> Thanks for the explanation Masatoshi. However, my point is that the behavior
> of a neutral code which is suppose to be cross-browser compatible has
> different results on different.
Different browsers may perform the different rounding when calculating the premultiplied alpha.
http://www.w3.org/TR/2dcontext/#dom-context-2d-putimagedata
> The handling of pixel rounding when the specified coordinates do not
> exactly map to the device coordinate space is not defined by this
> specification, except that the following must result in no visible
> changes to the rendering:
>
> context.putImageData(context.getImageData(x, y, w, h), p, q);
Note that it is NOT guaranteed that
context.putImageData(imageData, p, q);
imageData = context.getImageData(x, y, w, h);
will preserve the pixel values.
> Note: Due to the lossy nature of converting to and from premultiplied
> alpha color values, pixels that have just been set using putImageData()
> might be returned to an equivalent getImageData() as different values.
| Reporter | ||
Comment 15•13 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #14)
> (In reply to vik.nuckchady from comment #12)
> > Thanks for the explanation Masatoshi. However, my point is that the behavior
> > of a neutral code which is suppose to be cross-browser compatible has
> > different results on different.
>
> Different browsers may perform the different rounding when calculating the
> premultiplied alpha.
>
> http://www.w3.org/TR/2dcontext/#dom-context-2d-putimagedata
> > The handling of pixel rounding when the specified coordinates do not
> > exactly map to the device coordinate space is not defined by this
> > specification, except that the following must result in no visible
> > changes to the rendering:
> >
> > context.putImageData(context.getImageData(x, y, w, h), p, q);
>
> Note that it is NOT guaranteed that
> context.putImageData(imageData, p, q);
> imageData = context.getImageData(x, y, w, h);
> will preserve the pixel values.
>
> > Note: Due to the lossy nature of converting to and from premultiplied
> > alpha color values, pixels that have just been set using putImageData()
> > might be returned to an equivalent getImageData() as different values.
Thanks again Masatoshi for the prompt reply and the W3C link. Based on that, i think that there is no bug. So, this case can be closed.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•