1%D \module 2%D [ file=grph-raw, 3%D version=2006.08.26, % overhaul of 1997.03.31 4%D title=\CONTEXT\ Graphic Macros, 5%D subtitle=Raw Bitmaps, 6%D author=Hans Hagen, 7%D date=\currentdate, 8%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] 9%C 10%C This module is part of the \CONTEXT\ macro||package and is 11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for 12%C details. 13 14\writestatus{loading}{ConTeXt Graphic Macros / Raw Bitmaps} 15 16%D \startluacode 17%D function document.TestBitmap(nx,ny) 18%D local random = math.random 19%D local maxbit = 2^24 20%D for i=1,nx do 21%D for i=1,ny do 22%D context("%06x",random(0,maxbit)) 23%D end 24%D end 25%D end 26%D \stopluacode 27%D 28%D \def\TestBitmap#1#2{\ctxlua{document.TestBitmap(#1,#2)}} 29%D 30%D \blank 31%D 32%D \startMPcode 33%D draw textext("\bitmapimage[x=100,y=100]{\TestBitmap{100}{100}}") xsized 10cm ; 34%D \stopMPcode 35%D 36%D \blank 37%D 38%D \startMPcode 39%D draw textext("\bitmapimage[x=200,y=50]{\TestBitmap{50}{200}}") xsized 10cm ; 40%D \stopMPcode 41 42\registerctxluafile{grph-raw}{} 43 44\unprotect 45 46\unexpanded\def\bitmapimage[#1]#2% 47 {\hbox\bgroup 48 \getdummyparameters[\c!color=rgb,\c!width=,\c!height=,\c!x=,\c!y=,#1]% 49 \clf_bitmapimage 50 data {#2}% 51 colorspace {\directdummyparameter\c!color}% 52 width {\directdummyparameter\c!width}% 53 height {\directdummyparameter\c!height}% 54 xresolution {\directdummyparameter\c!x}% 55 yresolution {\directdummyparameter\c!y}% 56 \relax 57 \egroup} 58 59\unexpanded\def\startbitmapimage[#1]#2\stopbitmapimage 60 {\bitmapimage[#1]{#2}} 61 62\let\stopbitmapimage\relax 63 64\protect \endinput 65 |