Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/awt/image/dither.h
38918 views
/*1* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include <stdio.h>26#include <stdlib.h>27#include <math.h>28#include <string.h>2930#include "colordata.h"3132#ifdef __cplusplus33extern "C" {34#endif3536extern sgn_ordered_dither_array std_img_oda_red;37extern sgn_ordered_dither_array std_img_oda_green;38extern sgn_ordered_dither_array std_img_oda_blue;39extern int std_odas_computed;4041void make_dither_arrays(int cmapsize, ColorData *cData);42void initInverseGrayLut(int* prgb, int rgbsize, ColorData* cData);4344/*45* state info needed for breadth-first recursion of color cube from46* initial palette entries within the cube47*/4849typedef struct {50unsigned int depth;51unsigned int maxDepth;5253unsigned char *usedFlags;54unsigned int activeEntries;55unsigned short *rgb;56unsigned char *indices;57unsigned char *iLUT;58} CubeStateInfo;5960#define INSERTNEW(state, rgb, index) do { \61if (!state.usedFlags[rgb]) { \62state.usedFlags[rgb] = 1; \63state.iLUT[rgb] = index; \64state.rgb[state.activeEntries] = rgb; \65state.indices[state.activeEntries] = index; \66state.activeEntries++; \67} \68} while (0);697071#define ACTIVATE(code, mask, delta, state, index) do { \72if (((rgb & mask) + delta) <= mask) { \73rgb += delta; \74INSERTNEW(state, rgb, index); \75rgb -= delta; \76} \77if ((rgb & mask) >= delta) { \78rgb -= delta; \79INSERTNEW(state, rgb, index); \80rgb += delta; \81} \82} while (0);8384#ifdef __cplusplus85} /* extern "C" */86#endif878889