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 8194717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:55:01+00:00 2026-06-07T04:55:01+00:00

I am working on complex task so my issue should not make real sense,

  • 0

I am working on complex task so my issue should not make real sense, but the issue is how to draw a point using putImageData with color information of some point that was previously obtain via getImageData.

Let’s say I have a 200px horizontal line A (0, 0) – B (199, 0). I can read its pixel color information using

var pixels = ctx.getImageData(0, 0, 200, 1); // horizontal line :: 200 pixels

but once I have pixels array (pixel.length = 800), I want to draw just some points from this line on different place(s). Just point, not line.

This will draw the entire line:

ctx.putImageData(pixels, 20, 20);

But how can I draw just one point C (20, 20) with pixel color information from n-th point of the line A – B?

How can I use putImageData with array of rgba (array.lenght = 4) using data from pixels?

  • 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-07T04:55:04+00:00Added an answer on June 7, 2026 at 4:55 am

    putImageData has another set of arguments, a dirty rectangle:

    putImageData(imagedata, dx, dy, dirtyX, dirtyY, dirtyWidth, dirtyHeight)

    With this you can specify a rectangle within the image data to copy back. It will copy only the pixels in that rectangle back to the canvas.

    So this will get you your horizontal line, as you said:

    var pixels = ctx.getImageData(0, 0, 200, 1); // horizontal line :: 200 pixels
    

    This will put the one pixel at (20,0) in the image data at the location (20,0) in your canvas:

    ctx.putImageData(pixels, 0, 0, 20, 0, 1, 1)
    

    Note that you still have to start the x/y offset at 0,0, this is because of how the dirty rectangle works. You aren’t putting the one pixel at (20,0) back at (0,0), instead you’re putting the entire image data back starting at (0,0) but not copying over any of it except whats inside the dirty rectangle. This makes

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

Sidebar

Related Questions

I am working with some complex queries using the dynamic find_all method and reached
I'm working on a complex application, and I'm having an issue with a listbox
I have a problem with NSUndoManager not undoing when working with a complex model.
i am working with a complex application and like to know which files it
I've been working on a complex app with one main dashboard. I don't particularly
We have the following code working for a complex rails form with checkboxes. I'm
I am working a much more complex version of this (with vehicle moving in
I'm working on my first very complex JQuery based application. A single web page
I am working on a relatively complex JavaScript-driven website. It runs great in all
I'm working on a pretty complex web application in Ext with Google maps API

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.