Closed Bug 564886 Opened 14 years ago Closed 13 years ago

getImageData gives back wrong results

Categories

(Firefox :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: mudcube, Unassigned)

Details

(Whiteboard: [CLOSEME 2011-1-30])

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 GTB7.0

There is a bug in newest Firefox (not in older versions).

The following function should return the same results:  it sets a pixel, and then grabs the data from that pixel.

<html>
<body>
<script>
(function() {
    var canvas = document.createElement("canvas"),
        ctx = canvas.getContext("2d"),
        rgb = [ 30, 120, 255, 255 ];
    ctx.fillStyle = "rgba("+rgb+")";
    ctx.fillRect(0, 0, 1, 1);       
    var imageData = ctx.getImageData(0, 0, 1, 1),
        data = imageData.data;
    alert(data[0] + "," + data[1] + "," + data[2] + " == " + rgb[0] + "," + rgb[1] + "," + rgb[2]);
})();
</script>
</body>

Reproducible: Always

Steps to Reproduce:
1. Run code in "Details"
Actual Results:  
11,105,255 == 30,120,255

Expected Results:  
11,105,255 == 11,105,255

This is a new bug, previous Firefox versions worked properly.
My expected results should read:

30,120,255 == 30,120,255

Also, there was a typo on the test, this line:

rgb = [ 30, 120, 255, 255 ];

should be replaced with this:

rgb = [ 30, 120, 255, 1 ];

makes no difference on test results, but, it's a notice-able typo.
I see this too, I think it's because of colour correction.
This might be a Mac only bug. I'm running the same version on Ubuntu with color management enabled and I'm not having this problem:
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3 - Build ID: 20100423141150

When I run the above test in my error console, I get the following output alerted:
"30,120,255 == 30,120,255"
(In reply to comment #3)
> This might be a Mac only bug. I'm running the same version on Ubuntu with color
> management enabled and I'm not having this problem:
> Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100423
> Ubuntu/10.04 (lucid) Firefox/3.6.3 - Build ID: 20100423141150
> 
> When I run the above test in my error console, I get the following output
> alerted:
> "30,120,255 == 30,120,255"

Although, I am using the system default color profile.
Just tested on Windows in Firefox 3.6.3 and it returns the proper results.  

This is a Mac only bug.
Reporter, are you still seeing this issue with Firefox 3.6.13 or later in safe mode? If not, please close. These links can help you in your testing.
http://support.mozilla.com/kb/Safe+Mode
http://support.mozilla.com/kb/Managing+profiles

You can also try to reproduce in Firefox 4 Beta 8 or later, there are many improvements in the new version, http://www.mozilla.com/en-US/firefox/all-beta.html
Whiteboard: [CLOSEME 2011-1-30]
Opening in Firefox 4.0 in Safe Mode there was no changes.  However, by creating a new profile in the new Firefox, and starting the browser, the output was correct.  

Checking in the config values, noticed my profile was set to:

gfx.color_management.mode = 1;
As gfx.color_management.mode defaults to 2 - closing this issue.
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.