Homebrew Release: PNGShot - Capture screenshots as PNGs.

  • Thread starter Thread starter JK_
  • Start date Start date
  • Views Views 10,288
  • Replies Replies 70
  • Likes Likes 19

JK_

Well-Known Member
Member
Joined
Sep 4, 2015
Messages
963
Reaction score
2,281
Trophies
2
XP
3,598
Country
United States
Just a warning: I'm releasing this knowing that starting tomorrow life is about it get extra hectic for me. I've been told it seems pretty stable by the few people that I've let use it, but I might not be around for immediate fixes or tweaks should something arise in the next couple of months.

What is this?:
This is a sysmodule I wrote years ago, and thought I lost, that, in combination with bitmap-printer's exefs patches, can take screenshots and save them as PNG's instead of the system's default JPEG. The benefits are that:
  • Files are smaller than a bitmap (Anywhere from a couple of hundred kilobytes to just under 2MB depending on what's captured)
  • Losseless, unlike JPEG
The story behind it:
I was talking to a buddy on discord and he brought up bitmap-printer shortly after it was released. The quality was great, he said, but the file sizes were what put him off of it. I said something about doing the same, but with libpng. Thanks to my impulsiveness PNGshot (or pngscr as I named it then) was made. Problem was that it required the same patches that made bitmap-printer function. Not wanting to step on toes or cause issues, we agreed to keep it between us. A few months later, my laptop took a dump and I thought it was gone. That is, until I was looking through a flash drive I found in a drawer over this past weekend. I rewrote it to work with the most recent libnx since it was relatively simple and decided to not let it go to waste.

How to use:
  • You're going to need the exefs patches from bitmap-printer for now. Maybe in the future I'll have time to make my own, but right now I don't see the point, or have time, to do work that's already been done.
  • Download the sysmodule from the git repo link at the bottom of this post.
  • Pressing the capture button will now capture the current screen and save it to "sdmc:/switch/PNGShot/[date][time].png".
Thanks to:
  • Obviously the author(s) of bitmap-printer and its patches
  • @impeeza for enhancing the makefile and git readme. Especially since I don't really keep up with the homebrew scene lately and am really out of the loop.

I hope it was worth the time I put into it and someone finds it useful. Take it easy, everyone.


 
Sounds great, thanks! bitmap-printer has worked perfectly as a method to get lossless screenshots, but not having to convert them to the more useful format afterward is a big bonus.
 
Advice: immediately after initializing libnx time use timeExit(). Its very scarce session count can cause myriads of issues if you block sessions. Afaik you don't need time initialized after that if you are using newlib functions to get time, because everything is calculated with ticks.

__syscall_clock_gettime() exists too
https://github.com/switchbrew/libnx/blob/master/nx/source/runtime/newlib.c#L361

Bitmap printer uses fsFsGetFileTimeStampRaw to completely avoid use of time service.
 
Last edited by masagrator,
  • Like
Reactions: hippy dave
Advice: immediately after initializing libnx time use timeExit(). Its very scarce session count can cause myriads of issues if you block sessions. Afaik you don't need time initialized after that if you are using newlib functions to get time, because everything is calculated with ticks.

__syscall_clock_gettime() exists too
https://github.com/switchbrew/libnx/blob/master/nx/source/runtime/newlib.c#L361

Bitmap printer uses fsFsGetFileTimeStampRaw to completely avoid use of time service.
Yeah, you're right. It's not needed after __libnx_init_time() is called. I'll update it asap.
 
  • Love
Reactions: hippy dave
Hello there, I just noted something I didn't noted before, when the PNGShot Sysmodule is enabled, you can not capture video, is this intended?
 
Hello there, I just noted something I didn't noted before, when the PNGShot Sysmodule is enabled, you can not capture video, is this intended?
It's not intentional. The only way I can possibly see avoiding the issue would be to immediately read the entire screenshot stream to a buffer and close the stream. Problem is, the buffer would need to be around 3MB, and I remember there being a good reason I stuck to straight C and used as little memory as possible when writing sysmodules back then.

Edit: My math was wrong, the buffer is actually closer to 4MB, but doing it that way actually does solve the issue. It even lets you take a JPEG screenshot with a png. I'm noticing some wonky-ness though.
Post automatically merged:

@impeeza Actually, everyone, consider this a shits and giggles build that isn't going up on git. It's a memory hog, so you've been warned. It will probably cause issues and conflicts, but I was curious. It allows the system capture functions to still work and can still get a PNG out. I think it's quicker on the draw than the Switch is, but it did let me capture a decent comparison shot:
JPEG:
2024091209592000-6C53F6F49C292FD1C2157D3E0D773577.jpg
PNG:
20240912095920.png
I'll attach it below.
 

Attachments

Last edited by JK_,
New builds are up on Git for anyone interested. I changed the output directory to the album directory and also included the memory hog version that buffers the entire capture stream and allows normal captures and videos to work again. I might be taking a break to fiddle with PS4 for a bit if I can figure out how OpenOrbis is supposed to work without Visual Studio...
 
no idea if it's pngshot or bitmap printer, but 1 of both make atmosphere crash on boot in 20.3 20.4
Try this, it have patches for the most recent firmware, please remove any other sysmoduleS and install them one by one to catch any incompatibility.
 

Attachments

Last edited by impeeza,
no idea if it's pngshot or bitmap printer, but 1 of both make atmosphere crash on boot in 20.3 20.4
Either use the Impeeza posted or get them here. If it still crashes and it's actually PNGShot, you are the first and only crash I've ever had reported for this thing. Congratulations!
 
  • Haha
Reactions: impeeza

New build is up for anyone interested. The code has been overhauled completely and I changed the output folder structure to be more organized and easier to navigate.

With that, besides future firmware patches, PNGShot is pretty much complete and I don't think it's going to get much else in the way of updates unless someone discovers some catastrophic bug I managed to miss. Was a fun little C only project though.
 
Hi @JK_ I don't know if you are aware of the telegram Group NX Tools, this is a group where a bot send a message each time a repository is updated and have links to the official page.
An example:
1762479465619.png


I just wrote to the administrator of the group to include the PNGShot repository, and they asked for a picture for the front of the posts on that group. Do you have any picture you like to be the caption of the repo?
 
Last edited by impeeza,
Hi @JK_
I just wrote to the administrator of the group to include the PNGShot repository, and they asked for a picture for the front of the posts on that group. Do you have any picture you like to be the caption of the repo?
I don't really know. It's a sysmodule (that I thought I lost) and never really intended to release so... I never considered it needing a graphic or icon or anything.
 
  • Like
Reactions: impeeza
I don't really know. It's a sysmodule (that I thought I lost) and never really intended to release so... I never considered it needing a graphic or icon or anything.
Yes I think the same, it is only a aesthetic thing on the release group.
Post automatically merged:

What do you think of this logo for PNG Screenshot?

1762882688952.png
 
Last edited by impeeza,
My Switch gets extremely laggy with 99% utilization on system core #3 when i use PNGShot. I don't remember this happening before even on same versions. Currently on 19.0.1 with atmosphere 1.10.1 and latest png shot. Bitmap-Printer works flawlessly and has 35-45% utilization on #3 so it could be whatever pngshot is using for compressing the image?

Conspiratorial take: This is going to sound mental but the only "new" thing I remember doing is launching the RU version of DBI 854 recently by accident...................
 
Well, PNG compression was always inefficient performance wise and how long it takes depends on complexity of the screenshot. So if you do screenshot of homebrew with console style text printing, it will take very short time to finish, while for many games it will take few seconds - you should use CPU OC by default to reduce that time.

Imo using highest compression - 9 - is a very bad choice for something that should work fast. It should be much lower - around 4, just 1 would be enough for most people since it should be mainly about convenience, not size.

bitmap-printer just saves raw image with no compression.
Post automatically merged:

For test I modified source code to save the same screenshot 4 times with different levels of compression. CPU - 1020 MHz, RAM - 1600 MHz.

Compression level - how long it took to save - size

9 - 14 seconds - 1.16 MB
4 - 4.4 seconds - 1.19 MB
1 - 4.2 seconds - 1.34 MB
0 - 7.6 seconds - 2.64 MB

The image:
20260226_042702_262368729.png

So as you can see, 4 level is the most balanced one.

Also tested doing the same screenshot with 1963 CPU and 2131 RAM.

Compression level - how long it took to save
9 - 7.5 seconds
4 - 3.28 seconds
1 - 3.26 seconds
0 - 7.6 seconds

So as you can see, there is no difference when no compression is applied. On level 4 and 1 difference in time is much smaller than for level 9.

Added PR for this:
https://github.com/J-D-K/PNGShot/pull/14
 
Last edited by masagrator,

Site & Scene News

Popular threads in this forum