/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This file contains macro definitions for the Encoding category of
* the macros used by the generic scaleloop function.
*
* This implementation uses a Floyd-Steinberg error diffusion technique
* to produce a very high quality version of an image with only an 8-bit
* (or less) RGB colormap. The error diffusion technique requires that
* the input color information be delivered in a special order from the
* top row to the bottom row and then left to right within each row, thus
* it is only valid in cases where the ImageProducer has specified the
* TopDownLeftRight delivery hint. If the data is not read in that order,
* no mathematical or memory access errors should occur, but the dithering
* error will be spread through the pixels of the output image in an
* unpleasant manner.
*/
#include "img_fsutil.h"
/*
* These definitions vector the standard macro names to the "Color"
* versions of those macros only if the "DitherDeclared" keyword has
* not yet been defined elsewhere. The "DitherDeclared" keyword is
* also defined here to claim ownership of the primary implementation
* even though this file does not rely on the definitions in any other
* files.
*/
#ifndef DitherDeclared
#define DitherDeclared
#endif
typedef struct {
int r, g, b;
#define DeclareColorDitherVars \
do { \
if (cep == 0) { \
return SCALEFAILURE; \
} \
} \
} while (0)
do { \
if (dstX1) { \
} else { \
} \
} while (0)
do { \
\
/* add previous errors */ \
\
/* bounds checking */ \
\
/* Store the closest color in the destination pixel */ \
\
/* Set the error from the previous lap */ \
\
/* compute the errors */ \
\
/* distribute the errors */ \
cep++; \
} while (0)
do { \
if (dstX1) { \
} \
} while (0)