⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dither.3

📁 [Game.Programming].Academic - Graphics Gems (6 books source code)
💻 3
字号:
.\" Copyright (c) 1986, 1987, University of Utah.TH DITHER 3 2/2/87 3.UC 4 .SH NAME.HPdithermap, bwdithermap, make_square, dithergb, ditherbw \- functions for dithering color or black and white images..SH SYNOPSIS.na.sp.Bdithermap( levels, gamma, rgbmap, divN, modN, magic ).br.Bint levels;.br.Bdouble gamma;.br.Bint rgbmap[][3], divN[256], modN[256], magic[16][16];.sp.Bbwdithermap( levels, gamma, bwmap, divN, modN, magic ).br.Bint levels;.br.Bdouble gamma;.br.Bint bwmap[], int divN[256], modN[256], magic[16][16];.sp.Bmake_square( N, divN, modN, magic ).br.Bdouble N;.br.Bint divN[256], modN[256], magic[16][16];.sp.Bdithergb( x, y, r, g, b, levels, divN, modN, magic ).br.Bint x, y, r, g, b, levels;.br.Bint divN[256], modN[256], magic[16][16];.sp.Bditherbw( x, y, val, divN, modN, magic ).br.Bint x, y, val, divN[256], modN[256], magic[16][16];.ad b.SH DESCRIPTIONThese functions provide a common set of routines for dithering a fullcolor or gray scale image into a lower resolution color map.  .I Dithermapcomputes a color map and some auxiliary parameters for dithering afull color (24 bit) image to fewer bits.  The argument.I levelstells how many different intensity levels per primary color should becomputed.  To get maximum use of a 256 entry color map, use.IR levels =6.  The computed map uses \fIlevels^3\fP entries.The.I gamma argument provides for gamma compensation of the generated color map(that is, the values in the map will be adjusted to give a linearintensity variation on a display with the given gamma).The computed color map will be returned in the array.IR rgbmap ..I divNand.I modNare auxiliary arrays for computing the dithering pattern (see below),and.I magicis the magic square dither pattern..PPTo compute a color map for dithering a black and white image to fewerintensity levels, use.IR bwdithermap .The arguments are as for.IR dithermap ,but only a single channel color map is computed.  The value of\fIlevels\fP can be larger than for \fIdithermap\fP, asthe computed map only has \fIlevels\fP entries..PPTo just build the magic square and other parameters, use.IR make_square .The argument.I Nshould be equal to 255.0 divided by the desired number of intensitylevels less one (i.e., \fIN = 255.0 / (levels - 1)\fP).  The otherarguments are filled in as above..PPThe color map index for a dithered full color pixel is computed by.IR dithergb .Since the pattern depends on the screen location, the first twoarguments.IR x and.IR y ,specify that location.  The true color of the pixel at that locationis given by the triple.IR r ,.IR g ,and.IR b .The number of intensity.I levelsand the dithering parameter matrices computed by.I dithermapare also passed to .IR dithergb ..PPThe color map index for a dithered gray scale pixel is computed by.IR ditherbw .Again, the screen position is specified, and the intensity value ofthe pixel is supplied in.IR val .The dithering parameters must also be supplied..PPAlternatively, the dithering may be done in line instead of incurringthe extra overhead of a function call, which can be significant whenrepeated a million times.  The computation is as follows:.nf.ta .5i 1.0i 1.5i		row = y % 16;		col = x % 16;	#define DMAP(v,col,row) (divN[v] + (modN[v]>magic[col][row] ? 1 : 0))		pix = DMAP(r,col,row) + DMAP(g,col,row)*levels +			DMAP(b,col,row)*levels*levels;.fiFor a gray scale image, it is a little simpler:.nf.ta .5i 1.0i 1.5i		pix = DMAP(val,row,col);.fiAnd on a single bit display (assuming a 1 means white):.nf.ta .5i 1.0i		pix = divN[val] > magic[col][row] ? 1 : 0.fi.SH SEE ALSO.IR rgb_to_bw (3),.IR librle (3),.IR RLE (5)..SH AUTHORSpencer W. Thomas.brUniversity of Utah

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -