Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Dhruv-Vanjari
Copy link

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

  • librsvg
  • cairo

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
Copy link
Author

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
Copy link

Naheel-Azawy commented Apr 9, 2021

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
Copy link
Author

Thanks for the suggestion Naheel.

@Dhruv-Vanjari Dhruv-Vanjari changed the title added a loader for svg images and modified Makefile enough so that it compiles added svg support and modified Makefile enough so that it compiles Apr 13, 2021
@Dhruv-Vanjari
Copy link
Author

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.

bakkeby added a commit to bakkeby/sxiv-flexipatch that referenced this pull request Apr 13, 2021
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.

Ref. xyb3rt#440 (comment)
@Naheel-Azawy
Copy link

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
Copy link
Author

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

@PRESFIL
Copy link

PRESFIL commented Apr 13, 2021

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

@Dhruv-Vanjari
Copy link
Author

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
Copy link

bakkeby commented Apr 16, 2021

@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
Copy link

@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
Copy link

GRFreire commented Aug 23, 2021

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

  • Open sxiv in a folder with an svg in it ( open the svg here with -n option, because you wont be able to open it after )
  • Go to thumbnail mode
  • Open a raster image

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants