Homebrew Release: PNGShot - Capture screenshots as PNGs.

  • Thread starter JK_
  • Start date
  • Views 907
  • Replies 8
  • Likes 9

JK_

Well-Known Member
OP
Member
Joined
Sep 4, 2015
Messages
707
Trophies
1
XP
2,362
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.


 

hippy dave

BBMB
Member
Joined
Apr 30, 2012
Messages
10,194
Trophies
2
XP
33,760
Country
United Kingdom
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.
 

masagrator

The patches guy
Developer
Joined
Oct 14, 2018
Messages
6,505
Trophies
3
XP
12,515
Country
Poland
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

JK_

Well-Known Member
OP
Member
Joined
Sep 4, 2015
Messages
707
Trophies
1
XP
2,362
Country
United States
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

JK_

Well-Known Member
OP
Member
Joined
Sep 4, 2015
Messages
707
Trophies
1
XP
2,362
Country
United States
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

  • PNGShot.zip
    131.8 KB · Views: 3
Last edited by JK_,

JK_

Well-Known Member
OP
Member
Joined
Sep 4, 2015
Messages
707
Trophies
1
XP
2,362
Country
United States
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...
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    BigOnYa @ BigOnYa: That game maybe too violent for your granny tho. Better get Barbies Dream house instead.