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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:22:39+00:00 2026-06-02T00:22:39+00:00

With HTML5 canvas you can get a subimage of an image with no difficulty.

  • 0

With HTML5 canvas you can get a subimage of an image with no difficulty. Like follows:

var imageData = context.getImageData(5, 5, 10, 10);
var d = imageData.data

However, there does not appear to be a way to get another subimage of this data.

Say I wanted to do this:
var imageData = context.getImageData(0, 0, 2, 2) of the previously returned subimage.

This would effectively be (5, 5, 2, 2);

Drilling down recursively into an image with subimages is possible with most graphics libraries. Does canvas have something similar?

  • 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-02T00:22:41+00:00Added an answer on June 2, 2026 at 12:22 am

    You could create your own rect object and use that to do the subselections, but pull data directly from the initial canvas element.

    Something like

    function rect(x, y, w, h) {
        this.x = x;
        this.y = y;
        this.width = w;
        this.height = h;
    }
    
    rect.prototype.getRect = function(x, y, w, h) {
        return new rect(this.x + x, this.y + y, w, h);
    };
    
    var initial = new rect(5,5,10,10);
    var second = initial.getRect(0,0,2,2);
    

    Alternatively you could create a canvas element in memory, draw the first image, and then call getImageData on the new canvas context..

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

Sidebar

Related Questions

I'm making a game in html5 canvas. I'm using jquery so I can get
I have external html5 canvas that you can paint on some lines using your
I am developing an HTML5 canvas based mini-game and I can't seem to organize
Why do we need the html5 canvas element, when the same can be achieved
I am creating a web application using HTML5 canvas to draw images ( like
How can I automatically scale the HTML5 <canvas> element to fit the page? For
I'm building a game using HTML5 canvas. You can find it here, along with
I have an upcoming project that I would like to use the HTML5 canvas
Can anyone tell me why this canvas won't show up? I just don't get
I have made a snake game using javascript and HTML5 Canvas element. It can

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.