Difference between revisions of "Command/bitmapimage"

From Wiki
Jump to navigation Jump to search
(Created page with "Documentation for \bitmapimage")
 
 
(3 intermediate revisions by the same user not shown)
Line 14: Line 14:
 
     </cd:parameter>
 
     </cd:parameter>
 
     <cd:parameter name="width">
 
     <cd:parameter name="width">
       <cd:paramdoc></cd:paramdoc>
+
       <cd:paramdoc>width of the produced bitmap</cd:paramdoc>
 
       <cd:constant type="cd:dimension"></cd:constant>
 
       <cd:constant type="cd:dimension"></cd:constant>
 
     </cd:parameter>
 
     </cd:parameter>
 
     <cd:parameter name="height">
 
     <cd:parameter name="height">
       <cd:paramdoc></cd:paramdoc>
+
       <cd:paramdoc>height of the produced bitmap</cd:paramdoc>
 
       <cd:constant type="cd:dimension"></cd:constant>
 
       <cd:constant type="cd:dimension"></cd:constant>
 
     </cd:parameter>
 
     </cd:parameter>
 
     <cd:parameter name="x">
 
     <cd:parameter name="x">
       <cd:paramdoc></cd:paramdoc>
+
       <cd:paramdoc>number of pixel in the x direction</cd:paramdoc>
 
       <cd:constant type="cd:number"></cd:constant>
 
       <cd:constant type="cd:number"></cd:constant>
 
     </cd:parameter>
 
     </cd:parameter>
 
     <cd:parameter name="y">
 
     <cd:parameter name="y">
       <cd:paramdoc></cd:paramdoc>
+
       <cd:paramdoc>number of pixel in the y direction</cd:paramdoc>
 
       <cd:constant type="cd:number"></cd:constant>
 
       <cd:constant type="cd:number"></cd:constant>
 
     </cd:parameter>
 
     </cd:parameter>
 
     </cd:assignments>
 
     </cd:assignments>
 
     <cd:keywords delimiters="braces" ordinal="2">
 
     <cd:keywords delimiters="braces" ordinal="2">
     <cd:keywordsdoc></cd:keywordsdoc>
+
     <cd:keywordsdoc>Concatenated strings giving for each pixel, the color code. For example, in rgb mode : "FF0000" for a first red pixel, then  "00FF00" for a second green pixel,... At the end you should provide a string like "FF000000FF00..."
 +
</cd:keywordsdoc>
 
     <cd:constant type="cd:number"></cd:constant>
 
     <cd:constant type="cd:number"></cd:constant>
 
     </cd:keywords>
 
     </cd:keywords>
Line 39: Line 40:
 
<cd:description><!-- the long description of the command goes here -->
 
<cd:description><!-- the long description of the command goes here -->
 
</cd:description>
 
</cd:description>
<cd:examples><cd:example title="">%<context source="yes">
+
<cd:examples><cd:example title=""><context source="yes">
 
\bitmapimage[x=2,  y=2,  width=4cm, height=4cm,color=rgb]{44000088000CC00000FF0000}
 
\bitmapimage[x=2,  y=2,  width=4cm, height=4cm,color=rgb]{44000088000CC00000FF0000}
 
</context>
 
</context>
</cd:example></cd:examples>
+
</cd:example><cd:example title="With lua, you can obtain all you want">Since you're unlikely to define bitmap images by hand, you'll probably prefer to use lua :-)
 +
 
 +
<context source="yes">
 +
\startluacode
 +
function document.TestBitmap(nx,ny)
 +
  local r = { }
 +
  for i=1,nx do
 +
    for j=1,ny do
 +
      r[#r+1] = string.format("%02x%02x%02x",
 +
                              math.floor(i/nx*255),
 +
                              math.floor(j/nx*255),
 +
                              0)
 +
    end
 +
  end
 +
  r = table.concat(r,"\r",1,nx*ny)
 +
  context(r)
 +
end
 +
\stopluacode
 +
 
 +
 
 +
\bitmapimage[x=100,y=100,width=4cm, height=4cm,color=rgb]{\ctxlua{document.TestBitmap(100,100)}}
 +
 
 +
\stoptext
 +
</context></cd:example></cd:examples>
 
<cd:notes></cd:notes>
 
<cd:notes></cd:notes>
 
<cd:seealso>
 
<cd:seealso>

Latest revision as of 17:27, 8 May 2024


\bitmapimage

Summary

The command \bitmapimage is used to produce bitmap image giving color code for each pixel, from left ro right and top to bottom.

Settings

\bitmapimage[...=...,...]{...}
colorrgb cmyk gray
widthdimension
heightdimension
xnumber
ynumber
{...}number

OptionExplanation
width
width of the produced bitmap
height
height of the produced bitmap
x
number of pixel in the x direction
y
number of pixel in the y direction
Concatenated strings giving for each pixel, the color code. For example, in rgb mode : "FF0000" for a first red pixel, then "00FF00" for a second green pixel,... At the end you should provide a string like "FF000000FF00..."

Description

Examples

Example 1

\bitmapimage[x=2,  y=2,  width=4cm, height=4cm,color=rgb]{44000088000CC00000FF0000}

With lua, you can obtain all you want

Since you're unlikely to define bitmap images by hand, you'll probably prefer to use lua :-)

\startluacode
function document.TestBitmap(nx,ny)
  local r = { }
  for i=1,nx do
    for j=1,ny do
      r[#r+1] = string.format("%02x%02x%02x",
                              math.floor(i/nx*255),
                              math.floor(j/nx*255),
                              0)
    end
  end
  r = table.concat(r,"\r",1,nx*ny)
  context(r)
end
\stopluacode


\bitmapimage[x=100,y=100,width=4cm, height=4cm,color=rgb]{\ctxlua{document.TestBitmap(100,100)}}

\stoptext

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: