Change bitmap signedness to allow conversion to other data types

Buffered bitmap array should have been type unsigned char not type char
Includes change to manual
In response to (and hopefully fixing) #182 reported by Marcelo Antunes
This commit is contained in:
Robin Stuart 2020-03-29 13:42:33 +01:00
parent e8b56faa11
commit 52214c5a1c
3 changed files with 9 additions and 8 deletions

View file

@ -61,7 +61,7 @@ static void buffer_plot(struct zint_symbol *symbol, char *pixelbuf) {
int fgred, fggrn, fgblu, bgred, bggrn, bgblu; int fgred, fggrn, fgblu, bgred, bggrn, bgblu;
int row, column, i; int row, column, i;
symbol->bitmap = (char *) malloc(symbol->bitmap_width * symbol->bitmap_height * 3); symbol->bitmap = (unsigned char *) malloc(symbol->bitmap_width * symbol->bitmap_height * 3);
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]); fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);
fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]); fggrn = (16 * ctoi(symbol->fgcolour[2])) + ctoi(symbol->fgcolour[3]);

View file

@ -125,7 +125,7 @@ extern "C" {
unsigned char encoded_data[200][143]; unsigned char encoded_data[200][143];
int row_height[200]; /* Largest symbol is 189 x 189 Han Xin */ int row_height[200]; /* Largest symbol is 189 x 189 Han Xin */
char errtxt[100]; char errtxt[100];
char *bitmap; unsigned char *bitmap;
int bitmap_width; int bitmap_width;
int bitmap_height; int bitmap_height;
unsigned int bitmap_byte_length; unsigned int bitmap_byte_length;

View file

@ -749,13 +749,13 @@ the example below where render_pixel() is assumed to be a function for drawing
a pixel on the screen implemented by the external application: a pixel on the screen implemented by the external application:
int row, col, i = 0; int row, col, i = 0;
unsigned int red, blue, green; int red, blue, green;
for (row = 0; row < my_symbol->bitmap_height; row++) { for (row = 0; row < my_symbol->bitmap_height; row++) {
for (column = 0; col < my_symbol->bitmap_width; column++) { for (column = 0; col < my_symbol->bitmap_width; column++) {
red = my_symbol->bitmap[i]; red = (int) my_symbol->bitmap[i];
green = my_symbol->bitmap[i + 1]; green = (int) my_symbol->bitmap[i + 1];
blue = my_symbol->bitmap[i + 2]; blue = (int) my_symbol->bitmap[i + 2];
render_pixel(row, column, red, green, blue); render_pixel(row, column, red, green, blue);
i += 3; i += 3;
} }
@ -826,7 +826,8 @@ row_height | array of | Representation of the | (output only)
errtxt | character | Error message in the event | (output only) errtxt | character | Error message in the event | (output only)
| string | that an error ocurred. | | string | that an error ocurred. |
bitmap | pointer to | Pointer to stored bitmap | (output only) bitmap | pointer to | Pointer to stored bitmap | (output only)
| character | image. | | unsigned | image. |
| character | |
| array | | | array | |
bitmap_width | integer | Width of stored bitmap | (output only) bitmap_width | integer | Width of stored bitmap | (output only)
| | image (in pixels). | | | image (in pixels). |