if (inkpot) {
inkpot->values.no_palette_value = 0;
- inkpot->values.no_palette_vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes);
+ inkpot->values.no_palette_vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_rgb);
inkpot->value.index = 0;
inkpot->value.value = 0;
- inkpot->value.vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes);
+ inkpot->value.vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_rgb);
inkpot->canon = NULL;
inkpot->canon_alloc = 0;
{
inkpot_status_t rc;
inkpot_value_t value;
- VALUE v;
+ unsigned long v;
int i;
for (i = 0; i < 4; i++) {
- value.value <<= SZB_RED;
+ value.value <<= 16;
v = rgba[i];
v = (v < 0.0) ? 0.0 : v;
v = (v > 1.0) ? 1.0 : v;
- value.value |= (int)(v * MAX_RED);
+ value.value |= (int)(v * 65535);
}
- value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes;
+ value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgba;
rc = inkpot_value_set ( &inkpot->values, &value );
if (rc == INKPOT_SUCCESS)
if (*inkpot->canon == '#') {
a = 65535;
if ((len = sscanf(inkpot->canon, "#%4x%4x%4x%4x", &r, &g, &b, &a)) >= 3) {
- r *= MAX_RED/65535; g *= MAX_RED/65535; b *= MAX_RED/65535; a *= MAX_RED/65535;
+ if (len == 4)
+ value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgba;
+ else
+ value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgb;
}
- if (len < 3) {
+ else if (len < 3) {
a = 255;
if ((len = sscanf(inkpot->canon, "#%2x%2x%2x%2x", &r, &g, &b, &a)) >= 3) {
- r *= MAX_RED/255; g *= MAX_RED/255; b *= MAX_RED/255; a *= MAX_RED/255;
+ r *= 65535/255; g *= 65535/255; b *= 65535/255; a *= 65535/255;
+ if (len == 4)
+ value.vtype = BIT_VTYPE_size_8 | BIT_VTYPE_code_rgba;
+ else
+ value.vtype = BIT_VTYPE_size_8 | BIT_VTYPE_code_rgb;
}
}
if (len >= 3) {
- value.value = (((((((VALUE)r) << SZB_RED) | (VALUE)g) << SZB_RED) | (VALUE)b) << SZB_RED) | (VALUE)a;
- value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes;
+ value.value = (((((((unsigned long)r) << 16) | (unsigned long)g) << 16) | (unsigned long)b) << 16) | (unsigned long)a;
rc = inkpot_value_set ( &inkpot->values, &value );
if (rc == INKPOT_SUCCESS)
else if (((c = *inkpot->canon) == '.') || isdigit(c)) {
hsva[3] = 1.0;
if (sscanf(inkpot->canon, "%lf%lf%lf%lf", &hsva[0], &hsva[1], &hsva[2], &hsva[3]) >= 3)
- rc = inkpot_set_hsva(inkpot, hsva);
+ rc = inkpot_set_hsva(inkpot, hsva); /* FIXME */
else
if (sscanf(inkpot->canon, "%d", &index) == 1) /* simple indexes */
rc = inkpot_set_index(inkpot, index);
rc = inkpot->status = inkpot_value_get( &inkpot->values, &value );
if (rc == INKPOT_SUCCESS) {
for (i = 3; i >= 0; i--) {
- rgba[i] = (value.value & MSK_RED);
- value.value >>= SZB_RED;
+ rgba[i] = (value.value & 65535);
+ value.value >>= 16;
}
}
return rc;
rc = inkpot->status = inkpot_value_get( &inkpot->values, &value );
if (rc == INKPOT_SUCCESS) {
for (i = 3; i >= 0; i--) {
- rgba[i] = (value.value & MSK_RED) / (double)MAX_RED;
- value.value >>= SZB_RED;
+ rgba[i] = (value.value & 65535) / (double)65535;
+ value.value >>= 16;
}
}
return rc;
int i;
for (i = 3; i >= 0; i--) {
- rgba[i] = (value & MSK_RED);
- value >>= SZB_RED;
+ rgba[i] = (value & 65535);
+ value >>= 16;
}
sprintf(buf, "#%04x%04x%04x%04x", rgba[0], rgba[1], rgba[2], rgba[3]);
errputs(inkpot, buf);
inkpot_status_t inkpot_value_get ( inkpot_values_t *values, inkpot_value_t *value )
{
IDX_VALUES index;
+
+ /* FIXME - this routine must check for 8 bit values and properly scale to 16 for the api */
index = value->index;
if (index < SZT_VALUES) {
value->value = TAB_VALUES[index];
- value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes;
+ value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgba; /* FIXME */
}
else if (index - SZT_VALUES < SZT_NONAME_VALUES) {
value->value = TAB_NONAME_VALUES[index - SZT_VALUES];
- value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes;
+ value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_rgba; /* FIXME */
}
else if (index == SZT_VALUES + SZT_NONAME_VALUES) {
value->value = values->no_palette_value;
#define BIT_VTYPE_size_8 0x01
#define MSK_VTYPE_code 0x0e
-#define BIT_VTYPE_code_VALUE 0x00
-#define BIT_VTYPE_code_rgba 0x02
-#define BIT_VTYPE_code_hsva 0x04
-#define BIT_VTYPE_code_cmyk 0x06
-
-#define MSK_VTYPE_alpha 0x10
-#define BIT_VTYPE_alpha_yes 0x00
-#define BIT_VTYPE_alpha_no 0x10
+#define BIT_VTYPE_code_rgba 0x00
+#define BIT_VTYPE_code_hsva 0x02
+#define BIT_VTYPE_code_cmyk 0x04
+#define BIT_VTYPE_code_rgb 0x06
+#define BIT_VTYPE_code_hsv 0x08
typedef struct inkpot_values_s {
- VALUE no_palette_value;
+ unsigned long no_palette_value;
BIT_VTYPE no_palette_vtype;
} inkpot_values_t;
typedef struct inkpot_value_s {
- IDX_VALUES index; /* write by set, read by get, write by first, read/write by next */
- BIT_VTYPE vtype; /* read by set, write by get, read by first, read by next */
- VALUE value; /* read by set, write by get, write by first, write by next */
+ IDX_VALUES index; /* write by set, read by get, write by first, read/write by next */
+ BIT_VTYPE vtype; /* read by set, write by get, read by first, read by next */
+ unsigned long value; /* read by set, write by get, write by first, write by next */
} inkpot_value_t;
extern inkpot_status_t inkpot_value_set ( inkpot_values_t *values, inkpot_value_t *value );
* AT&T Research, Florham Park NJ *
**********************************************************/
-VALUE TAB_VALUES[SZT_VALUES] = {
+unsigned long TAB_VALUES[SZT_VALUES] = {
0x000000000000ffff, /* black */
0x00000000ffffffff, /* bleu, blue */
0x0000ffff0000ffff, /* green, vert */
0xffffffffffffffff, /* white */
};
-VALUE TAB_NONAME_VALUES[SZT_NONAME_VALUES] = {
+unsigned long TAB_NONAME_VALUES[SZT_NONAME_VALUES] = {
0x000000008000ffff,
0x00000000a400ffff,
0x00000000c800ffff,