add .desktop file, fix opening images from file explorer

This commit is contained in:
Crispy 2024-10-25 17:51:02 +02:00
parent 3042fcb8cd
commit 7a1de9d871
3 changed files with 16 additions and 3 deletions

2
README.md Normal file
View file

@ -0,0 +1,2 @@
# showimage
very basic image viewer that doesn't blur images when zoomed in

7
showimage.desktop Normal file
View file

@ -0,0 +1,7 @@
[Desktop Entry]
Type=Application
Name=showimage
Exec=/bin/env showimage %u
Categories=Other;
MimeType=image/svg+xml
Terminal=false

View file

@ -14,8 +14,12 @@ main :: proc() {
rl.SetTargetFPS(60) rl.SetTargetFPS(60)
if len(os.args) > 1 { if len(os.args) > 1 {
path := strings.clone_to_cstring(os.args[1]) path := os.args[1]
tex = new_clone(rl.LoadTexture(path)) if strings.has_prefix(path, "file://") {
path, _ = strings.substring_from(path, 7)
}
tex = new_clone(rl.LoadTexture(strings.clone_to_cstring(path)))
if tex.id <= 0 { return }
reset_zoom() reset_zoom()
} }
@ -44,7 +48,7 @@ main :: proc() {
} }
zoom_to_power :: proc(size: i32, max: i32) -> i32 { zoom_to_power :: proc(size: i32, max: i32) -> i32 {
fit: i32 = 1 fit: i32 = 2
for fit * size < max { for fit * size < max {
fit *= 2 fit *= 2
} }