aboutsummaryrefslogtreecommitdiffstats
path: root/lib/percept/doc/src/img_esi.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/percept/doc/src/img_esi.erl')
-rw-r--r--lib/percept/doc/src/img_esi.erl25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/percept/doc/src/img_esi.erl b/lib/percept/doc/src/img_esi.erl
new file mode 100644
index 0000000000..e9796819c0
--- /dev/null
+++ b/lib/percept/doc/src/img_esi.erl
@@ -0,0 +1,25 @@
+-module(img_esi).
+
+-export([image/3]).
+
+image(SessionID, _Env, _Input) ->
+ mod_esi:deliver(SessionID, header()),
+ Binary = my_image(),
+ mod_esi:deliver(SessionID, binary_to_list(Binary)).
+
+my_image() ->
+ Im = egd:create(300,20),
+ Black = egd:color({0,0,0}),
+ Red = egd:color({255,0,0}),
+ egd:filledRectangle(Im, {30,14}, {270,19}, Red),
+ egd:rectangle(Im, {30,14}, {270,19}, Black),
+
+ Filename = filename:join([code:priv_dir(percept), "fonts", "6x11_latin1.wingsfont"]),
+ Font = egd_font:load(Filename),
+ egd:text(Im, {30, 0}, Font, "egd with esi callback", Black),
+ Bin = egd:render(Im, png),
+ egd:destroy(Im),
+ Bin.
+
+header() ->
+ "Content-Type: image/png\r\n\r\n".