72 #define RANGE(a,b,c) { if (a < b) a = b; if (a > c) a = c; } 73 typedef unsigned char byte;
82 byte *
Smooth(
byte *picSrc8,
size_t swide,
size_t shigh,
size_t dwide,
size_t dhigh);
91 #define xvbzero(s,l) memset(s, 0, l) 100 byte * picSmooth =
Smooth(picSrc8, swide, shigh, dwide, dhigh);
108 byte *
Smooth(
byte *picSrc8,
size_t swide,
size_t shigh,
size_t dwide,
size_t dhigh) {
116 byte *picSmooth, *ptrPicSmooth;
119 size_t ex, ey, cx, cy, px, py, apx, apy, apx_100, apy_100, x1, y1;
120 size_t cA, cB, cC, cD;
121 size_t pA, pB, pC, pD;
124 cA = cB = cC = cD = 0;
125 size_t picSmoothSize = ((size_t) dwide) * dhigh;
126 ptrPicSmooth = picSmooth = (
byte *) malloc(picSmoothSize);
132 if (dwide < swide && dhigh < shigh)
133 retval =
SmoothXY(picSmooth, picSrc8, swide, shigh, dwide, dhigh);
146 cxtab = (
int *) malloc(dwide *
sizeof(
int));
150 pxtab = (
int *) malloc(dwide *
sizeof(
int));
154 for (ex = 0; ex < dwide; ex++) {
155 cxtab[ex] = (ex * swide) / dwide;
156 pxtab[ex] = (((ex * swide) * 100) / dwide) - (cxtab[ex] * 100) - 50;
159 for (ey = 0; ey < dhigh; ey++) {
160 cy = (ey * shigh) / dhigh;
161 py = (((ey * shigh) * 100) / dhigh) - (cy * 100) - 50;
174 cyOff = (size_t) cy * swide;
175 y1Off = (size_t) y1 * swide;
179 for (ex = 0; ex < dwide; ex++) {
193 cA = picSrc8[y1Off + x1];
194 cB = picSrc8[y1Off + cx];
195 cC = picSrc8[cyOff + x1];
196 cD = picSrc8[cyOff + cx];
199 if (cA == cB && cB == cC && cC == cD)
201 *ptrPicSmooth++ = cD;
209 pD = apx_100*apy_100;
211 byte val = (
byte) (((pA * cA) + (pB * cB) + (pC * cC) + (pD * cD)) / 10000);
212 *ptrPicSmooth++ = val;
224 picSmooth = (
byte *) NULL;
237 int lastline, thisline, lastpix, linecnt, pixcnt;
247 lbuf = (
int *) calloc(swide,
sizeof(
int));
248 pixarr = (
int *) calloc(swide + 1,
sizeof(
int));
249 if (!lbuf || !pixarr)
252 for (j = 0; j <= swide; j++)
253 pixarr[j] = (j * dwide + (15 * swide) / 16) / swide;
255 lastline = linecnt = pix = 0;
258 for (i = 0; i <= shigh; i++) {
259 thisline = (i * dhigh + (15 * shigh) / 16) / shigh;
261 if ((thisline != lastline)) {
262 pix = pixcnt = lastpix = 0;
264 for (j = 0, paptr = pixarr; j <= swide; j++, paptr++) {
265 if (*paptr != lastpix) {
266 *picSmooth++ = (pix / linecnt) / pixcnt;
278 xvbzero((
char *) lbuf, swide *
sizeof(
int));
284 for (j = 0; j < swide; j++, cptr++)
313 int *thisline, *nextline, *thisptr, *nextptr, *tmpptr;
326 cache = (
short *) calloc(2 << 14,
sizeof(
short));
327 thisline = (
int *) malloc(w *
sizeof(
int));
328 nextline = (
int *) malloc(w *
sizeof(
int));
329 if (!cache || !picDithered || !thisline || !nextline)
336 for (j = w, tmpptr = nextline;
j; j--, ep++)
337 *tmpptr++ = (
int) *ep;
339 for (i = 0; i < h; i++) {
340 np = picDithered + i *
w;
346 for (j = w, tmpptr = nextline;
j; j--, ep++)
347 *tmpptr++ = (
int) *ep;
350 thisptr = (i & 1) ? thisline + w - 1 : thisline;
351 nextptr = (i & 1) ? nextline + w - 1 : nextline;
355 for (j = 0; j <
w; j++) {
356 int k,
d, mind, closest;
369 key = ((r2 & 0xf8) << 6) | ((r2 & 0xf8) << 1) | (r2 >> 4);
378 *np = (
byte) (cache[key] - 1);
385 for (k = closest = 0; k < 256 && mind > 7; k++) {
392 cache[key] = closest + 1;
400 int rerr_2 = rerr / 2;
401 thisptr[0] += rerr_2;
#define REPORT_ERROR(nerr, ErrormMsg)
void DoColorDither(byte *picSmooth, byte *&picDithered, size_t w, size_t h)
There is not enough memory for allocation.
void abs(Image< double > &op)
void SmoothResize(byte *picSrc8, byte *destpic8, size_t swide, size_t shigh, size_t dwide, size_t dhigh)
byte * Smooth(byte *picSrc8, size_t swide, size_t shigh, size_t dwide, size_t dhigh)
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
String formatString(const char *format,...)