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

  • SEARCH
  • Home
  • 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 8412169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:36:27+00:00 2026-06-10T00:36:27+00:00

When I getImageData() from a canvas, I get an ImageData object, with a Data

  • 0

When I getImageData() from a canvas, I get an ImageData object, with a Data sub-object, which is a clamped array. I want to check if every pixel I get is white (and not transparent). In other words, I want to check if every value in the data object is equal to 255. The obvious code would be the following:

if (data.every(function(value) {return value == 255})) {
    //Do something
    }

But for some reason it won’t work in clamped arrays, as the following minimal code shows:

var DATA = new Uint8ClampedArray(3);
//var DATA = new Array

DATA[0] = 255
DATA[1] = 255
DATA[2] = 255
DATA[3] = 255

alert(DATA.every(function(value) {return value == 255}))

Any solutions? Thanks!

  • 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-06-10T00:36:29+00:00Added an answer on June 10, 2026 at 12:36 am

    You could extend the prototype of Uint8ClampedArray with an every() function, which can be taken from the Array prototype; then your code will work fine.

    Uint8ClampedArray.prototype.every = Array.prototype.every;
    

    I guess this is the easiest way to do it, but note that it will break the for ... in loop (which shouldn’t be used to iterate over arrays anyway…).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 imageData objects which I get from the same canvas through the
I can't seem to get pixel data from my canvas (Chrome 12). What am
var imageData = context.getImageData(0, 0, canvas.width, canvas.height); var data = imageData.data; and var data
I try to get the color of the selected pixel from my canvas background-image,
You can sample pixel color data on a canvas image with getImageData(). If I
I have to get imageData from Database in the form of byte[]. I think
I am trying to load an svg image into canvas for pixel manipulation I
I need to get the ratio of transparent/opaque pixels in my canvas. What is
I want to implement vertical scrolling of the contents of a HTML5 canvas element.
I'm using getImageData / putImageData on a HTML5 canvas to be able to manipulate

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.