mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-20 10:15:10 -04:00
gif.c: #191 suppress clang-tidy warning; very small bitmap fix
This commit is contained in:
parent
d88d5906fd
commit
4391fb6a1d
6 changed files with 150 additions and 17 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
/*
|
||||
libzint - the open source barcode library
|
||||
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
|
||||
Copyright (C) 2009 - 2020 Robin Stuart <rstuart114@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
|
@ -32,7 +32,6 @@
|
|||
/* vim: set ts=4 sw=4 et : */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "common.h"
|
||||
#include <math.h>
|
||||
|
@ -49,8 +48,6 @@
|
|||
*/
|
||||
#define TRANSPARENT_INDEX (-1)
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef struct s_statestruct {
|
||||
unsigned char * pOut;
|
||||
unsigned char *pIn;
|
||||
|
@ -67,6 +64,7 @@ typedef struct s_statestruct {
|
|||
unsigned char NodePix[4096];
|
||||
unsigned char colourCode[10];
|
||||
unsigned char colourPaletteIndex[10];
|
||||
int colourCount;
|
||||
} statestruct;
|
||||
|
||||
/* Transform a Pixel to a lzw colourmap index and move to next pixel.
|
||||
|
@ -79,11 +77,12 @@ static unsigned char NextPaletteIndex(statestruct *pState)
|
|||
pixelColour = *(pState->pIn);
|
||||
(pState->pIn)++;
|
||||
(pState->InLen)--;
|
||||
for (colourIndex = 0;; colourIndex++) {
|
||||
for (colourIndex = 0; colourIndex < pState->colourCount; colourIndex++) {
|
||||
if (pixelColour == pState->colourCode[colourIndex])
|
||||
return pState->colourPaletteIndex[colourIndex];
|
||||
|
||||
}
|
||||
return 0; /* Not reached */
|
||||
}
|
||||
|
||||
|
||||
|
@ -301,14 +300,16 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
|
||||
unsigned char pixelColour;
|
||||
|
||||
/* Allow for overhead of 4 == code size + byte count + overflow byte + zero terminator */
|
||||
unsigned int lzoutbufSize = symbol->bitmap_height * symbol->bitmap_width + 4;
|
||||
#ifdef _MSC_VER
|
||||
char * lzwoutbuf;
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
char lzwoutbuf[symbol->bitmap_height * symbol->bitmap_width];
|
||||
char lzwoutbuf[lzoutbufSize];
|
||||
#else
|
||||
lzwoutbuf = (char *) _alloca((symbol->bitmap_height * symbol->bitmap_width) * sizeof (char));
|
||||
lzwoutbuf = _alloca(lzoutbufSize);
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* Open output file in binary mode */
|
||||
|
@ -444,6 +445,8 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
(State.colourPaletteIndex)[colourCount] = paletteIndex;
|
||||
colourCount++;
|
||||
}
|
||||
State.colourCount = colourCount;
|
||||
|
||||
/* find palette bit size from palette size*/
|
||||
|
||||
/* 1,2 -> 1, 3,4 ->2, 5,6,7,8->3 */
|
||||
|
@ -563,7 +566,7 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||
State.pIn = (unsigned char *) pixelbuf;
|
||||
State.InLen = symbol->bitmap_height * symbol->bitmap_width;
|
||||
State.pOut = (unsigned char *) lzwoutbuf;
|
||||
State.OutLength = symbol->bitmap_height * symbol->bitmap_width;
|
||||
State.OutLength = lzoutbufSize;
|
||||
|
||||
/* call lzw encoding */
|
||||
byte_out = gif_lzw(&State, paletteBitSize);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue