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

Add screenshotPNG command #262

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

zturtleman
Copy link

I created a pull request in case someone wants to object to this going into ioq3.

@ensiform
Copy link

When was FS_GetModDescription added to ioq3?

@zturtleman
Copy link
Author

FS_GetModDescription was added last October in 755b2f3.

ri.Cvar_VariableStringBuffer("version", tEXt[numtEXt].text, sizeof (tEXt[numtEXt].text));
numtEXt++;
Q_strncpyz(tEXt[numtEXt].key, "Author", sizeof (tEXt[numtEXt].key));
ri.Cvar_VariableStringBuffer("username", tEXt[numtEXt].text, sizeof (tEXt[numtEXt].text));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't mind much about my playername (e.g. ^1That^6Guy) to show up as metadata in screenshots, I'd rather not have my username (e.g. John Doe) recorded somewhere. Especially since the average user might not know about this somewhat hidden metadata or how to remove/edit it.

Base automatically changed from master to main February 10, 2021 09:26
@zturtleman zturtleman marked this pull request as draft May 20, 2024 20:01
@zturtleman
Copy link
Author

I think the screenshot data is linear colorspace but PNG is always sRGB colorspace. The screenshot is not converted so I think the screenshot will be displayed incorrectly in image viewers. Converting 8-bit linear to 8-bit sRGB is lossy and probably not a great idea. (Or I guess use TGA if you want an accurate copy of the screenshot.)

(I don't think this is handled when ioquake3 loads PNG images either. I think they will display incorrectly in-game; sRGB colorspace displayed as linear colorspace.)

I should remove metadata from screenshots and remove exporting zlib functions for compress to the renderer API. I should split levelshot changes into a separate PR.

zturtleman added a commit to zturtleman/worldofpadman that referenced this pull request May 24, 2024
Setting packAlign was removed [1] and later set to 0 [2] and this caused
PADP( ..., packAlign ) to return NULL which later gets passed to
R_GammaCorrect() and crashed.

It seems I left packAlign in my PNG/levelshot changes [3] even though
it's not needed in R_LevelShot().

Set packAlign to 1 which is single byte alignment and doesn't allocate
additional memory. PADP( ..., 1 ) returns the same address and it
doesn't crash later.

1: b514a01
2: 688f4f5
3: ioquake/ioq3#262
zturtleman added a commit to zturtleman/worldofpadman that referenced this pull request May 24, 2024
Setting packAlign was removed [1] and later set to 0 [2] and this caused
PADP( ..., 0 ) to return NULL which later gets passed to R_GammaCorrect()
and crashed.

It seems I left packAlign in my PNG/levelshot changes [3] even though
it's not needed in R_LevelShot().

Set packAlign to 1 which is single byte alignment and doesn't allocate
additional memory. PADP( ..., 1 ) returns the same address and it
doesn't crash later.

1: b514a01
2: 688f4f5
3: ioquake/ioq3#262
Add screenshotPNG command.
Fix "\screenshotJPEG levelshot" to save JPEG image instead of TGA.
Allow specifying the size of levelshot using "\screenshot levelshot 256".
Fix using offset for source returned by RB_ReadPixels(). In practice
this shouldn't be an issue because Hunk_AllocateTempMemory() should
already be aligned to sizeof(intptr_t).
Filling the resample buffer didn't correctly handle offset for packAlign
if it didn't match the alignment returned by Hunk_AllocateTempMemory().

There isn't SIMD or something that the code wants a specific alignment.
Hunk_AllocateTempMemory() is aligned to sizeof(intptr_t) anyway so there
isn't a reason to add a memory alignment here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants