| Chỉ mục bài viết |
|---|
| mimeTeX - Hiển thị toán học trên website |
| mimeTeX page 2 |
| mimeTeX page 3 |
| mimeTeX page 4 |
| Tất cả các trang |
(IIIf) \picture( ){ } "Environment", including \line( ){ } and \circle( )
Besides \begin{array}{lcr}, mimeTeX also tries to emulate the familiar LaTeX picture environment with the somewhat similar
\picture(width[,height]) { (loc1){pic_elem1} (loc2){pic_elem2} ... }
as illustrated by Examples 12-13 above. Arguments surrounded by [ ]'s are optional. If the optional [,height] is omitted, then height=width is assumed. Locations (loc1) and (loc2) ... each denote either a \put(loc) or a \multiput(loc), and each location is of the form ([c]x,y[;xinc,yinc[;num]]).
A \put(loc) is denoted by a location of the form ([c]x,y) where x,y denotes the coordinate where the lower-left corner of the subsequent picture_element will be placed, unless the letter c precedes the x-number, in which case cx,y denotes the center point instead. The very lower-left corner of the entire picture is always 0,0, and the upper-right corner is width-1,height-1. Note, for example, that you'd never want to specify location c0,0 since the picture_element would be mostly out-of-bounds (only its upper-right quadrant would be in-bounds).
A \multiput(loc) starts like a \put(loc), but location [c]x,y is followed by ;xinc,yinc[;num] indicating the x,y-increments applied to each of num repetitions of picture_element. If ;num is omitted, repetitions continue until the picture_element goes out-of-bounds of the specified width[,height]. Note that x,y are always positive or zero, but xinc,yinc may be postive, zero or negative.
The \picture(,){...} parameters width, height, x, y, xinc, yinc may be either integer or may contain a decimal point, and they're all scaled by \unitlength. The num parameter must be integer.
Picture_element's {pic_elem1} and {pic_elem2} ... may be any expressions recognized by mimeTeX, even including other \picture's nested to any level.
\line( ){ } and \circle( )...
To help draw useful picture_element's, mimeTeX provides several drawing commands, \line(xinc,yinc)[{xlen}] and \circle(xdiam[,ydiam][;arc]). Although primarily intended for use in \picture's, you can use them in any mimeTeX expression, e.g., abc\circle(20)def produces .
Without its optional {xlen} parameter, the expression (x,y){\line(xinc,yinc)} draws a straight line from point x,y to point x+xinc,y+yinc. The inc's can be positive, zero or negative. Don't prefix location x,y with a leading c for \line's; the intended "corner" is determined by the signs of xinc and yinc. If given, the optional {xlen} parameter rescales the length of the line so its x-projection is xlen and its slope is unchanged.
Without optional ,ydiam and ;arc, the expression (x,y){\circle(xdiam)} draws a circle of diameter xdiam centered at x,y. Don't prefix location x,y with a leading c for \circle's; centering is assumed. If ,ydiam is also given, then (x,y){\circle(xdiam,ydiam)} draws the ellipse inscribed in a rectangle of width xdiam and height ydiam centered at x,y.
Finally, ;arc specifies the arc to be drawn, in one of two ways. An ;arc argument given in the form ;1234 interprets each digit as a quadrant to be drawn, with 1 the upper-right quadrant and then proceeding counterclockwise, e.g., \circle(12;34) specifies the lower half of a circle whose diameter is twelve.
Alternatively, an ;arc argument given in the form 45,180 or -60,120 specifies the endpoints of the desired arc in degrees, with 0 the positive x-axis and then proceeding counterclockwise. The first number must always be smaller than the second (negative numbers are allowed), and the arc is drawn counterclockwise starting from the smaller number.
Besides Examples 12-13 above, it's hard to resist illustrating
\unitlength{.6} \picture(100) {
(50,50){\circle(99)} %%head%%
(20,55;50,0;2){\fs{+1}\hat\bullet} %%eyes%%
(50,40){\bullet} %%nose%%
(50,35){\circle(50,25;34)} %%upper lip%%
(50,35){\circle(50,45;34)} %%lower lip%% }
(IIIg) Other mimeTeX Commands
Various and sundry other LaTeX-like commands are also provided by mimeTeX. In addition to features explicitly discussed below, mimeTeX supports the usual sub_scripts and super^scripts, and most of the typical LaTeX commands, many already discussed above, including
- \frac{ }{ } and { \over }
- { \atop } and { \choose }
- \sqrt{ }
- \lim_{ } and all the usual LaTeX function names
- \hat{ } and \widehat{ } and many of the usual LaTeX accents
- \overbrace{ }^{ } and \underbrace{ }_{ }
- \overline{ } and \underline{ }
All these typical commands should behave as they usually do in LaTeX, and won't be discussed further. Short discussions of some other commands follow.
\overset{ }{ } or \stackrel{ }{ } and \underset{ }{ } or \relstack{ }{ } ...
\stackrel{ }{ } behaves as usual in LaTeX, rendering its first argument one font size smaller and centered above its second. And the amsmath-style \overset{ }{ } is identical. For example,
"\vec x\overset{\rm def}=(x_1\ldots x_n)" produces
"Conversely" to \stackrel{ }{ }, mimeTeX provides \relstack{ }{ }, which renders its second argument one font size smaller and centered below its first. And the amsmath-style \underset{ }{ } renders its first argument one font size smaller and centered below its second. For example, the \log function name doesn't treat limits like \lim_, but you can write, for example,
"\underset{\rm base 2}\log32=5" to render
MimeTeX's \limits provides an easier but non-standard alternative to achieve the same effect. For example,
"\vec x =\limits^{\rm def} (x_1\ldots x_n)" produces
and "\log\limits_{\rm base 2}32=5" produces
\fbox{ }...
In case html border attributes aren't suitable, mimeTeX provides the usual \fbox{expression} command, e.g.,
You can also write \fbox[width]{expression} to explicitly set the box's width, or you can write \fbox[width][height]{expression} to explicitly set both width and height.
\today and \calendar...
\today renders in the usual LaTeX text mode way. That's \today's default format#1. MimeTeX has an optional format argument so that, for example, \blue\today[2] renders
, showing both date and time. And \red\today[3] renders
, showing time only.
To accommodate time zones, you may also write, for example, \small\blue\today[2,+3], which renders , adding three hours to format#2. The arguments may be in either order. The time zone increment must always be preceded by either + or -, and must be in the range -23 to +23.
\calendar renders a calendar for the current month, as illustrated by the left-hand image below. For a different month, the optional argument \small\blue\calendar[2001,9] renders the right-hand image, for the requested year and month. Years must be 1973...2099 and months must be 1...12.
The default calendar emphasizes the current day of the current month, while any other month emphasizes no day. Day emphasis is controlled by an optional third argument. \calendar[0,0,1] emphasizes the first day of the current month, and \calendar[2001,9,11] emphasizes the eleventh day of that month. \calendar[0,0,99] renders the current month with no day emphasized.
\input{ }...
\input{filename} behaves just like the corresponding LaTeX command, reading the entire contents of filename into your expression at the point where the \input command occurs. By default, filename resides in the same directory as mimetex.cgi. Moreover, for security, absolute paths with leading /'s or \'s, and paths with ../'s or ..\'s, are not permitted. See the -DPATHPREFIX compile option, discussed above, if you want \input files in some other directory. In any case, if filename isn't found, then \input tries to read filename.tex instead.
And for further security, \input{ } is disabled by default unless mimeTeX is compiled with either the -DINPUTOK or -DINPUTPATH or -DINPUTREFERER compile option discussed above. When it's disabled, the command \input{filename} renders the error message [\input{filename} not permitted] .
MimeTeX also supports the optional form \input{filename:tag}. In this case, filename is read as before, but only those characters between <tag>...</tag> are placed into your expression. This permits you to have one file containing many different <tag>'s, e.g., one file containing all the questions and/or answers to a homework assignment or a quiz, etc.
\counter[ ]{ } ...
The bottom-right corner of this page contains a page hit counter that's maintained using mimeTeX's \counter[logfile]{counterfile:tag} command. As with \input, described immediately above, both the required counterfile and the optional logfile are the names of files that reside in the same directory as your mimetex.cgi executable, unless you compiled mimetex with the -DPATHPREFIX compile option. Before using the \counter command, Unix "touch" and "chmod" those files so they're mimeTeX readable and writable.
Also as with \input, for security \counter is disabled by default unless mimeTeX is compiled with either the -DINPUTOK or the -DCOUNTEROK compile option (notice that -DINPUTOK also enables \counter). If you've compiled mimeTeX with \counter enabled, then it behaves as follows...
If counterfile isn't readable and writable, then the \counter command always displays 1st. Otherwise, it maintains a line in counterfile of the form <tag> value </tag> where value is initialized as 1_ if the specified <tag> line doesn't already exist, and then incremented on each subsequent call. That trailing underscore on the value in the file, e.g., 99_, tells mimeTeX to display 99th with an ordinal suffix. Edit the value in the file and remove the underscore if you don't want the ordinal suffix displayed. Finally, mimeTeX makes no effort to lock files or records (tags), so be careful using \counter if your hit rates are high enough so that frequent collisions are likely.
The same counterfile can contain as many different <tag> lines as you like, so counters for all the pages on your site can be maintained in one file. MimeTeX also maintains a special <timestamp> tag in counterfile that logs the the date/time and name of the most recently updated tag.
Somewhat more detailed log information can be accumulated in the optional logfile. If you provide that filename, mimeTeX writes a line to it of the form 2008-09-07:12:59:33pm <tag>=99 192.168.1.1 http_referer containing a timestamp, the counter tag and its current value, and the user's IP address and http_referer page if they're available.
The page hit counter displayed at the bottom-right corner of this page is maintained by the command \counter[counters.log]{counters.txt:mimetex.html}. After compiling and installing your own mimetex.cgi and your own copy of this page, that counter will continually show 1st's unless/until you "touch" and "chmod" counters.txt (and, optionally, counters.log) in your mimetex.cgi directory.
\environment ...
Submitting the expression \environment to mimeTeX renders
displaying the http environment variables known to mimeTeX. This is primarily a programming aid, showing information available to mimeTeX that might facilitate future enhancements.
As with \input and \counter above, for security \environment is disabled by default unless mimeTeX is compiled with either the -DINPUTOK or the -DENVIRONOK compile option (notice that -DINPUTOK also enables \environment).
(IIIh) Other Exceptions to LaTeX Syntax
Binding Exceptions...
MimeTeX's bindings are pretty much left-to-right. For example, although mimeTeX correctly interprets \frac12 as well as \frac{1}{2}, etc, the legal LaTeX expression x^\frac12 must be written x^{\frac12}. Otherwise, mimeTeX interprets it as {x^\frac}12, i.e., the same way x^\alpha12 would be interpreted, which is entirely wrong for \frac. The same requirement also applies to other combinations of commands, e.g., you must write \sqrt{\frac\alpha\beta}, etc.
(IIIi) mimeTeX Errors and Messages
mimeTeX Errors...
Any (La)TeX error is typically also a mimeTeX error. However, mimeTeX has no command line interface or .log file for reporting errors. Its only communication with you is through the mimeTeX image rendered by your browser. So error messages are embedded in that image whenever feasible. For example, suppose you want to see , but you mistakenly type \alpha\bethe\gamma\delta instead. Then the image rendered is
, indicating the unrecognized [\bethe?] where you wanted to type \beta and hoped to see
. If your expression contains some unprintable character (meaning any character mimeTeX has no bitmap for), then just
is displayed in the corresponding position.
The preceding example illustrates a pretty trivial error. Any non-trivial errors in your expression are likely to go unrecognized and unreported by mimeTeX, and to render unexpected images. While checking your input expression for syntax errors, keep in mind the following points about mimeTeX's behavior:
- An unmatched left brace { is matched by mimeTeX with a "phantom" right brace } that's imagined to be at the end of your expression.
- Likewise, an unmatched \left(, or \left\{ or \left\anything, is matched by mimeTeX with a "phantom" \right. at the end of your expression.
- On the other hand, an unmatched right brace } is displayed in place, as if you had typed \rbrace.
- But an unmatched \right\anything is interpreted as an abbreviation for \rightarrow followed by \anything. For example, \leff( abc \right) def renders
.
mimeTeX Messages...
The special mimeTeX directive \version displays the following information
(IV) Appendices
Programming information to help you modify mimeTeX's behavior, and to use its functionality in your own programs, is provided by these appendices. The currently available appendices discuss (a)how to modify or extend mimeTeX's fonts, (b)how to use mimeTeX's principal function, make_raster(), and (c)how to use Sverre Huseby's gifsave.c library.
(IVa) mimeTeX Fonts
The font information mimeTeX uses to render characters is derived from .gf font files (usually generated by metafont running against .mf files), which are then run through gftype -i and finally through my gfuntype program (supplied with your mimeTeX distribution).
The final output from each such sequence of three runs (metafont > gftype -i > gfuntype) gives mimeTeX the bitmap information it needs to render one particular font family at one particular size. The file texfonts.h supplied with your mimeTeX distribution collects the output from 72 such (sequences of) runs, representing nine font families at eight sizes each.
This collection of information in texfonts.h is "wired" into mimeTeX through tables maintained in mimetex.h. To change mimeTeX's fonts, you'll have to first modify (or totally replace) texfonts.h using your own gfuntype output, and then change mimetex.h to reflect your texfonts.h modifications.
This appendix provides a brief description of the above process, though you'll probably need at least some previous C programming experience to confidently accomplish it. Your motivation might be to add more fonts to mimeTeX, to change the font sizes I chose, or to add more font sizes, etc. MimeTeX's design permits all this to be easily done once you understand the process.
Running metafont to generate a .gf file from .mf source will usually be your very first step. A typical such run might be
mf '\mode=preview; mag=magstep(-16.393225); input cmmi10'
which in this case generates output file cmmi10.131gf (which is mimeTeX's font size 3 for the cmmi family).
Given the cmmi10.131gf file from this metafont run (or substitute any other .gf file you like), next run
gftype -i cmmi10.131gf > typeout
where typeout can be any temporary filename you like.
Finally, run gfuntype against the typeout file you just generated with the command
gfuntype -n cmmi131 typeout cmmi131.h
to generate the final output file cmmi131.h (or any filename you supply as the last arg). This contains the cmmi data in an array whose name is taken from the -n arg you supplied to gfuntype.
The above sequence of three runs resulted in output file cmmi131.h, containing the font information mimeTeX needs for one font family (cmmi) at one font size (3). Repeat this sequence of three runs for each font size and each font family. Then pull all the output files into one big texfonts.h file (or write a small texfonts.h which just #include's them all).
For your information, the 72 sequences of runs represented in the texfonts.h file supplied with your mimeTeX distribution correspond to the following eight inital metafont runs for cmr10
size=0 (.83gf) mf '\mode=eighthre; input cmr10'
1 (.100gf) mf '\mode=preview; mag=magstep(-17.874274); input cmr10'
2 (.118gf) mf '\mode=preview; mag=magstep(-16.966458); input cmr10'
3 (.131gf) mf '\mode=preview; mag=magstep(-16.393225); input cmr10'
4 (.160gf) mf '\mode=preview; mag=magstep(-15.296391); input cmr10'
5 (.180gf) mf '\mode=preview; mag=magstep(-14.650373); input cmr10'
6 (.210gf) mf '\mode=preview; mag=magstep(-13.804885); input cmr10'
7 (.250gf) mf '\mode=preview; mag=magstep(-12.848589); input cmr10'
Then ditto for the eight other font families cmmi10, cmmib10, cmsy10, cmex10, bbold10, rsfs10, stmary10 and wncyr10. And to generate other .dpigf font sizes, calculate magsteps . All the subsequent gftype and gfuntype runs just follow the standard format described above.
To incorporate all this font information you just generated into mimeTeX, edit your mimetex.h file and find the table that looks something like
static fontfamily aafonttable[] = {
/* ----------------------------------------------------------------------------------------
family size=0, 1, 2, 3, 4, 5, 6, 7
----------------------------------------------------------------------------------------- */
{ CMR10,{ cmr83, cmr100, cmr118, cmr131, cmr160, cmr180, cmr210, cmr250}},
{ CMMI10,{ cmmi83, cmmi100, cmmi118, cmmi131, cmmi160, cmmi180, cmmi210, cmmi250}},
{ CMMIB10,{ cmmib83, cmmib100, cmmib118, cmmib131, cmmib160, cmmib180, cmmib210, cmmib250}},
{ CMSY10,{ cmsy83, cmsy100, cmsy118, cmsy131, cmsy160, cmsy180, cmsy210, cmsy250}},
{ CMEX10,{ cmex83, cmex100, cmex118, cmex131, cmex160, cmex180, cmex210, cmex250}},
{ RSFS10,{ rsfs83, rsfs100, rsfs118, rsfs131, rsfs160, rsfs180, rsfs210, rsfs250}},
{ BBOLD10,{ bbold83, bbold100, bbold118, bbold131, bbold160, bbold180, bbold210, bbold250}},
{STMARY10,{stmary83,stmary100,stmary118,stmary131,stmary160,stmary180,stmary210,stmary250}},
{ CYR10,{ wncyr83, wncyr100, wncyr118, wncyr131, wncyr160, wncyr180, wncyr210, wncyr250}},
{ -999,{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}}
} ; /* --- end-of-fonttable[] --- */
Note the 72 names cmr83...wncyr250 in the table. These must correspond to (or must be changed to) the names following the -n switch you specified for your gfuntype runs.
If you want more than eight font sizes, first build up texfonts.h with all the necessary information. Then change LARGESTSIZE (and probably NORMALSIZE) in mimetex.h, and finally edit the above aafonttable[] by extending the columns in each row up to your largest size.
You can also add new rows by #define'ing a new family, and then adding a whole lot of character definitions at the bottom of mimetex.h, all in the obvious way (i.e., it should become obvious after reviewing mimetex.h). A new row would be required, for example, to make another font available in mimeTeX.
One small problem with the above procedure is that the default gftype program supplied with most TeX distributions can't emit the long lines needed to display mimeTeX's larger font sizes. You'll need to compile your own version from source. The following instructions are for Unix/Linux:
First, download both web-7.5.3.tar.gz and web2c-7.5.3.tar.gz, or more recent versions. Then untar them both, cd web2c-7.5.3/ and run ./configure and make in the usual way (make may fail before completion if you don't have all needed fonts installed, but it will create and compile gftype.c before failing). Now edit texk/web2c/gftype.c and notice two lines very near the top that #define maxrow (79) and similarly for maxcol. Change both 79's to 1024, and then re-run make. The new texk/web2c/gftype executable image can emit the long lines needed for mimeTeX's larger font sizes.
Finally, the Unix/Linux bash shell script texfonts.sh generates file texfonts.h containing the information for all 72 mimeTeX fonts discussed above (and, optionally, an extra 1200dpi cmr font used to test mimeTeX's supersampling algorithm). You'll need to understand and edit this script to use it meaningfully. But it helps automate mimeTeX's font generation procedure in case you want to experiment with different fonts. (Note that metafont emits a complaint while generating the 83dpi rsfs font. Just press <CR> and it completes successfully.)
(IVb) mimeTeX's make_raster() function
MimeTeX converts an input LaTeX math expression to a corresponding GIF image in two steps. First, it converts the input LaTeX expression to a corresponding bitmap raster. Then Sverre Huseby's gifsave library, discussed below, converts that bitmap to the emitted gif. Though you never explicitly see that bitmap, it's mimeTeX's principal result. MimeTeX is written so any program can easily use its expression-to-bitmap conversion capability with just a single line of code. The following complete program demonstrates the simplest such use.
#include <stdio.h>
#include "mimetex.h"
int main ( int argc, char *argv[] )
{
raster *rp = make_raster(argv[1],NORMALSIZE);
type_raster(rp,stdout); /* display ascii image of raster */
}
Cut-and-paste the above sample code from this file to, say, mimedemo.c (and fix the brackets around stdio.h). Then compile
cc -DTEXFONTS mimedemo.c mimetex.c -lm -o mimedemo
and run it from your unix shell command line like
./mimedemo "x^2+y^2"
MimeTeX's expression-to-bitmap conversion is accomplished by the make_raster() call, whose first argument is just a pointer to a (null-terminated) string containing any mimeTeX-compliant LaTeX expression, and whose second argument is the mimeTeX font size to use (overridden if your expression contains a preamble). The ascii display of the bitmap raster returned by make_raster() results from the subsequent call to type_raster(). That's all this program does, but you could use make_raster()'s returned bitmap for any other purpose you have in mind.
MimeTeX's primary purpose is to emit either xbitmaps or gif images rather than ascii displays. And mimeTeX has anti-aliasing and various other options that further complicate its main() function compared to the simple example above. The example below demonstrates mimeTeX usage in the slightly more realistic situation where an input expression is converted to a gif, without anti-aliasing, and emitted on stdout.
#include <stdio.h>
#include <stdlib.h>
#include "mimetex.h"
/* --- global needed by callback function, below, for gifsave.c --- */
static raster *rp = NULL; /* 0/1 bitmap raster image */
/* --- callback function to return pixel value at col x, row y --- */
int GetPixel ( int x, int y ) /* pixel value will be 0 or 1 */
{ return (int)getpixel(rp,y,x); } /* just use getpixel() macro */
/* --- main() entry point --- */
int main ( int argc, char *argv[] )
{
/* --- get LaTeX expression from either browser query or command-line --- */
char *query = getenv("QUERY_STRING"), /* check for query string */
*expression = (query!=NULL? query : /* input either from query */
(argc>1? argv[1] : "f(x)=x^2")); /* or from command line */
/* ---- mimeTeX converts expression to bitmap raster ---- */
rp = make_raster(expression,NORMALSIZE); /* mimeTeX rasterizes expression */
/* ---- convert returned bitmap raster to gif, and emit it on stdout ---- */
if ( query != NULL ) /* Content-type line for browser */
fprintf( stdout, "Content-type: image/gif\n\n" );
/* --- initialize gifsave library and colors, and set transparent bg --- */
GIF_Create(NULL, rp->width, rp->height, 2, 8); /* init for black/white */
GIF_SetColor(0, 255, 255, 255); /* always set background white */
GIF_SetColor(1, 0, 0, 0); /* and foreground black */
GIF_SetTransparent(0); /* and set transparent background */
/* --- finally, emit compressed gif image (to stdout) --- */
GIF_CompressImage(0, 0, -1, -1, GetPixel);
GIF_Close();
}
Cut-and-paste as before, compile like
cc -DTEXFONTS mimedemo.c mimetex.c gifsave.c -lm -o mimedemo
and run it like the first example, but this time you may want to redirect stdout
./mimedemo "x^2+y^2" > mimedemo.gif
since output is now a gif image consisting of mostly unprintable bytes. Input is typically from the command line as illustrated, but this example checks for a browser query string too. That means you could actually replace mimetex.cgi with this executable, though anti-aliasing wouldn't be available.
Of course, this example's intent isn't to replace the mimetex.cgi executable, but rather to illustrate GIFSAVE library usage, documented in detail below. And this example also illustrates usage of several mimeTeX raster structure elements, like rp->width and rp->height. So you'll probably also want to refer to mimetex.h, which contains those raster structures and other relevant definitions. For instance, the example's GetPixel() callback function illustrates usage of the getpixel() macro in mimetex.h, to retrieve individual pixels by their x,y-coordinates. And there's a similar setpixel() macro in mimetex.h to store pixels. After completing all this reading, you'll be prepared to begin using mimeTeX functions in your own code.
(IVc) Sverre Huseby's gifsave.c library
The information below is taken from the README file accompanying Sverre Huseby's distribution of GIFSAVE. I've made a few small editorial modifications, including descriptions of the several minor changes necessary to support mimeTeX. And the mimeTeX example program immediately above uses GIFSAVE in a very straightforward way that should help clarify any questions which may remain after reading the documentation below.
INTRODUCTIONCONCLUDING REMARKS
============
The GIFSAVE functions make it possible to save GIF images from
your own C programs.
GIFSAVE creates simple GIF files following the GIF87a standard.
Interlaced images cannot be created. There should only be
one image per file.
GIFSAVE consists of five functions, all returning type int,
and no separate header file is required.
The functions should be called in the order listed below
for each GIF-file. One file must be closed before a new one
can be created.
GIF_Create() creates new GIF-files. It takes parameters
specifying filename, screen size, number of colors,
and color resolution.
GIF_SetColor() sets up red, green, blue color components.
It should be called once for each possible color.
GIF_SetTransparent() is optional. If called, it sets the
color number of the color that should be transparent,
i.e., the background color shows through this one.
GIF_CompressImage() performs the compression of the image.
It accepts parameters describing the position and size
of the image on screen, and a user defined callback
function that is supposed to fetch the pixel values.
GIF_Close() terminates and closes the file.
To use these functions, you must also write a callback
function that returns the pixel values for each point
in the image.
THE FUNCTIONS
=============
GIF_Create()
------------
Function Creates a new GIF-file, and stores info on
the screen.
Syntax int GIF_Create(
char *filename,
int width, int height,
int numcolors, int colorres
);
Remarks Creates a new (or overwrites an existing)
GIF-file with the given filename. No
.GIF-extension is added.
If filename is passed as a NULL pointer,
output is directed to stdout.
The width- and height- parameters specify
the size of the image in pixels.
numcolors is the number of colors used in
the image.
colorres is number of bits used to encode a
primary color (red, green or blue).
In GIF-files, colors are built by combining
given amounts of each primary color.
On VGA-cards, each color is built by
combining red, green and blue values in
the range [0, 63]. Encoding the number 63
would require 6 bits, so colorres would be
set to 6.
Return value GIF_OK - OK
GIF_ERRCREATE - Error creating file
GIF_ERRWRITE - Error writing to file
GIF_OUTMEM - Out of memory
GIF_SetColor()
--------------
Function Specifies the primary color component of a
color used in the image.
Syntax void GIF_SetColor(
int colornum,
int red, int green, int blue
);
Remarks This function updates the colortable-values
for color number colornum in the image.
Should be called for each color in the range
[0, numcolors]
with red, green and blue components in the
range [0, (2^colorres)-1]
colorres and colornum are values previousely
given to the function GIF_Create().
Return value None
GIF_SetTransparent()
--------------------
Function Specifies the color number of the color
that should be considered transparent.
Syntax void GIF_SetTransparent(
int colornum
);
Remarks Need not be called at all. But if called,
should be called only once with colornum in
the range [0, numcolors] i.e., colornum
must be one of the values previously
given to GIF_SetColor().
Return value None
GIF_CompressImage()
-------------------
Function Compresses an image and stores it in the
current file.
Syntax int GIF_CompressImage(
int left, int top,
int width, int height,
int (*getpixel)(int x, int y)
);
Remarks The left- and top- parameters indicate the
image offset from the upper left corner of
the screen. They also give the start values
for calls to the userdefined callback
function.
width and height give the size of the image.
A value of -1 indicates the equivalent screen
size given in the call to GIF_Create().
If the image is supposed to cover the entire
screen, values 0, 0, -1, -1 should be given.
GIF_CompressImage() obtains the pixel values
by calling a user specified function. This
function is passed in the parameter getpixel.
See "callback()" further down for a
description of this function.
Return value GIF_OK - OK
GIF_ERRWRITE - Error writing to file
GIF_OUTMEM - Out of memory
GIF_Close()
-----------
Function Closes the GIF-file.
Syntax int GIF_Close(void);
Remarks This function writes a terminating descriptor
to the file, and then closes it. Also frees
memory used by the other functions of GIFSAVE.
Return value GIF_OK - OK
GIF_ERRWRITE - Error writing to file
THE CALLBACK FUNCTION
=====================
callback()
----------
Function Obtains pixel-values for the
GIF_CompressImage() -function.
Syntax int callback(int x, int y);
Remarks This function must be written by the
programmer. It should accept two integer
parameters specifying a point in the image,
and return the pixel value at this point.
The ranges for these parameters are as
follows
x : [img_left, img_left + img_width - 1]
y : [img_top, img_top + img_height - 1]
where img_left, img_top, img_width and
img_height are the values left, top, width
and height passed to GIF_CompressImage().
An example; if the screen has width 640 and
height 350, and the image covers the entire
screen, x will be in the range [0, 639]
and y in the range [0, 349].
callback() need not get its values from the
screen. The values can be fetched from a
memory array, they can be calculated for
each point requested, etc.
The function is passed as a parameter to
GIF_CompressImage(), and can thus have any
name, not only callback().
Return value Pixel value at the point requested. Should
be in the range [0, numcolors-1] where
numcolors is as specified to GIF_Create().
I hope you find mimeTeX useful. If so, a contribution to your country's TeX Users Group, or to the GNU project, is suggested, especially if you're a company that's currently profitable.
Source forkosh.com| 37 trang css & xhtml web template miễn phí tuyệt đẹp < Lùi | Tiếp theo > Tạo bàn phím ảo virtual keyboard trên website |
|---|
- 16/04/2012 22:27 - 37 trang css & xhtml web template miễn phí tuyệt đẹp
- 06/04/2011 14:23 - Bảng mã ISO-8859-1
- 05/12/2009 11:02 - 13 Firefox Add-ons cho Web Development
- 15/07/2009 16:54 - Tool cho webmaster trong Lienket247
- 14/06/2009 18:09 - Tạo bàn phím ảo virtual keyboard trên website
- 12/06/2009 23:51 - Ngôn ngữ truy vấn XML - XQuery
- 20/05/2009 11:21 - Tạo quảng cáo chạy dọc 2 bên bằng javascript
- 16/05/2009 00:30 - Tạo menu top với hiệu ứng đẹp mắt
Download Game bóng đá PES8 Việt Nam
Tải game bóng đá FiFa 09
Tải game Dragon ball Z - 7 viên ngọc rồng
Tải Game Bóng Đá Pro Evolution Soccer 6 Việt Nam
Download PES 2011 patch Việt Nam PESVN
Tải Game Bóng Đá FIFA 2009 RIP 1 CD
Download Pro Evolution Soccer 2011
Download Game THE SIMS 3
Tải Game bóng đá PES 2009
Download PES 2011 demo
Thay đổi màn hình đăng nhập Windows 7 bằng tay
Một số hàm hay dùng trong JavaScript
Kiểm soát hoàn toàn trỏ chuột bằng bàn phím với NeatMouse
Choáng với concept của Windows Phone 8
Những đặc điểm ưu việt của Windows Phone
Ứng dụng gọi điện VoIP Viber sắp có mặt trên Windows Phone
Game Diablo 3 sắp có mặt trên Windows Phone Marketplace
37 trang css & xhtml web template miễn phí tuyệt đẹp
Những điều cơ bản cần biết về bàn phím chơi game - Gaming Keyboard
L.A. Noire: The Complete Edition - THETA [Full ISO/Action/2011] [13.37GB]
Download 7554 demo
Download Game PC, cập nhật liên tục (torrent)
PES 2012 ra mắt bản mở rộng đầu tiên vào 11/10
PES2012 - Full version - Ngôn ngữ và bình luận tiếng Anh
PES2012 - Blurry disable làm mịn đồ họa
PES 2011 PATCH 4.1 - TRANSFER UPDATE - RELEASED
Bộ sưu tập free PrestaShop Themes phần 3
Bộ sưu tập theme Prestashop miễn phí phần 2
Top 10 Free PrestaShop Themes
Download Prestashop 1.5
Download PrestaShop 1.4
Bổ sung Memcached vào PrestaShop 1.4
Hướng dẫn tích hợp Ngân Lượng vào PrestaShop
Sửa lỗi invalid carrier or no carrier selected trong PrestaShop
Cài đặt PrestaShop
Thiết kế giao diện PrestaShop Theme
Hướng dẫn cài đặt themes trong PrestaShop
Hướng dẫn cách thêm ngôn ngữ cho PrestaShop
Bộ sưu tập Giao diện Premium PrestaShop Themes chuyên nghiệp
Giới thiệu về website thương mại điện tử 2.0 Prestashop
Cài đặt Apache, MySQL, PHP trên Fedora Core phần 2
Tìm hiểu về PES 2012 - Khám phá giao diện (Phần 1)


