The Better Snipping Tool was born from a simple annoyance: the extra click required by the default Snipping Tool. I wanted a faster, smoother tool with my own unique touch. What started as a personal project evolved into a practical and customizable solution for snipping, painting, and creating GIFs, all while maintaining simplicity and efficiency.
Example of a screenshot captured using the Better Snipping Tool.
Example of a painting on a screenshot captured with the Better Snipping Tool.
Example of an endlessly looping GIF captured using Better Snipping Tool.
Trimming menu that pops up when enabling trimming, user selects starting and ending frames.
- Operating System: Windows 10/11 (Linux planned).
- .NET 8.0
- FFmpeg with GIF and PNG support (minimal build included in source code and installer).
- Download the latest release at https://github.com/ShayneEvans/BetterSnippingTool/releases
- Click on BetterSnippingTool.vX.Y.Z.Setup.zip and then use the setup executable to install.
- A shortcut should appear on your desktop, you're now ready to snip!
Before building, ensure you have the following installed:
- Visual Studio (Community Edition is free)
- During installation, include:
- .NET Desktop Development workload
- Windows Forms support
- During installation, include:
- Microsoft Windows Desktop Runtime - 8.0.0 (x64)
Download the source code:
git clone https://github.com/ShayneEvans/BetterSnippingTool.git && cd BetterSnippingTool
- Locate the solution file (e.g.,
BetterSnippingTool.sln
). - Open it with Visual Studio.
- In Visual Studio, go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
- Restore the required dependencies by clicking the Restore button or running:
- Dependency:
WindowsAPICodePack
version8.0.4
π You're Ready to Run the Program!
All necessary C# dependencies have been installed, and the program is ready to run. Everything is setup and ready to build. A minimal FFmpeg build is included with the project for your convenience. However, if you prefer not to use the provided build, you can compile FFmpeg yourself by following the steps outlined below. If not skip to the Buld the Project section.
Follow the steps below to install a minimal FFmpeg build with GIF support.
-
Install MSYS2
Download and install MSYS2 from msys2.org. -
Install Build Tools
Open the MSYS2 terminal and run the following command:
pacman -S base-devel mingw-w64-x86_64-toolchain git yasm pkg-config
-
Download the FFmpeg Source
Clone the FFmpeg repository and navigate to the directory:
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
-
Install Required Libraries
Install the necessary libraries (libpng
andzlib
):
pacman -S mingw-w64-x86_64-libpng mingw-w64-x86_64-zlib
-
Configure FFmpeg with Minimal Settings
Run the following command to configure FFmpeg with only the necessary options for GIF support:
./configure --disable-everything --enable-demuxer=image2 --enable-decoder=png --enable-muxer=gif --enable-encoder=gif --enable-encoder=png --enable-filter=palettegen --enable-filter=paletteuse --enable-filter=scale --extra-cflags="-I/mingw64/include" --extra-ldflags="-L/mingw64/lib"
- If you encounter the error
gcc is unable to create an executable file
, install additional MinGW libraries with the following command:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-pkg-config mingw-w64-x86_64-zlib
- If this doesn't work it is possible GCC isn't installed. This can be checked by doing
gcc --version
, if it doesn't work it's not installed. Execute this command to install gcc:pacman -S mingw-w64-x86_64-gcc
. ifgcc --version
doesn't work after this make sure it appears in your PATH. The MSYS2 MinGW environment should automatically set this up, but you can verify by checking:echo $PATH
. If the output does not include/mingw64/bin
then add it manually withexport PATH=$PATH:/mingw64/bin
. After this hopefullygcc --version
should work. - Another potential error will be
nasm not found or too old. Please install/pdate nasm or use --disablex86asm for a build without hand-optimzied assembly
this can be remedied withpacman -S nasm
.
- If you encounter the error
-
Compile FFmpeg
Run the following command to compile FFmpeg:
make -j4
-
Gather Required Files
After the build completes, you will need the following files:ffmpeg.exe
\ffmpeglibbz2-1.dll
C:\msys64\mingw64\binlibiconv-2.dll
C:\msys64\mingw64\binliblzma-5.dll
C:\msys64\mingw64\binlibwinpthread-1.dll
C:\msys64\mingw64\binzlib1.dll
C:\msys64\mingw64\bin
-
Cleanup
Remove unnecessary files and keep only the required binaries and DLLs by running:
find . -maxdepth 1 ! -name '.' ! -name 'ffmpeg.exe' ! -name 'libbz2-1.dll' ! -name 'libiconv-2.dll' ! -name 'liblzma-5.dll' ! -name 'libwinpthread-1.dll' ! -name 'zlib1.dll' -exec rm -rf {} +
- In Visual Studio, go to Build > Build Solution or press
Ctrl+Shift+B
. - The build will generate an
.exe
file in one of the following directories:- For Debug builds:
bin\Debug
- For Release builds:
bin\Release
- For Debug builds:
- Navigate to the output folder (
bin\Debug
orbin\Release
). - Locate the
.exe
file (e.g.,BetterSnippingTool.exe
). - Double-click to run the program.
- If you encounter issues during the build:
- Ensure all prerequisites are installed.
- Check the target framework compatibility on your system.
- Feel free to open an issue in the repository for further assistance.
The Better Snipping Tool is built entirely in C# with WinForms providing the graphical user interface (GUI). It offers advanced functionality for capturing and editing screenshots, creating GIFs, and managing user settings efficiently.
-
Screenshots are captured based on the user-defined selection area and converted into
Bitmap
objects. These images are then displayed in aPictureBox
on the MediaForm. -
From the MediaForm, users can:
- Save the screenshot to their computer.
- Edit the screenshot in Paint.
- Capture a new screenshot.
- Create a GIF using multiple screenshots.
- The clipboard functionality required a memory-efficient solution, especially for managing frequent updates during painting operations.
- The default
Clipboard.SetImage()
method was unsuitable because it retained each image in memory, leading to gradual memory increases with every paintbrush stroke. - To resolve this, platform invoking (P/Invoke) was used to clear the clipboard history. This ensured that memory usage remained stable, even with frequent updates.
- The clipboard supports both screenshots and GIFs, allowing captures to be instantly pasted where needed.
- GIFs are composed of multiple screenshots, determined by the user's selected frames per second (FPS) and duration in seconds.
- For example, a 24 FPS GIF lasting 5 seconds will consist of 120 screenshots (
5 Γ 24 = 120
).
- For example, a 24 FPS GIF lasting 5 seconds will consist of 120 screenshots (
- Screenshots are captured using the same method as standard snips and are temporarily stored in the AppData/Roaming directory.
- Once all screenshots are captured:
- FFmpeg is used to generate a color palette from the screenshots.
- The GIF is then created using this palette for optimal quality.
- The completed GIF is displayed in a
PictureBox
on the MediaForm, where users can optionally trim it by selecting starting and ending frames.
- Users can customize several settings in the application, including:
- Default save directory for screenshots and GIFs.
- Resolution options: Optimized, Snipped Resolution, or Custom Resolution.
- GIF FPS (1β60).
- GIF duration in seconds (1β20).
- Configurations can be saved as XML profiles, allowing users to easily switch between different setups for GIF creation.
- A singleton pattern is used to manage the application's configuration. These settings are loaded at the start of the application, ensuring seamless operation.
- Fix: GIF stays in memory even after being disposed.
- Improvement: Mimic snipping tool transparency when snipping.
- Improvement: Smaller FFmpeg compile.
- Improvement: Add unit testing using MVP pattern.
- Feature: Ability to add text to GIFs post creation.
- Feature: More options for screenshots such as full screen, free form shape, etc.
- Feature: Optimize screenshot output as toggleable option (reducing resolution to save space).
- Feature: Cropping.