1if not modules then modules = { } end modules ['grph-raw'] = {
2 version = 1.001,
3 comment = "companion to grph-raw.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9
10
11
12
13local tonumber = tonumber
14
15local report_bitmap = logs.reporter("graphics","bitmaps")
16
17local context = context
18local texsp = tex.sp
19
20function figures.bitmapimage(t)
21 local data = t.data
22 local xresolution = tonumber(t.xresolution)
23 local yresolution = tonumber(t.yresolution)
24 if data and xresolution and yresolution then
25 local width = t.width or ""
26 local height = t.height or ""
27 local n = backends.nodeinjections.injectbitmap {
28 xresolution = xresolution,
29 yresolution = yresolution,
30 width = width ~= "" and texsp(width) or nil,
31 height = height ~= "" and texsp(height) or nil,
32 data = data,
33 colorspace = t.colorspace,
34 format = t.format,
35 }
36 if n then
37
38 context(nodes.hpack(n))
39 else
40 report_bitmap("format no supported by backend")
41 end
42 else
43 report_bitmap("invalid specification")
44 end
45end
46
47interfaces.implement {
48 name = "bitmapimage",
49 actions = figures.bitmapimage,
50 arguments = {
51 {
52 { "data" },
53 { "colorspace" },
54 { "width" },
55 { "height" },
56 { "xresolution" },
57 { "yresolution" },
58 }
59 }
60}
61 |