Ave
Ave

Reputation: 4430

How to scan all pixel in square C#?

I get height and width of an element on the website.

Example: Element easelCanvas with height: 1000px and width: 600px.

Note: I using Excel to easy imagine. It must scan like this:

I do with code:

int width = 600, height = 1000;
for (int i = 0; i < width; i += 60)
{
    for (int j = 0; j < height; j += 50)
    {

    }
}

First rows it scan from at position(0, 0) to final and go like:

Upvotes: 0

Views: 55

Answers (1)

Anant Dabhi
Anant Dabhi

Reputation: 11114

I have creates one sample canvas it might be helpful to you ..

 var canvas=document.getElementById("myCanvas");
    var ctx=canvas.getContext("2d");



var index = 0;
for (var i = 0; i < canvas.height; i += 60)
{
    for (var j = 0; j < canvas.width; j += 50)
    {

ctx.strokeText("index"+index,j,i+15);
index++;

    }
}

JsBin Link

Upvotes: 1

Related Questions