mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
raster: #197 OUT_BUFFER_INTERMEDIATE output option
This commit is contained in:
@ -198,7 +198,7 @@ characters are shown in the table below.
|
||||
--------------------------------------------------------------------
|
||||
Escape Character | ASCII Equivalent | Interpretation
|
||||
--------------------------------------------------------------------
|
||||
\0 | 0x00 | Null
|
||||
\0 | 0x00 | NUL character
|
||||
\E | 0x04 | End of Transmission
|
||||
\a | 0x07 | Bell
|
||||
\b | 0x08 | Backspace
|
||||
@ -779,9 +779,9 @@ int ZBarcode_Encode_File_and_Print(struct zint_symbol *symbol, char *filename,
|
||||
int rotate_angle);
|
||||
|
||||
In these definitions "length" can be used to set the length of the input
|
||||
string. This allows the encoding of NULL (ASCII 0) characters in those
|
||||
string. This allows the encoding of NUL (ASCII 0) characters in those
|
||||
symbologies which allow this. A value of 0 will disable this function and Zint
|
||||
will encode data up to the first NULL character in the input string.
|
||||
will encode data up to the first NUL character in the input string.
|
||||
|
||||
The "rotate_angle" value can be used to rotate the image when outputting as a
|
||||
raster image. Valid values are 0, 90, 180 and 270.
|
||||
@ -805,28 +805,44 @@ int ZBarcode_Encode_File_and_Buffer(struct zint_symbol *symbol, char *filename,
|
||||
int rotate_angle);
|
||||
|
||||
The arguments here are the same as above. The difference is that instead of
|
||||
saving the image to file it is placed in an unsigned integer array. The "bitmap"
|
||||
pointer is set to the first memory location in the array and the values
|
||||
saving the image to file it is placed in an unsigned character array. The
|
||||
"bitmap" pointer is set to the first memory location in the array and the values
|
||||
"barcode_width" and "barcode_height" indicate the size of the resulting image
|
||||
in pixels. Rotation and colour options can be used at the same time as using
|
||||
the buffer functions in the same way as when saving to a raster image. The
|
||||
pixel data can be extracted from the array by the method shown in
|
||||
the example below where render_pixel() is assumed to be a function for drawing
|
||||
a pixel on the screen implemented by the external application:
|
||||
pixel data can be extracted from the array by the method shown in the example
|
||||
below where render_pixel() is assumed to be a function for drawing a pixel on
|
||||
the screen implemented by the external application:
|
||||
|
||||
int row, col, i = 0;
|
||||
int red, blue, green;
|
||||
|
||||
for (row = 0; row < my_symbol->bitmap_height; row++) {
|
||||
for (column = 0; col < my_symbol->bitmap_width; column++) {
|
||||
for (col = 0; col < my_symbol->bitmap_width; col++) {
|
||||
red = (int) my_symbol->bitmap[i];
|
||||
green = (int) my_symbol->bitmap[i + 1];
|
||||
blue = (int) my_symbol->bitmap[i + 2];
|
||||
render_pixel(row, column, red, green, blue);
|
||||
render_pixel(row, col, red, green, blue);
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
Where speed is important, the buffer can be returned instead in a more compact
|
||||
intermediate form using the output option OUT_BUFFER_INTERMEDIATE. Here each
|
||||
byte is an ASCII value: '1' for foreground colour and '0' for background colour,
|
||||
except for Ultracode, which uses colour codes: 'W' for white, 'C' for cyan, 'B'
|
||||
for blue, 'M' for magenta, 'R' for red, 'Y' for yellow, 'G' from green, and 'K'
|
||||
for black. The loop for accessing the data is then:
|
||||
|
||||
int row, col, i = 0;
|
||||
|
||||
for (row = 0; row < my_symbol->bitmap_height; row++) {
|
||||
for (col = 0; col < my_symbol->bitmap_width; col++) {
|
||||
render_pixel(row, col, my_symbol->bitmap[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
5.5 Setting Options
|
||||
-------------------
|
||||
So far our application is not very useful unless we plan to only make Code 128
|
||||
@ -1143,21 +1159,23 @@ together when adjusting this value:
|
||||
my_symbol->output_options |= BARCODE_BIND | READER_INIT;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Value | Effect
|
||||
Value | Effect
|
||||
--------------------------------------------------------------------------------
|
||||
0 | No options selected.
|
||||
BARCODE_BIND | Boundary bars above and below the symbol and between
|
||||
| rows if stacking multiple symbols. [2]
|
||||
BARCODE_BOX | Add a box surrounding the symbol and whitespace. [2]
|
||||
BARCODE_STDOUT | Output the file to stdout.
|
||||
READER_INIT | Add a reader initialisation symbol to the data before
|
||||
| encoding.
|
||||
SMALL_TEXT | Use a smaller font for the human readable text.
|
||||
BOLD_TEXT | Embolden the human readable text.
|
||||
CMYK_COLOUR | Select the CMYK colour space option for encapsulated
|
||||
| PostScript files.
|
||||
BARCODE_DOTTY_MODE | Plot a matrix symbol using dots rather than squares.
|
||||
GS1_GS_SEPARATOR | Use GS instead FNC1 as GS1 separator (Data Matrix).
|
||||
0 | No options selected.
|
||||
BARCODE_BIND | Boundary bars above and below the symbol and between
|
||||
| rows if stacking multiple symbols. [2]
|
||||
BARCODE_BOX | Add a box surrounding the symbol and whitespace. [2]
|
||||
BARCODE_STDOUT | Output the file to stdout.
|
||||
READER_INIT | Add a reader initialisation symbol to the data before
|
||||
| encoding.
|
||||
SMALL_TEXT | Use a smaller font for the human readable text.
|
||||
BOLD_TEXT | Embolden the human readable text.
|
||||
CMYK_COLOUR | Select the CMYK colour space option for encapsulated
|
||||
| PostScript files.
|
||||
BARCODE_DOTTY_MODE | Plot a matrix symbol using dots rather than squares.
|
||||
GS1_GS_SEPARATOR | Use GS instead FNC1 as GS1 separator (Data Matrix).
|
||||
OUT_BUFFER_INTERMEDIATE | Return the bitmap buffer as ASCII values instead of
|
||||
| separate colour channels (OUT_BUFFER only).
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
5.9 Setting the Input Mode
|
||||
@ -2950,7 +2968,7 @@ reproduced here for reference.
|
||||
-------------------------------------------------------------
|
||||
Hex | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
|
||||
-------------------------------------------------------------
|
||||
0 | NULL | DLE | SPACE | 0 | @ | P | ` | p
|
||||
0 | NUL | DLE | SPACE | 0 | @ | P | ` | p
|
||||
1 | SOH | DC1 | ! | 1 | A | Q | a | q
|
||||
2 | STX | DC2 | " | 2 | B | R | b | r
|
||||
3 | ETX | DC3 | # | 3 | C | S | c | s
|
||||
|
Reference in New Issue
Block a user