diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2010-04-20 20:15:30 +0000 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2010-04-20 20:15:30 +0000 |
commit | 0ffe17b83c05efe7066e7bf4bd0ca1fa00389899 (patch) | |
tree | 3bead3a27105a41967cb1545ce17bbaf63c4d002 /xps/xpscolor.c | |
parent | aedcf47a54f382c1d510d0c07d644b450bf01ee5 (diff) | |
download | ghostpdl-0ffe17b83c05efe7066e7bf4bd0ca1fa00389899.tar.gz |
Reformat GhostXPS source to use 4 spaces for indentation rather than a mix of tabs and spaces.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@11090 a1074d23-0009-0410-80fe-cf8c14f379e6
Diffstat (limited to 'xps/xpscolor.c')
-rw-r--r-- | xps/xpscolor.c | 194 |
1 files changed, 97 insertions, 97 deletions
diff --git a/xps/xpscolor.c b/xps/xpscolor.c index 0bbf37a5e..234a5c863 100644 --- a/xps/xpscolor.c +++ b/xps/xpscolor.c @@ -25,19 +25,19 @@ xps_set_color(xps_context_t *ctx, gs_color_space *cs, float *samples) if (ctx->opacity_only) { - gs_setopacityalpha(ctx->pgs, 1.0); - gs_setgray(ctx->pgs, samples[0]); + gs_setopacityalpha(ctx->pgs, 1.0); + gs_setgray(ctx->pgs, samples[0]); } else { - n = cs_num_components(cs); - cc.pattern = 0; - for (i = 0; i < n; i++) - cc.paint.values[i] = samples[i + 1]; - - gs_setopacityalpha(ctx->pgs, samples[0]); - gs_setcolorspace(ctx->pgs, cs); - gs_setcolor(ctx->pgs, &cc); + n = cs_num_components(cs); + cc.pattern = 0; + for (i = 0; i < n; i++) + cc.paint.values[i] = samples[i + 1]; + + gs_setopacityalpha(ctx->pgs, samples[0]); + gs_setcolorspace(ctx->pgs, cs); + gs_setcolor(ctx->pgs, &cc); } return 0; @@ -54,9 +54,9 @@ static int count_commas(char *s) int n = 0; while (*s) { - if (*s == ',') - n ++; - s ++; + if (*s == ',') + n ++; + s ++; } return n; } @@ -80,105 +80,105 @@ xps_parse_color(xps_context_t *ctx, char *base_uri, char *string, gs_color_space if (string[0] == '#') { - if (strlen(string) == 9) - { - samples[0] = unhex(string[1]) * 16 + unhex(string[2]); - samples[1] = unhex(string[3]) * 16 + unhex(string[4]); - samples[2] = unhex(string[5]) * 16 + unhex(string[6]); - samples[3] = unhex(string[7]) * 16 + unhex(string[8]); - } - else - { - samples[0] = 255.0; - samples[1] = unhex(string[1]) * 16 + unhex(string[2]); - samples[2] = unhex(string[3]) * 16 + unhex(string[4]); - samples[3] = unhex(string[5]) * 16 + unhex(string[6]); - } - - samples[0] /= 255.0; - samples[1] /= 255.0; - samples[2] /= 255.0; - samples[3] /= 255.0; - - return 0; + if (strlen(string) == 9) + { + samples[0] = unhex(string[1]) * 16 + unhex(string[2]); + samples[1] = unhex(string[3]) * 16 + unhex(string[4]); + samples[2] = unhex(string[5]) * 16 + unhex(string[6]); + samples[3] = unhex(string[7]) * 16 + unhex(string[8]); + } + else + { + samples[0] = 255.0; + samples[1] = unhex(string[1]) * 16 + unhex(string[2]); + samples[2] = unhex(string[3]) * 16 + unhex(string[4]); + samples[3] = unhex(string[5]) * 16 + unhex(string[6]); + } + + samples[0] /= 255.0; + samples[1] /= 255.0; + samples[2] /= 255.0; + samples[3] /= 255.0; + + return 0; } else if (string[0] == 's' && string[1] == 'c' && string[2] == '#') { - if (count_commas(string) == 2) - sscanf(string, "sc#%g,%g,%g", samples + 1, samples + 2, samples + 3); - if (count_commas(string) == 3) - sscanf(string, "sc#%g,%g,%g,%g", samples, samples + 1, samples + 2, samples + 3); - return 0; + if (count_commas(string) == 2) + sscanf(string, "sc#%g,%g,%g", samples + 1, samples + 2, samples + 3); + if (count_commas(string) == 3) + sscanf(string, "sc#%g,%g,%g,%g", samples, samples + 1, samples + 2, samples + 3); + return 0; } else if (strstr(string, "ContextColor ") == string) { - /* Crack the string for profile name and sample values */ - strcpy(buf, string); - - profile = strchr(buf, ' '); - if (!profile) - return gs_throw1(-1, "cannot find icc profile uri in '%s'", string); - - *profile++ = 0; - p = strchr(profile, ' '); - if (!p) - return gs_throw1(-1, "cannot find component values in '%s'", profile); - - *p++ = 0; - n = count_commas(p) + 1; - i = 0; - while (i < n) - { - samples[i++] = atof(p); - p = strchr(p, ','); - if (!p) - break; - p ++; - if (*p == ' ') - p ++; - } - while (i < n) - { - samples[i++] = 0.0; - } - - /* Default fallbacks if the ICC stuff fails */ - - if (n == 2) /* alpha + tint */ - *csp = ctx->gray; - - if (n == 5) /* alpha + CMYK */ - *csp = ctx->cmyk; - - /* Find ICC colorspace part */ - - xps_absolute_path(partname, base_uri, profile); - part = xps_read_part(ctx, partname); - if (!part) - return gs_throw1(-1, "cannot find icc profile part '%s'", partname); + /* Crack the string for profile name and sample values */ + strcpy(buf, string); + + profile = strchr(buf, ' '); + if (!profile) + return gs_throw1(-1, "cannot find icc profile uri in '%s'", string); + + *profile++ = 0; + p = strchr(profile, ' '); + if (!p) + return gs_throw1(-1, "cannot find component values in '%s'", profile); + + *p++ = 0; + n = count_commas(p) + 1; + i = 0; + while (i < n) + { + samples[i++] = atof(p); + p = strchr(p, ','); + if (!p) + break; + p ++; + if (*p == ' ') + p ++; + } + while (i < n) + { + samples[i++] = 0.0; + } + + /* Default fallbacks if the ICC stuff fails */ + + if (n == 2) /* alpha + tint */ + *csp = ctx->gray; + + if (n == 5) /* alpha + CMYK */ + *csp = ctx->cmyk; + + /* Find ICC colorspace part */ + + xps_absolute_path(partname, base_uri, profile); + part = xps_read_part(ctx, partname); + if (!part) + return gs_throw1(-1, "cannot find icc profile part '%s'", partname); #if 0 /* disable ICC profiles until gsicc_manager is available */ - if (!part->icc) - { - code = xps_parse_icc_profile(ctx, &part->icc, (byte*)part->data, part->size, n - 1); - if (code < 0) - return gs_rethrow1(code, "cannot parse icc profile part '%s'", partname); - } + if (!part->icc) + { + code = xps_parse_icc_profile(ctx, &part->icc, (byte*)part->data, part->size, n - 1); + if (code < 0) + return gs_rethrow1(code, "cannot parse icc profile part '%s'", partname); + } - *csp = part->icc; + *csp = part->icc; #endif - xps_release_part(ctx, part); + xps_release_part(ctx, part); - return 0; + return 0; } else { - return gs_throw1(-1, "cannot parse color (%s)", string); + return gs_throw1(-1, "cannot parse color (%s)", string); } } @@ -190,8 +190,8 @@ xps_stream_from_buffer(xps_context_t *ctx, byte *data, int length) stm = xps_alloc(ctx, sizeof(struct stream_s)); if (!stm) { - gs_throw(-1, "out of memory: stream struct"); - return NULL; + gs_throw(-1, "out of memory: stream struct"); + return NULL; } sread_string(stm, data, length); @@ -225,10 +225,10 @@ xps_parse_solid_color_brush(xps_context_t *ctx, char *base_uri, xps_resource_t * samples[3] = 0.0; if (color_att) - xps_parse_color(ctx, base_uri, color_att, &colorspace, samples); + xps_parse_color(ctx, base_uri, color_att, &colorspace, samples); if (opacity_att) - samples[0] = atof(opacity_att); + samples[0] = atof(opacity_att); xps_set_color(ctx, colorspace, samples); |