/*
* 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.
*/
/* Iterative color palette generation */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#ifdef TIMES
#include <time.h>
#endif /* TIMES */
#ifndef MAKECUBE_EXE
#include "jvm.h"
#include "jni_util.h"
#endif
#define FALSE 0
{0.3811f, 0.2073f, 0.0213f},
{0.3203f, 0.6805f, 0.1430f},
{0.2483f, 0.1122f, 1.2417f}
};
typedef struct {
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char bestidx;
int nextidx;
float L, U, V;
float dist;
float dE;
float dL;
} CmapEntry;
static int num_virt_cmap_entries;
/* this is a multiplier--it should not be zero */
#if 0
#define WEIGHT_DIST(d,l) (d)
#define UNWEIGHT_DIST(d,l) (d)
#endif
static void
{
static int done = 0;
int i;
if (done) {
return;
}
for (i = 0; i < 256; ++i)
{
}
done = 1;
}
static void
{
float sum = X+Y+Z;
if (sum != 0.0f) {
float x = X/sum;
float y = Y/sum;
if (ytmp < .206893f) {
} else {
}
if (dnm != 0.0f) {
} else {
*u = 0.0f;
*v = 0.0f;
}
} else {
*L = 0.0f;
*u = 0.0f;
*v = 0.0f;
}
}
static int cmapmax;
static int total;
static int
int i;
for (i = 0; i < c_tot; ++i) {
return 0;
}
return 1;
}
static int
add_color(int r, int g, int b, int f) {
return 0;
++total;
return 1;
} else {
return 0;
}
}
static void
init_primaries() {
int r, g, b;
for (r = 0; r < 256; r += (r?128:127)) {
for (g = 0; g < 256; g += (g?128:127)) {
for (b = 0; b < 256; b += (b?128:127)) {
if ((r == g) && (g == b)) continue; /* black or white */
}
}
}
}
static void
init_pastels() {
int i;
/* very light colors */
for (i = 6; i >= 0; --i)
(i&2) ? 0xff : 0xf0,
}
static void
init_grays() {
int i;
for (i = 15; i < 255; i += 16)
}
static void
init_mac_palette() {
}
static void
{
int r, g, b;
if (virt_cmap) {
virt_cmap = 0;
}
/*
* Fix for bug 4070647 malloc return value not check in img_colors.c
* We have to handle the malloc failure differently under
* Win32 and Solaris since under Solaris this file is linked with
* libawt.so and under Win32 it's a separate awt_makecube.exe
* application.
*/
#ifndef MAKECUBE_EXE
return;
#else
exit(-1);
#endif
}
for (r = 0; r < total; r++) {
gray = r;
}
}
}
if (gray < 0) {
#ifdef DEBUG
#endif /* DEBUG */
gray = 0;
}
g = 0;
b = 0;
for (r = 0; r < tablesize - 1; ++r) {
if (g >= 0) {
b = r;
dotest[r] = 1;
g -= tablesize;
} else {
dotest[r] = 0;
}
prevtest[r] = b;
g += testsize;
}
b = r;
prevtest[r] = b;
dotest[r] = 1;
for (r = tablesize - 1; r >= 0; --r) {
if (prevtest[r] == r) {
b = r;
}
nexttest[r] = b;
}
#ifdef DEBUG
for (r = 0; r < tablesize; ++r) {
if (dotest[r]) {
}
}
}
#endif /* DEBUG */
for (r = 0; r < tablesize; ++r)
{
for (g = 0; g < tablesize; ++g)
{
for (b = 0; b < tablesize; ++b)
{
float t, d;
#ifdef DEBUG
#endif /* DEBUG */
continue; /* Shouldn't happen */
}
{
pCmap++;
continue;
}
d = t * t;
d *= Lscale;
} else {
d *= Lscale;
d += t * t;
d += t * t;
}
pCmap++;
}
}
}
#ifdef DEBUG
}
#endif /* DEBUG */
}
static int
float L = pCmap->L;
float dist;
int i;
float dL;
continue;
}
}
}
} else {
float U = pCmap->U;
float V = pCmap->V;
{
/* *delta = (dL/4) + dU + dV; */
/* *delta = dist */
/* *delta = dL + 100*(dU+dV)/(100+L); */
}
}
}
}
static int num_offenders;
static void
{
int i;
for (i = num_offenders; i > 0; --i) {
}
}
static void
int i, j;
float dEthresh = 0;
num_offenders = 0;
continue;
}
if (num_offenders == MAX_OFFENDERS
{
continue;
}
}
if (num_offenders > 0) {
}
if (!pCmap) continue;
if (j) {
for (j = i+1; j < num_offenders; ++j) {
float dE;
if (!pCmap) {
continue;
}
offenders[j] = 0;
} else {
}
}
}
}
}
}
void
unsigned char *reds,
unsigned char *greens,
unsigned char *blues,
unsigned char *lookup)
{
int i, ix;
#ifdef STATS
#endif /* STATS */
#ifdef TIMES
#endif /* TIMES */
total = 0;
for (i = 0; i < prevclrs; i++) {
}
/* do grays next; otherwise find_nearest may break! */
init_grays();
if (doMac) {
}
init_pastels();
/* special case some blues */
}
#ifdef TIMES
#endif /* TIMES */
for (i = 0; i < num_virt_cmap_entries; i++, pCmap++) {
continue;
}
}
}
#ifdef TIMES
#endif /* TIMES */
if (tablesize != lookupsize) {
int r, g, b;
for (r = 0; r < lookupsize; ++r)
{
for (g = 0; g < lookupsize; ++g)
{
for (b = 0; b < lookupsize; ++b, pCmap++)
{
float L, U, V;
float bestd = 0;
continue;
}
#ifdef DEBUG
if (r == g && g == b) {
}
#endif /* DEBUG */
L = pCmap->L;
U = pCmap->U;
V = pCmap->V;
for (i = 0; i < 8; i++) {
float d, t;
+ gi) * lookupsize
+ bi];
#ifdef DEBUG
}
#endif /* DEBUG */
if (i != 0 && d > bestd) continue;
if (i != 0 && d > bestd) continue;
if (i != 0 && d > bestd) continue;
bestd = d;
}
}
}
}
}
for (i = 0; i < num_virt_cmap_entries; i++) {
}
#ifdef TIMES
#endif /* TIMES */
#ifdef STATS
max_dL = 0.0;
max_dE = 0.0;
ave_dL = 0.0;
ave_dE = 0.0;
for (i = 0; i < num_virt_cmap_entries; i++, pCmap++) {
} else {
}
}
#endif /* STATS */
#ifdef TIMES
#endif /* TIMES */
virt_cmap = 0;
}