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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:48:06+00:00 2026-05-26T02:48:06+00:00

I need to draw rotated image data on a canvas. (This is a GWT

  • 0

I need to draw rotated image data on a canvas. (This is a GWT project and the context is an instance of com.google.gwt.canvas.dom.client.Context2d.)

I am trying to use the following code:

context.rotate(rotation);
context.putImageData(data, x, y);
context.rotate(-rotation);

But that code does not draw a rotated image. If I change the code like this:

context.rotate(rotation);
context.fillRect(x, y, 100, 50);
context.rotate(-rotation);

then a rotated rectangle will be drawn on the canvas. Is this an API bug, or my fault? What can I do to correct it?

I also tried using drawImage() instead of putImageData() to test how that method works. It works with rotation fine. But I need to draw ImageData that I take from another canvas. Are there any fast methods to translate ImageData to ImageElement? In what units does ImageData return its size?

  • 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-26T02:48:07+00:00Added an answer on May 26, 2026 at 2:48 am

    putImageData is not affected by the transformation matrix.

    This is by the Spec’s orders:

    The current path, transformation matrix, shadow attributes, global alpha, the clipping region, and global composition operator must not affect the getImageData() and putImageData() methods.

    What you can do is putImageData to an in-memory canvas, and then

    context.rotate(rotation);
    context.drawImage(inMemoryCanvas, x, y)
    context.rotate(-rotation);
    

    onto your regular canvas.

    NOTE: from your edit you seem to imply that you might just be drawing from one canvas to another without changing any of the imagedata. If this is the case, definitely just use drawImage(othercanvas, x, y) instead of using getImageData and putImageData if possible. Using drawImage is far faster.

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

Sidebar

Related Questions

I need to draw rotated rectangle on Canvas. I have x and y of
I need to draw a .png image on an UIView. I have no clue
I am drawing an image in HTML 5 using canvas in JavaScript. I need
so having a canvas and canvasContext I want to draw an image onto that
Now I'm doing a project which need draw multiple pie charts with text. Can
I need to draw Line, Circle, and rectangle by mouse drag on canvas and
I want to draw an earth globe on android. At this point I need
I am in need to draw a rotated text of any angle in a
I need to take a photo, find out its orientation, draw it on canvas
I need to draw some simple network topology charts, suggestions of some good tools

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.