2017-10-24 08:34:31 +13:00
|
|
|
/* pcx.c - Handles output to ZSoft PCX file */
|
|
|
|
/*
|
|
|
|
libzint - the open source barcode library
|
2024-01-17 14:45:45 +13:00
|
|
|
Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
|
2017-10-24 08:34:31 +13:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
2017-10-24 08:37:52 +13:00
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
2017-10-24 08:34:31 +13:00
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
2017-10-24 08:37:52 +13:00
|
|
|
documentation and/or other materials provided with the distribution.
|
2017-10-24 08:34:31 +13:00
|
|
|
3. Neither the name of the project nor the names of its contributors
|
|
|
|
may be used to endorse or promote products derived from this software
|
2017-10-24 08:37:52 +13:00
|
|
|
without specific prior written permission.
|
2017-10-24 08:34:31 +13:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
2017-10-24 08:37:52 +13:00
|
|
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
2017-10-24 08:34:31 +13:00
|
|
|
SUCH DAMAGE.
|
|
|
|
*/
|
2022-07-15 03:01:30 +12:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause */
|
2017-10-24 08:34:31 +13:00
|
|
|
|
2021-06-10 22:15:39 +12:00
|
|
|
#include <errno.h>
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
#include <math.h>
|
2017-10-24 08:34:31 +13:00
|
|
|
#include <stdio.h>
|
2022-09-14 09:08:08 +12:00
|
|
|
#include "common.h"
|
2023-12-28 08:20:19 +13:00
|
|
|
#include "filemem.h"
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
#include "output.h"
|
2022-09-14 09:08:08 +12:00
|
|
|
#include "pcx.h" /* PCX header structure */
|
2017-10-24 08:34:31 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* ZSoft PCX File Format Technical Reference Manual http://bespin.org/~qz/pc-gpe/pcx.txt */
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
INTERNAL int pcx_pixel_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf) {
|
|
|
|
unsigned char fgred, fggrn, fgblu, fgalpha, bgred, bggrn, bgblu, bgalpha;
|
2017-10-24 08:34:31 +13:00
|
|
|
int row, column, i, colour;
|
|
|
|
int run_count;
|
2023-12-28 08:20:19 +13:00
|
|
|
struct filemem fm;
|
|
|
|
struct filemem *const fmp = &fm;
|
2017-10-24 08:34:31 +13:00
|
|
|
pcx_header_t header;
|
2020-04-07 08:26:13 +12:00
|
|
|
unsigned char previous;
|
2023-12-23 10:29:54 +13:00
|
|
|
const unsigned char *pb;
|
|
|
|
const int bytes_per_line = symbol->bitmap_width + (symbol->bitmap_width & 1); /* Must be even */
|
2022-07-15 03:01:30 +12:00
|
|
|
unsigned char *rle_row = (unsigned char *) z_alloca(bytes_per_line);
|
2017-10-24 08:34:31 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
rle_row[bytes_per_line - 1] = 0; /* Will remain zero if bitmap_width odd */
|
2020-04-07 08:26:13 +12:00
|
|
|
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
(void) out_colour_get_rgb(symbol->fgcolour, &fgred, &fggrn, &fgblu, &fgalpha);
|
|
|
|
(void) out_colour_get_rgb(symbol->bgcolour, &bgred, &bggrn, &bgblu, &bgalpha);
|
2017-10-24 08:34:31 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
header.manufacturer = 10; /* ZSoft */
|
|
|
|
header.version = 5; /* Version 3.0 */
|
|
|
|
header.encoding = 1; /* Run length encoding */
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
header.bits_per_pixel = 8; /* TODO: 1-bit monochrome black/white */
|
2024-01-17 14:45:45 +13:00
|
|
|
out_le_u16(header.window_xmin, 0);
|
|
|
|
out_le_u16(header.window_ymin, 0);
|
|
|
|
out_le_u16(header.window_xmax, symbol->bitmap_width - 1);
|
|
|
|
out_le_u16(header.window_ymax, symbol->bitmap_height - 1);
|
|
|
|
out_le_u16(header.horiz_dpi, symbol->dpmm ? roundf(stripf(symbol->dpmm * 25.4f)) : 300);
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
header.vert_dpi = header.horiz_dpi;
|
2017-10-24 08:34:31 +13:00
|
|
|
|
|
|
|
for (i = 0; i < 48; i++) {
|
|
|
|
header.colourmap[i] = 0x00;
|
|
|
|
}
|
|
|
|
|
|
|
|
header.reserved = 0;
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
header.number_of_planes = 3 + (fgalpha != 0xFF || bgalpha != 0xFF); /* TODO: 1-bit monochrome black/white */
|
2017-10-24 08:34:31 +13:00
|
|
|
|
2024-01-17 14:45:45 +13:00
|
|
|
out_le_u16(header.bytes_per_line, bytes_per_line);
|
2017-10-24 08:34:31 +13:00
|
|
|
|
2024-01-17 14:45:45 +13:00
|
|
|
out_le_u16(header.palette_info, 1); /* Colour */
|
|
|
|
out_le_u16(header.horiz_screen_size, 0);
|
|
|
|
out_le_u16(header.vert_screen_size, 0);
|
2017-10-24 08:34:31 +13:00
|
|
|
|
|
|
|
for (i = 0; i < 54; i++) {
|
|
|
|
header.filler[i] = 0x00;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open output file in binary mode */
|
2023-12-28 08:20:19 +13:00
|
|
|
if (!fm_open(fmp, symbol, "wb")) {
|
2024-10-28 10:33:33 +13:00
|
|
|
return errtxtf(ZINT_ERROR_FILE_ACCESS, symbol, 621, "Could not open PCX output file (%1$d: %2$s)", fmp->err,
|
|
|
|
strerror(fmp->err));
|
2017-10-24 08:34:31 +13:00
|
|
|
}
|
|
|
|
|
2023-12-28 08:20:19 +13:00
|
|
|
fm_write(&header, sizeof(pcx_header_t), 1, fmp);
|
2017-10-24 08:34:31 +13:00
|
|
|
|
2023-12-23 10:29:54 +13:00
|
|
|
for (row = 0, pb = pixelbuf; row < symbol->bitmap_height; row++, pb += symbol->bitmap_width) {
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
for (colour = 0; colour < header.number_of_planes; colour++) {
|
2017-10-24 08:34:31 +13:00
|
|
|
for (column = 0; column < symbol->bitmap_width; column++) {
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
const unsigned char ch = pb[column];
|
2017-10-24 08:34:31 +13:00
|
|
|
switch (colour) {
|
|
|
|
case 0:
|
2023-11-20 08:39:54 +13:00
|
|
|
if (ch == '0' || ch == '1') {
|
|
|
|
rle_row[column] = ch != '0' ? fgred : bgred;
|
|
|
|
} else {
|
|
|
|
out_colour_char_to_rgb(ch, &rle_row[column], NULL, NULL);
|
2017-10-24 08:34:31 +13:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2023-11-20 08:39:54 +13:00
|
|
|
if (ch == '0' || ch == '1') {
|
|
|
|
rle_row[column] = ch != '0' ? fggrn : bggrn;
|
|
|
|
} else {
|
|
|
|
out_colour_char_to_rgb(ch, NULL, &rle_row[column], NULL);
|
2017-10-24 08:34:31 +13:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2023-11-20 08:39:54 +13:00
|
|
|
if (ch == '0' || ch == '1') {
|
|
|
|
rle_row[column] = ch != '0' ? fgblu : bgblu;
|
|
|
|
} else {
|
|
|
|
out_colour_char_to_rgb(ch, NULL, NULL, &rle_row[column]);
|
2017-10-24 08:34:31 +13:00
|
|
|
}
|
|
|
|
break;
|
- `zint_symbol->fgcolour` & `bgcolour` buffer lengths extended 10
-> 16 to allow for "C,M,Y,K" comma-separated decimal percentage
strings
- API/CLI/GUI: allow foreground/background colours to be specified
as comma-separated decimal "C,M,Y,K" strings where "C", "M" etc.
are percentages (0-100) (ticket #281, 3rd point)
- output.c: new funcs `out_colour_get_rgb()` & `out_colour_get_cmyk()`
and use in bmp/emf/gif etc.
- PCX: add alpha support
- GUI: fix fg/gbcolor icon background not being reset on zap
- GUI: Rearrange some Appearance tab inputs (Border Type <-> Width,
Show Text <-> Font, Text/Font <-> Printing Scale/Size) to flow
more naturally (hopefully)
- GUI: save button "Save As..." -> "Save..." and add icon
- CLI: add --bgcolor/colour & --fgcolor/colour synonyms
2023-01-30 08:51:11 +13:00
|
|
|
case 3:
|
|
|
|
rle_row[column] = ch != '0' ? fgalpha : bgalpha;
|
|
|
|
break;
|
2017-10-24 08:34:31 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-07 08:26:13 +12:00
|
|
|
/* Based on ImageMagick/coders/pcx.c PCXWritePixels()
|
|
|
|
* Copyright 1999-2020 ImageMagick Studio LLC */
|
|
|
|
previous = rle_row[0];
|
2017-10-24 08:34:31 +13:00
|
|
|
run_count = 1;
|
2022-07-15 03:01:30 +12:00
|
|
|
for (column = 1; column < bytes_per_line; column++) { /* Note going up to bytes_per_line */
|
2020-04-07 08:26:13 +12:00
|
|
|
if ((previous == rle_row[column]) && (run_count < 63)) {
|
2017-10-24 08:34:31 +13:00
|
|
|
run_count++;
|
|
|
|
} else {
|
2020-04-07 08:26:13 +12:00
|
|
|
if (run_count > 1 || (previous & 0xc0) == 0xc0) {
|
|
|
|
run_count += 0xc0;
|
2023-12-28 08:20:19 +13:00
|
|
|
fm_putc(run_count, fmp);
|
2020-04-07 08:26:13 +12:00
|
|
|
}
|
2023-12-28 08:20:19 +13:00
|
|
|
fm_putc(previous, fmp);
|
2020-04-07 08:26:13 +12:00
|
|
|
previous = rle_row[column];
|
2017-10-24 08:34:31 +13:00
|
|
|
run_count = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-07 08:26:13 +12:00
|
|
|
if (run_count > 1 || (previous & 0xc0) == 0xc0) {
|
2017-10-24 08:34:31 +13:00
|
|
|
run_count += 0xc0;
|
2023-12-28 08:20:19 +13:00
|
|
|
fm_putc(run_count, fmp);
|
2017-10-24 08:34:31 +13:00
|
|
|
}
|
2023-12-28 08:20:19 +13:00
|
|
|
fm_putc(previous, fmp);
|
2017-10-24 08:34:31 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-28 08:20:19 +13:00
|
|
|
if (fm_error(fmp)) {
|
2024-10-28 10:33:33 +13:00
|
|
|
errtxtf(0, symbol, 622, "Incomplete write of PCX output (%1$d: %2$s)", fmp->err, strerror(fmp->err));
|
2023-12-28 08:20:19 +13:00
|
|
|
(void) fm_close(fmp, symbol);
|
2022-12-20 05:28:15 +13:00
|
|
|
return ZINT_ERROR_FILE_WRITE;
|
|
|
|
}
|
|
|
|
|
2023-12-28 08:20:19 +13:00
|
|
|
if (!fm_close(fmp, symbol)) {
|
2024-10-28 10:33:33 +13:00
|
|
|
return errtxtf(ZINT_ERROR_FILE_WRITE, symbol, 624, "Failure on closing PCX output file (%1$d: %2$s)",
|
|
|
|
fmp->err, strerror(fmp->err));
|
2021-07-27 02:29:05 +12:00
|
|
|
}
|
2017-10-24 08:34:31 +13:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2022-07-15 03:01:30 +12:00
|
|
|
|
|
|
|
/* vim: set ts=4 sw=4 et : */
|