summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/grph-inc.lmt
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2021-03-25 14:12:41 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2021-03-25 14:12:41 +0100
commitcaef1259af1c843232dfbf5efc65adcf83d67f6f (patch)
treedb2a4b76d4d14ca03d21e0bbf37c42759dda31a7 /tex/context/base/mkxl/grph-inc.lmt
parentcb28e8807d7908cc9644c2bd77c9d214dd8caefe (diff)
downloadcontext-caef1259af1c843232dfbf5efc65adcf83d67f6f.tar.gz
2021-03-25 14:03:00
Diffstat (limited to 'tex/context/base/mkxl/grph-inc.lmt')
-rw-r--r--tex/context/base/mkxl/grph-inc.lmt85
1 files changed, 85 insertions, 0 deletions
diff --git a/tex/context/base/mkxl/grph-inc.lmt b/tex/context/base/mkxl/grph-inc.lmt
index 4fa562cb8..2066b31b0 100644
--- a/tex/context/base/mkxl/grph-inc.lmt
+++ b/tex/context/base/mkxl/grph-inc.lmt
@@ -2158,3 +2158,88 @@ implement {
end
end
}
+
+-- for the moment we keep this here:
+
+do
+
+ local stores = setmetatableindex("table")
+ local defaultwidth = 6553600 -- maybe bp
+
+ function images.resetstore(name)
+ stores[name] = { }
+ end
+
+ local function resetdata(name,n)
+ local store = stores[name]
+ store[n] = false
+ end
+
+ local function storedata(name,data)
+ local store = stores[name]
+ store[#store+1] = data
+ return #store
+ end
+
+ local function fetchdata(name,n)
+ local store = stores[name]
+ return store and store[n]
+ end
+
+ images.storedata = storedata
+ images.fetchdata = fetchdata
+ images.resetdata = resetdata
+
+ -- function images.filetostore(name,kind,filename)
+ -- return storedata(name, {
+ -- data = io.loaddata(filename),
+ -- kind = kind or file.suffix(filename),
+ -- })
+ -- end
+ --
+ -- function images.datatostore(name,kind,data)
+ -- return storedata(name, {
+ -- data = data,
+ -- kind = kind,
+ -- })
+ -- end
+
+ -- local embedimage = images.embed
+ -- local wrapimage = images.wrap
+
+ function images.embedfromstore(name,n,reset)
+ local blob = fetchdata(name,n)
+ if blob then
+ local kind = blob.kind
+ if kind then
+ local identify = graphics.identifiers[kind]
+ local inject = backends.codeinjections[kind]
+ if identify and inject then
+ local info = blob.info or identify(blob.data,"string") -- could already be done
+ if info then
+ info.width = defaultwidth
+ info.height = (info.ysize /info.xsize) * defaultwidth
+ local image = blob.image
+ if not image then
+ image = inject(info,"string")
+ blob.image = image
+ end
+ image.width = info.width
+ image.height = info.height
+ context(wrapimage(image))
+ -- if reset then
+ -- resetdata(name,n)
+ -- end
+ end
+ end
+ end
+ end
+ end
+
+ implement {
+ name = "embedimagefromstore",
+ arguments = { "string", "integer", "boolean" },
+ actions = images.embedfromstore,
+ }
+
+end