mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-24 20:14:28 -04:00
Merge branch Ultra
This commit is contained in:
commit
0d26948baa
16 changed files with 1671 additions and 192 deletions
105
backend/ps.c
105
backend/ps.c
|
@ -38,6 +38,69 @@
|
|||
#include <math.h>
|
||||
#include "common.h"
|
||||
|
||||
void colour_to_pscolor(int option, int colour, char* output) {
|
||||
strcpy(output, "");
|
||||
if ((option & CMYK_COLOUR) == 0) {
|
||||
// Use RGB colour space
|
||||
switch(colour) {
|
||||
case 0: // White
|
||||
strcat(output, "1.00 1.00 1.00");
|
||||
break;
|
||||
case 1: // Cyan
|
||||
strcat(output, "0.00 1.00 1.00");
|
||||
break;
|
||||
case 2: // Blue
|
||||
strcat(output, "0.00 0.00 1.00");
|
||||
break;
|
||||
case 3: // Magenta
|
||||
strcat(output, "1.00 0.00 1.00");
|
||||
break;
|
||||
case 4: // Red
|
||||
strcat(output, "1.00 0.00 0.00");
|
||||
break;
|
||||
case 5: // Yellow
|
||||
strcat(output, "1.00 1.00 0.00");
|
||||
break;
|
||||
case 6: // Green
|
||||
strcat(output, "0.00 1.00 0.00");
|
||||
break;
|
||||
default: // Black
|
||||
strcat(output, "0.00 0.00 0.00");
|
||||
break;
|
||||
}
|
||||
strcat(output, " setrgbcolor");
|
||||
} else {
|
||||
// Use CMYK colour space
|
||||
switch(colour) {
|
||||
case 0: // White
|
||||
strcat(output, "0.00 0.00 0.00 0.00");
|
||||
break;
|
||||
case 1: // Cyan
|
||||
strcat(output, "1.00 0.00 0.00 0.00");
|
||||
break;
|
||||
case 2: // Blue
|
||||
strcat(output, "1.00 1.00 0.00 0.00");
|
||||
break;
|
||||
case 3: // Magenta
|
||||
strcat(output, "0.00 1.00 0.00 0.00");
|
||||
break;
|
||||
case 4: // Red
|
||||
strcat(output, "0.00 1.00 1.00 0.00");
|
||||
break;
|
||||
case 5: // Yellow
|
||||
strcat(output, "0.00 0.00 1.00 0.00");
|
||||
break;
|
||||
case 6: // Green
|
||||
strcat(output, "1.00 0.00 1.00 0.00");
|
||||
break;
|
||||
default: // Black
|
||||
strcat(output, "0.00 0.00 0.00 1.00");
|
||||
break;
|
||||
}
|
||||
strcat(output, " setcmykcolor");
|
||||
}
|
||||
}
|
||||
|
||||
INTERNAL int ps_plot(struct zint_symbol *symbol) {
|
||||
FILE *feps;
|
||||
int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
|
||||
|
@ -47,6 +110,8 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
|
|||
int error_number = 0;
|
||||
float ax, ay, bx, by, cx, cy, dx, dy, ex, ey, fx, fy;
|
||||
float radius;
|
||||
int colour_index, colour_rect_counter;
|
||||
char ps_color[30];
|
||||
|
||||
struct zint_vector_rect *rect;
|
||||
struct zint_vector_hexagon *hex;
|
||||
|
@ -153,18 +218,40 @@ INTERNAL int ps_plot(struct zint_symbol *symbol) {
|
|||
fprintf(feps, "%.2f 0.00 TB 0.00 %.2f TR\n", symbol->vector->height, symbol->vector->width);
|
||||
|
||||
fprintf(feps, "TE\n");
|
||||
if ((symbol->output_options & CMYK_COLOUR) == 0) {
|
||||
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
|
||||
} else {
|
||||
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
|
||||
if (symbol->symbology != BARCODE_ULTRA) {
|
||||
if ((symbol->output_options & CMYK_COLOUR) == 0) {
|
||||
fprintf(feps, "%.2f %.2f %.2f setrgbcolor\n", red_ink, green_ink, blue_ink);
|
||||
} else {
|
||||
fprintf(feps, "%.2f %.2f %.2f %.2f setcmykcolor\n", cyan_ink, magenta_ink, yellow_ink, black_ink);
|
||||
}
|
||||
}
|
||||
|
||||
// Rectangles
|
||||
rect = symbol->vector->rectangles;
|
||||
while (rect) {
|
||||
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width);
|
||||
fprintf(feps, "TE\n");
|
||||
rect = rect->next;
|
||||
if (symbol->symbology == BARCODE_ULTRA) {
|
||||
for (colour_index = 0; colour_index <= 7; colour_index++) {
|
||||
colour_rect_counter = 0;
|
||||
rect = symbol->vector->rectangles;
|
||||
while (rect) {
|
||||
if (rect->colour == colour_index) {
|
||||
if (colour_rect_counter == 0) {
|
||||
//Set new colour
|
||||
colour_to_pscolor(symbol->output_options, colour_index, ps_color);
|
||||
fprintf(feps, "%s\n", ps_color);
|
||||
}
|
||||
colour_rect_counter++;
|
||||
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width);
|
||||
fprintf(feps, "TE\n");
|
||||
}
|
||||
rect = rect->next;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rect = symbol->vector->rectangles;
|
||||
while (rect) {
|
||||
fprintf(feps, "%.2f %.2f TB %.2f %.2f TR\n", rect->height, (symbol->vector->height - rect->y) - rect->height, rect->x, rect->width);
|
||||
fprintf(feps, "TE\n");
|
||||
rect = rect->next;
|
||||
}
|
||||
}
|
||||
|
||||
// Hexagons
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue