emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/gnus-cloud 0456139 46/61: Merge branch 'master' of


From: Teodor Zlatanov
Subject: [Emacs-diffs] scratch/gnus-cloud 0456139 46/61: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Date: Fri, 1 Jul 2016 17:37:55 +0000 (UTC)

branch: scratch/gnus-cloud
commit 045613932b77b86b00e0c95479166ac8b86fba9d
Merge: ed55b4c 44caa96
Author: Ted Zlatanov <address@hidden>
Commit: Ted Zlatanov <address@hidden>

    Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
---
 doc/lispref/display.texi |   13 +++++++++++++
 lisp/descr-text.el       |    4 ++--
 lisp/svg.el              |   23 +++++++++++++++++++++++
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index a7c1d09..575cad8 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5350,6 +5350,19 @@ that describe the outer circumference of the polygon.
 @end lisp
 @end defun
 
address@hidden svg-embed svg image image-type datap &rest args
+Add an embedded (raster) image to @var{svg}.  If @var{datap} is
address@hidden, @var{IMAGE} should be a file name; if not, it should be a
+binary string containing the image data.  @var{image-type} should be a
address@hidden image type, for instance @samp{"image/jpeg"}.
+
address@hidden
+(svg-embed svg "~/rms.jpg" "image/jpeg" nil
+           :width "100px" :height "100px"
+           :x "50px" :y "75px")
address@hidden lisp
address@hidden defun
+
 Finally, the @code{svg-image} takes an SVG object as its parameter and
 returns an image object suitable for use in functions like
 @code{insert-image}.  Here's a complete example that creates and
diff --git a/lisp/descr-text.el b/lisp/descr-text.el
index 5288208..6c7983a 100644
--- a/lisp/descr-text.el
+++ b/lisp/descr-text.el
@@ -277,12 +277,12 @@ This function is semi-obsolete.  Use 
`get-char-code-property'."
                            'general-category (intern val))
                           val)))
               (list "Combining class"
-                    (let ((val (nth 1 fields)))
+                    (let ((val (nth 2 fields)))
                       (or (char-code-property-description
                            'canonical-combining-class (intern val))
                           val)))
               (list "Bidi category"
-                    (let ((val (nth 1 fields)))
+                    (let ((val (nth 3 fields)))
                       (or (char-code-property-description
                            'bidi-class (intern val))
                           val)))
diff --git a/lisp/svg.el b/lisp/svg.el
index c4f3270..c33b092 100644
--- a/lisp/svg.el
+++ b/lisp/svg.el
@@ -137,6 +137,18 @@ POINTS is a list of x/y pairs."
                            ", "))
       ,@(svg--arguments svg args)))))
 
+(defun svg-embed (svg image image-type datap &rest args)
+  "Insert IMAGE into the SVG structure.
+IMAGE should be a file name if DATAP is nil, and a binary string
+otherwise.  IMAGE-TYPE should be a MIME image type, like
+\"image/jpeg\" or the like."
+  (svg--append
+   svg
+   (dom-node
+    'image
+    `((xlink:href . ,(svg--image-data image image-type datap))
+      ,@(svg--arguments svg args)))))
+
 (defun svg--append (svg node)
   (let ((old (and (dom-attr node 'id)
                  (dom-by-id svg
@@ -147,6 +159,17 @@ POINTS is a list of x/y pairs."
       (dom-append-child svg node)))
   (svg-possibly-update-image svg))
 
+(defun svg--image-data (image image-type datap)
+  (with-temp-buffer
+    (set-buffer-multibyte nil)
+    (if datap
+        (insert image)
+      (insert-file-contents image))
+    (base64-encode-region (point-min) (point-max) t)
+    (goto-char (point-min))
+    (insert "data:" image-type ";base64,")
+    (buffer-string)))
+
 (defun svg--arguments (svg args)
   (let ((stroke-width (or (plist-get args :stroke-width)
                          (dom-attr svg 'stroke-width)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]