0N/A/*
2362N/A * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * This file contains macro definitions for the Encoding category of
0N/A * the macros used by the generic scaleloop function.
0N/A *
0N/A * This implementation uses a Floyd-Steinberg error diffusion technique
0N/A * to produce a very high quality version of an image with only an 8-bit
0N/A * (or less) RGB colormap or gray ramp. The error diffusion technique
0N/A * requires that the input color information be delivered in a special
0N/A * order from the top row to the bottom row and then left to right within
0N/A * each row, thus it is only valid in cases where the ImageProducer has
0N/A * specified the TopDownLeftRight delivery hint. If the data is not read
0N/A * in that order, no mathematical or memory access errors should occur,
0N/A * but the dithering error will be spread through the pixels of the output
0N/A * image in an unpleasant manner.
0N/A */
0N/A
0N/A/*
0N/A * These definitions vector the standard macro names to the "Any"
0N/A * versions of those macros. The "DitherDeclared" keyword is also
0N/A * defined to indicate to the other include files that they are not
0N/A * defining the primary implementation. All other include files
0N/A * will check for the existance of the "DitherDeclared" keyword
0N/A * and define their implementations of the Encoding macros using
0N/A * more specific names without overriding the standard names. This
0N/A * is done so that the other files can be included here to reuse
0N/A * their implementations for the specific cases.
0N/A */
0N/A#define DitherDeclared
0N/A#define DeclareDitherVars DeclareAnyDitherVars
0N/A#define InitDither InitAnyDither
0N/A#define StartDitherLine StartAnyDitherLine
0N/A#define DitherPixel AnyDitherPixel
0N/A#define DitherBufComplete AnyDitherBufComplete
0N/A
0N/A/* Include the specific implementations for color and grayscale displays */
0N/A#include "img_fscolor.h"
0N/A#include "img_fsgray.h"
0N/A
0N/A#define DeclareAnyDitherVars \
0N/A DeclareColorDitherVars \
0N/A DeclareGrayDitherVars \
0N/A int grayscale;
0N/A
0N/A#define InitAnyDither(cvdata, clrdata, dstTW) \
0N/A do { \
0N/A if (grayscale = clrdata->grayscale) { \
0N/A InitGrayDither(cvdata, clrdata, dstTW); \
0N/A } else { \
0N/A InitColorDither(cvdata, clrdata, dstTW); \
0N/A } \
0N/A } while (0)
0N/A
0N/A#define StartAnyDitherLine(cvdata, dstX1, dstY) \
0N/A do { \
0N/A if (grayscale) { \
0N/A StartGrayDitherLine(cvdata, dstX1, dstY); \
0N/A } else { \
0N/A StartColorDitherLine(cvdata, dstX1, dstY); \
0N/A } \
0N/A } while (0)
0N/A
0N/A#define AnyDitherPixel(dstX, dstY, pixel, red, green, blue) \
0N/A do { \
0N/A if (grayscale) { \
0N/A GrayDitherPixel(dstX, dstY, pixel, red, green, blue); \
0N/A } else { \
0N/A ColorDitherPixel(dstX, dstY, pixel, red, green, blue); \
0N/A } \
0N/A } while (0)
0N/A
0N/A#define AnyDitherBufComplete(cvdata, dstX1) \
0N/A do { \
0N/A if (grayscale) { \
0N/A GrayDitherBufComplete(cvdata, dstX1); \
0N/A } else { \
0N/A ColorDitherBufComplete(cvdata, dstX1); \
0N/A } \
0N/A } while (0)