Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raw screenshots have duplicated pixels and no Pixel Aspect Ratio metadata #4754

Closed
2 tasks done
sdsnatcher opened this issue Jan 12, 2024 · 4 comments
Closed
2 tasks done
Labels

Comments

@sdsnatcher
Copy link

sdsnatcher commented Jan 12, 2024

Describe the bug

While taking raw screenshots for #4753, I noticed two problems with the saved png files:

  1. There are duplicated pixels. Raw screenshots are supposed to be a direct copy of the video memory, without any sort of scaling
  2. The Pixel Aspect Ratio metadata is not being stored in the png files, causing them to be viewed with square pixels on viewers that support PixelAspect Ratio, like XnView and the Win 10 image viewer.

Example:
05_playfate_000 raw1

Steps to reproduce the behaviour

  1. Run any DOS game. Preferably EGA 640x200 or 640x350 games, where the issue is more evident
  2. Take a raw screenshot using the Capture menu

Expected behavior

  1. The raw screenshot should be a raw dump from the video memory, without any form of scaling
  2. The Pixel Aspect Ratio metadata (PNG pHYs chunk) should be stored in the file

dosbox-staging already implemented this on their raw screenshots.

Example (please view the image using XnView, since it supports the Pixel Aspect Ratio metadata to render rectangular pixels):
06_playfate_000 raw1_corrected

What operating system(s) this bug have occurred on?

macOS 13.6.3

What version(s) of DOSBox-X have this bug?

2023.10.06

Used configuration

No response

Output log

No response

Additional information

No response

Have you checked that no similar bug report(s) exist?

  • I have searched and didn't find any similar bug report.

Code of Conduct & Contributing Guidelines

  • I agree to follow the code of conduct and the contributing guidelines.
@sdsnatcher sdsnatcher added the bug label Jan 12, 2024
@joncampbell123
Copy link
Owner

joncampbell123 commented Feb 10, 2024

At this moment, the raw capture mode is more of a direct capture of the pixel values as rasterized by the monitor, so if you're using a 200-line graphics mode on VGA, and the VGA is doubling each scan line as VGA normally does in those modes, then the raw capture will contain the raw pixel values, scan line doubled.

Good point on the aspect ratio fields though, I think I can figure out how to use libpng to write that.

@joncampbell123
Copy link
Owner

I'm sorry if "raw" is confusing in that it's not exactly a snapshot of video memory, but only a snapshot of the raw pixel values from video memory as they are rasterized to the screen.

@joncampbell123
Copy link
Owner

joncampbell123 commented Feb 11, 2024

http://www.libpng.org/pub/png/book/chapter11.html#png.ch11.div.9

image

And the libpng function is png_set_pHYs but only if PNG_pHYs_SUPPORTED.

#ifdef PNG_pHYs_SUPPORTED
PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,
    png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
#endif

@joncampbell123
Copy link
Owner

Done. See latest commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants