https://github.com/fuelsoft/viewer
Load and display image files
https://github.com/fuelsoft/viewer
cpp giflib libheif sdl2 sdl2-image
Last synced: 11 months ago
JSON representation
Load and display image files
- Host: GitHub
- URL: https://github.com/fuelsoft/viewer
- Owner: fuelsoft
- License: gpl-3.0
- Created: 2020-03-04T05:59:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-09T07:11:11.000Z (over 5 years ago)
- Last Synced: 2023-09-14T20:38:01.312Z (almost 3 years ago)
- Topics: cpp, giflib, libheif, sdl2, sdl2-image
- Language: C++
- Homepage:
- Size: 319 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# viewer
Load and display image files
## What is this?
I got so tired of Windows Photo Viewer misbehaving that I decided to write a clone.
Things WPV does that drove me to insanity:
* No support for animated GIFs.
* I had to resort to opening GIFs in Internet Explorer, truly a cursed experience.
* As of version 0.3.X, animated GIFs are nearly fully supported.
* "Windows Photo Viewer can't display this picture because there might not be enough memory available on your computer"
* Let me assure you, this is not correct.
* Afflicted photos open correctly in Photoshop, web browsers, etc. It's just WPV that has a problem.
* Very low FPS and bad screen tearing with no warning when zooming or when panning while zoomed in.
* Really annoying, and there's no good reason for it.
How hard could it be to write a replacement, right?
Things *Viewer* can do:
* Display many common image formats.
* Zoom!
* Pan!
* Wow!
Also, it's GPU accelerated (via SDL's Accelerated Rendering features). There are some trade-offs:
* **PRO:** Ultra low CPU usage **once image is loaded -- this is still a CPU process.**
* **PRO:** Panning and zooming are very smooth and take advantage of better GPU hardware rendering.
* **CON:** Startup takes a little longer than WPV due to the conversion of the input image to a GPU texture.
* **CON:** Image size limited by typically smaller VRAM size compared to RAM - *I have yet to find an image large enough to hit this limit though.*
## Requirements:
This project depends on:
* C++17 for std::filesystem
* MSYS2 for MingW64 and required libraries
Packages you'll need, as they appear in MSYS:
* mingw-w64-x86_64-gcc
* mingw-w64-x86_64-make
* mingw-w64-x86_64-SDL2
* mingw-w64-x86_64-SDL2_image
* mingw-w64-x86_64-giflib
* mingw-w64-x86_64-libheif
## Building:
Run `make ` in the Viewer folder where type is either `Debug` or `Release` (defaults to `Release`).
#### Notes:
* If your `make.exe` isn't on your PATH, you need to launch it via it's complete path or hard link it into the Viewer directory.
* You will need to modify the makefile at the marked lines to point to your mingw64 install (for `g++` and `windres`).
* You will also need to point to the library include and lib folders - they shouldn't require much modification unless MSYS is installed somewhere other than default.
* These are mostly just the build commands as CodeBlocks runs them - they may not always be up to date enough to build the project without modification.
## Usage:
First, ensure that the executable has all the `.dll` files available to it. There are a number you need:
* `SDL2`, `SDL2_image` & all the related image `.dll`s (including `zlib`)
* `libaom`, `libde265`, `libheif`, `libx265` for HEIF files
* `libgcc_s_seh`, `libstdc++`, `libwinpthread` for basic program functions
Then call the program by either dragging an image onto Viewer.exe or by running `Viewer.exe ` in a terminal.
You can also set Viewer as the default program for some image formats if you want to commit to it.
### Controls:
##### Mouse:
|CONTROL|FUNCTION|NOTES|
|:-----:|:---:|:---:|
|SCROLL UP|Increase zoom|-|
|SCROLL DOWN|Decrease zoom|-|
|LEFT CLICK|Pan image|Must be held while dragging.|
|MIDDLE CLICK|Reset zoom and pan|This is usually a scroll wheel click.|
|MOUSE *X1*|Previous image|If the mouse is equipped with a *back* button.|
|MOUSE *X2*|Next image|If the mouse is equipped with a *forward* button.|
##### Keyboard:
|SYMBOL|CONTROL|FUNCTION|NOTES|
|:---:|:---:|:---:|:---:|
|+|PLUS|Increase zoom|For keyboards without keypad, use equals (`=`).|
|-|MINUS|Decrease zoom|-|
|0|ZERO|Reset zoom and pan|Zero, not the letter O.|
|ESC|ESCAPE|Close program|Identical to window *close* button.|
|<\-|LEFT ARROW|Previous image|-|
|\->|RIGHT ARROW|Next image|-|
|\|<\->\||TAB|Toggle light theme|-|
|␣|SPACEBAR|Play/Pause animation|Only applicable to animated images.|
|DEL|DELETE|Delete image|**Permanent!** This will **not** go to Recycle Bin!|
|F1|F1|View version info|Probably not useful to you if you're reading this.|
|F2|F2|View file info|Display Windows Explorer's *Properties* window for the image.|
|F3|F3|Containing folder|Launches Windows Explorer to the image's parent folder.|
|F5|F5|Refresh|Reload the current image.|
### Supported formats (by library):
#### SDL:
* JP(E)G
* PNG
* BMP
* TIF(F)
* TGA
#### GIFLIB:
* GIF
#### LIBHEIF:
* HEIC
* HEIF
### Notes:
* Some file types can contain multiple resolutions/variations of an image (ICO, CUR, ...). SDL_image [documentation][1] states that "for files with multiple images, the first one found with the highest color count is chosen."
* Window size and position are stored in `settings.cfg` in the program folder. If this becomes broken somehow (window appears off-screen, etc.) it is safe to delete this file to restore defaults.
* Setting up a version of GCC new enough to support C++17 is a really bad time on Windows and unless you really need to build from source, I highly recommend you use one of the builds. Otherwise, I'll direct you to [MSYS2](https://www.msys2.org/)'s homepage.
### TODO:
* Add key to set zoom to 1:1 pixel ratio
* Zoom on mouse instead of window center
* Stop image from being moved off-screen
* Possible **minimal** RAW support
### Known Problems:
* ICO: Files stored as "NEW PNG" type do not load with SDL_image
* ICO: Files with partially transparent pixels do not render correctly
* ALL: Images loaded from RO-type media (cell phones, cameras) are copied to a temp folder by Windows before being loaded.
This breaks in-folder navigation. It's unclear to me how WPV works around this.
* ALL: Images with UTF-8 characters anywhere in the path are broken - this is because of the conversion from wchar string to char string done to accommodate SDL_Image. I can't find anything online about how to work around this.
[1]: https://www.libsdl.org/projects/SDL_image/docs/SDL_image.pdf#page=21&zoom=auto,-205,720