Skip to content

p5.Framebuffer.get() loses resolution at pixel density > 1 #8583

Description

@MASTERsj01

Increasing access

Fixing this ensures that p5.Framebuffer.get() returns high-resolution images on high-DPI displays (like Retina screens), matching user expectations. Currently it silently downsizes the image, which can confuse beginners who don't understand pixel density.

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

Feature enhancement details

p5.Framebuffer.get() in src/webgl/p5.Framebuffer.js (line 1575) has a TODO: support get() at a pixel density > 1 comment.

Currently, when density > 1, the method reads the full high-resolution pixel data but then calls resize(w, h) which performs a lossy downscale — discarding the extra resolution.

The fix is to use p5.Image.pixelDensity(density) instead of resize(), so the returned image retains its full-resolution data while reporting the correct logical width and height.

Additionally, console.warn at line 1503 should use p5._friendlyError() for consistency with FES.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions