Skip to content

Direct imageData doesn't consider devicePixelRatio #104

@anderoonies

Description

@anderoonies

Describe the bug
When directly extracting getImageData from the canvas, the devicePixelRatio calculations aren't considered and the result is improperly sized.

To Reproduce
https://codehs.com/sandbox/andy/device-pixel-ratio

Steps to reproduce the behavior:

  1. On a device with >1 devicePixelRatio, extract imagedata using __graphics__.getContext().getImageData()
  2. Create a new WebImage and set its image data to the extracted data with setImageData
  3. The WebImage only contains a 1/n * 1/n portion of the ImageData, where n is the devicepixelratio

Expected behavior
I'd like getImageData to only ever return a value the size of the perceived canvas (after css downscaling).
I think a method like getImageData() (not on context, just global) that performs the devicePixelRatio scaling would be helpful. This is advanced functionality, but something to think about.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions