I've made a little progress.  That unicode character  - 0xfffc - is only a 
marker and does not carry any information about the image.  But behind the 
scenes, Qt keeps the image data and associates it with that marker.  The 
actual image bits are stored in Qt's "resources" for the page, and 
identified by a string.  One way to get the image data is to have the 
QTextEditor/QTextBrowser give you the contents as markdown or html, then 
parse that for image identifiers.  With the identifiers we can get the 
images from the resource system (though I don't know all the details for 
doing that yet).  The image data can be converted to a base64 string, and 
we could store that string in the node's UAs.  When the outline is loaded, 
new code could look through the UA data to see what image data to get and 
where to put it, then insert the images.  We should probably include a flag 
so that we can avoid spending time checking nodes that don't have any image 
data.

One drawback would be that if an external file were edited outside of Leo, 
the images might end up in the wrong places or even get deleted by 
mistake.  But my guess is that the kind of files that might get edited 
outside of Leo won't have any images anyway.

On Tue, Mar 28, 2023 at 5:04 PM Thomas Passin <tbp1...@gmail.com> wrote:

It would be very useful if an image could be embedded into a Leo body.  
Probably no one would want to do this in a program or script, but for 
documentation it could be very helpful.

... 

In theory it should be possible to put an image into a Leo node.  Qt has a 
way to do it, and I have written a little test Qt program that can put one 
into a QTextBrowser or a QTextEdit widget at the cursor location.

The way Qt does it is to insert a special Unicode character:


-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/c89d8f43-f209-44ec-8157-c1ae22cea2c9n%40googlegroups.com.

Reply via email to