Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6615033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:24:45+00:00 2026-05-25T20:24:45+00:00

I’m learning HTML5 and when doing some basic things like canvas pixel manipulation, found

  • 0

I’m learning HTML5 and when doing some basic things like canvas pixel manipulation, found out that Opera messes up the image completely when I want to change a color channel.
I’ve cooked up a small test page that should speak for itself: http://gda.0fees.net/tests/opera/canvas2.html (NB: the “expected result” images are dynamically loaded and the server is kind of slow).

The script takes the image and changes the red value for every pixel in a uniform manner. Here’s the central point of my code (which you can see in full via the link above):

for (var i = 0, l = matrix.data.length; i < l; i += 4)
{
    matrix.data[i] += delta;
    if (matrix.data[i] > 255) matrix.data[i] = 255;
    if (matrix.data[i] < 0  ) matrix.data[i] = 0;
}

In Chrome, Firefox, IE 9, and Safari it works like a charm. In Opera, however, I get this result for both transformations: http://gda.0fees.net/tests/opera/opera.jpg

Am I doing something wrong? Is this a known bug? Can it be suppressed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:24:46+00:00Added an answer on May 25, 2026 at 8:24 pm

    If I had to guess I’d say the red channel value was wrapping round to some invalid value. Note (in the source image) that the bugged areas are all much brighter overall than the areas that are properly treated.

    It might be that its doing some sort of limit check, zeroing the red value of pixels where the original red value + 128 would exceed the maximum value used to represent colour components (a uint 8 maybe?).

    I’ve never used HTML5’s canvas before, but if you can sample the colour of each pixel, you might be able to suppress it by guessing the maximum value and checking to make sure you don’t exceed it when augmenting that particular pixel’s colour component.

    Try this:

    // Apologies, my JavaScript is very rusty, and this isn't how I would do this.
    for (var i = 0, l = matrix.data.length; i < l; i += 4)
    {
        var current_red = matrix.data[i];
        var new_red = 0;
    
        if((current_red + delta) > 255) new_red = 255;
        else if((current_red - delta) < 0) new_red = 0;
        else new_red = current_red + delta;
    }
    
    // What I would do is this:
    for (var i = 0, l = matrix.data.length; i< l; i+=4)
    {
        // I don't know if JS has a clamp function :D
        matrix.data[i] = clamp(matrix.data[i] + delta, 0, 255);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.