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, height = t.width or "", t.height or ""
26 local n = backends.nodeinjections.injectbitmap {
27 xresolution = xresolution,
28 yresolution = yresolution,
29 width = width ~= "" and texsp(width) or nil,
30 height = height ~= "" and texsp(height) or nil,
31 data = data,
32 colorspace = t.colorspace,
33 }
34 if n then
35 context.hbox(n)
36 else
37 report_bitmap("format no supported by backend")
38 end
39 else
40 report_bitmap("invalid specification")
41 end
42end
43
44interfaces.implement {
45 name = "bitmapimage",
46 actions = figures.bitmapimage,
47 arguments = {
48 {
49 { "data" },
50 { "colorspace" },
51 { "width" },
52 { "height" },
53 { "xresolution" },
54 { "yresolution" },
55 }
56 }
57}
58 |