xyb3rt / sxiv

Simple X Image Viewer
GNU General Public License v2.0
1.82k stars 261 forks source link

added svg support and modified Makefile enough so that it compiles #440

Open Dhruv-Vanjari opened 3 years ago

Dhruv-Vanjari commented 3 years ago

Hi, This is a loader for svg images.

I am not very good at Makefile so I have modified it just enough so that the code compiles. Makefile has to be updated after this commit.

The following libraries are used for loading svg documents

First the svg document is opened using librsvg and then rendered on a cairo surface, and finally the cairo surface pixel buffer is used to create an Imlib_Image.

dependencies also need to updated in README after this commit.

Dhruv-Vanjari commented 3 years ago

I forgot to mention one thing. The vector images are converted to raster and thus not retain their scalable nature. I am planing to implement functions to zoom in the image without loosing clarity in the future.

Naheel-Azawy commented 3 years ago

Nice, added to my fork. Waiting for your next commit. Before I forget, I guess it's nice to add image/svg+xml; to the .desktop file. Thanks dude and have a nice day

Dhruv-Vanjari commented 3 years ago

Thanks for the suggestion Naheel.

Dhruv-Vanjari commented 3 years ago

Implemented zooming

Now users can zoom in svg images without loosing quality.

Because size (resolution) of the raster image changes when scaling svg images, zoom steps were increasing/decreasing exponentialy and the result was unusable. That's why while performing operations like img_check_pan and img_render, img->zoom property is forced to equal to 1.0 then reverted to the actual zoom value.

Now that svg support has been implemented, I will work on error handling and checks so that the program won't break. And also try work on the make file.

Naheel-Azawy commented 3 years ago

Great work! I found a little issue though. It seems that img_fit_win (when pressing w) is not following the new zoom mechanism.

Dhruv-Vanjari commented 3 years ago

Yeah, I encountered this issue as well. I will look into it. Thanks

PRESFIL commented 3 years ago

Does anyone know why @muennich doesn't show up on the net?

Dhruv-Vanjari commented 3 years ago

I figured out the solution to the img_fit problem and it requires to modify the way regular raster images are handled. I don't think that is a very good idea to have so many commits on so many different areas of the code base in one PR. I was thinking that once this PR gets accepted, I will create another PR as a bug fix. Mean while I will work on svg support and other features on the build branch in my fork of sxiv

bakkeby commented 3 years ago

@Dhruv-Vanjari you could always squash your commits :)

As for getting the PR accepted, good luck. I thought muennich has made it pretty clear that he is not accepting any more pull requests, but that could of course still happen.

GRFreire commented 3 years ago

@Dhruv-Vanjari nice work! The only thing that i didn't work for me was in the thumbnail mode. Unfortunately I dont know enough C to make this work, so I'll keep an eye on here to see if that's fixed

GRFreire commented 3 years ago

I'm also having some kind of error. I works flawless afaik, but it does prints out to the terminal:

GLib-GObject-CRITICAL **: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

How to reproduce

What do I got so far I know if you remove this part of the code, the error disappears, but I dunno how important it is to just remove it like that.

diff --git a/image.c b/image.c
index a850533..0a7caf4 100644
--- a/image.c
+++ b/image.c
@@ -428,9 +428,6 @@ CLEANUP void img_close(img_t *img, bool decache)
            imlib_free_image();
        img->im = NULL;
    }
-
-   if (img->svg.h)
-       g_object_unref(img->svg.h);
 }

 void img_check_pan(img_t *img, bool moved)