grph-raw.lua /size: 1708 b    last modification: 2020-07-01 14:35
1
if
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
-- This module is for Mojca, who wanted something like this for
10
-- her gnuplot project. It's somewhat premliminary code but it
11
-- works ok for that purpose.
12 13
local
tonumber
=
tonumber
14 15
local
report_bitmap
=
logs
.
reporter
(
"
graphics
"
,
"
bitmaps
"
)
16 17
local
context
=
context
18
local
texsp
=
tex
.
sp
19 20
function
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
42
end
43 44
interfaces
.
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