diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua b/Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua index 49cc7687111..34925fddd98 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/lpdf-grp.lua @@ -29,10 +29,6 @@ local pdfboolean = lpdf.boolean local pdfreference = lpdf.reference local pdfflushobject = lpdf.flushobject -local createimage = images.create -local wrapimage = images.wrap -local embedimage = images.embed - -- can also be done indirectly: -- -- 12 : << /AntiAlias false /ColorSpace 8 0 R /Coords [ 0.0 0.0 1.0 0.0 ] /Domain [ 0.0 1.0 ] /Extend [ true true ] /Function 22 0 R /ShadingType 2 >> @@ -157,18 +153,13 @@ function nodeinjections.injectbitmap(t) elseif height == 0 then height = width * yresolution / xresolution end - local a = pdfdictionary { - BBox = pdfarray { 0, 0, urx * basepoints, ury * basepoints } - } - local image = createimage { + local image = img.new { stream = formatters[template](d(),t.data), width = width, height = height, bbox = { 0, 0, urx, ury }, - attr = a(), - nobbox = true, } - return wrapimage(image) + return img.node(image) end -- general graphic helpers @@ -190,7 +181,7 @@ function codeinjections.setfigurealternative(data,figure) local displayfigure = figures.check() if displayfigure then -- figure.aform = true - embedimage(figure) + img.immediatewrite(figure) local a = pdfarray { pdfdictionary { Image = pdfreference(figure.objnum), @@ -224,14 +215,14 @@ function codeinjections.getpreviewfigure(request) end local image = figure.status.private if image then - embedimage(image) + img.immediatewrite(image) end return figure end function codeinjections.setfiguremask(data,figure) -- mark local request = data.request - local mask = request.mask + local mask = request.mask if mask and mask ~= "" then figures.push { name = mask, @@ -242,16 +233,15 @@ function codeinjections.setfiguremask(data,figure) -- mark width = request.width, height = request.height, } - mask = figures.identify() - mask = figures.check(mask) - if mask then - local image = mask.status.private + figures.identify() + local maskfigure = figures.check() + if maskfigure then + local image = maskfigure.status.private if image then - figures.include(mask) - embedimage(image) + img.immediatewrite(image) local d = pdfdictionary { Interpolate = false, - SMask = pdfreference(mask.status.objectnumber), + SMask = pdfreference(image.objnum), } figure.attr = d() end @@ -260,16 +250,39 @@ function codeinjections.setfiguremask(data,figure) -- mark end end --- experimental (q Q is not really needed) +-- temp hack -local f_pattern = formatters["q /Pattern cs /%s scn 0 0 %.6F %.6F re f Q"] +function img.package(image) -- see lpdf-u3d ** + local boundingbox = image.bbox + local imagetag = "Im" .. image.index + local resources = pdfdictionary { + ProcSet = pdfarray { + pdfconstant("PDF"), + pdfconstant("ImageC") + }, + Resources = pdfdictionary { + XObject = pdfdictionary { + [imagetag] = pdfreference(image.objnum) + } + } + } + local width = boundingbox[3] + local height = boundingbox[4] + local xform = img.scan { + attr = resources(), + stream = formatters["%.6F 0 0 %.6F 0 0 cm /%s Do"](width,height,imagetag), + bbox = { 0, 0, width/basepoints, height/basepoints }, + } + img.immediatewrite(xform) + return xform +end -directives.register("pdf.stripzeros",function() - f_pattern = formatters["q /Pattern cs /%s scn 0 0 %.6N %.6N re f Q"] -end) +-- experimental -local saveboxresource = tex.boxresources.save -local nofpatterns = 0 +local nofpatterns = 0 +local f_pattern = formatters["q /Pattern cs /%s scn 0 0 %.6F %.6F re f Q"] -- q Q is not really needed + +local texsavebox = tex.saveboxresource function lpdf.registerpattern(specification) nofpatterns = nofpatterns + 1 @@ -286,11 +299,10 @@ function lpdf.registerpattern(specification) (specification.voffset or 0) * basepoints, }, } - local resources = lpdf.collectedresources{ patterns = false } local attributes = d() local onlybounds = 1 - local patternobj = saveboxresource(specification.number,attributes,resources,true,onlybounds) + local patternobj = texsavebox(specification.number,attributes,resources,true,onlybounds) lpdf.adddocumentpattern("Pt" .. nofpatterns,lpdf.reference(patternobj )) return nofpatterns end |