Browse Source

Actaully disable that warning, fix a bug

Creating a paletted image along with other images broke it
tags/v1.8.0
Xerbo 4 years ago
parent
commit
d37f450229
2 changed files with 11 additions and 13 deletions
  1. +1
    -1
      Makefile
  2. +10
    -12
      pngio.c

+ 1
- 1
Makefile View File

@@ -1,7 +1,7 @@
CC = gcc CC = gcc
BIN = /usr/bin BIN = /usr/bin
INCLUDES = -I. INCLUDES = -I.
CFLAGS = -O3 -g -Wall -Wextra $(INCLUDES)
CFLAGS = -O3 -g -Wall -Wextra -Wno-missing-field-initializers $(INCLUDES)
OBJS = main.o image.o dsp.o filter.o reg.o pngio.o median.o color.o OBJS = main.o image.o dsp.o filter.o reg.o pngio.o median.o color.o


aptdec: $(OBJS) aptdec: $(OBJS)


+ 10
- 12
pngio.c View File

@@ -277,8 +277,8 @@ int applyUserPalette(float **prow, int nrow, char *filename, rgb_t **crow){
for(int y = 0; y < nrow; y++){ for(int y = 0; y < nrow; y++){
for(int x = 0; x < CH_WIDTH; x++){ for(int x = 0; x < CH_WIDTH; x++){
int cha = prow[y][x + CHA_OFFSET]; int cha = prow[y][x + CHA_OFFSET];
int cbb = prow[y][x + CHB_OFFSET];
crow[y][x + CHA_OFFSET] = pal_row[cbb][cha];
int chb = prow[y][x + CHB_OFFSET];
crow[y][x + CHA_OFFSET] = pal_row[chb][cha];
} }
} }
@@ -293,7 +293,6 @@ int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, c
sprintf(outName, "%s/%s", opts->path, opts->filename); sprintf(outName, "%s/%s", opts->path, opts->filename);
} }


#pragma GCC diagnostic ignored "-Wunused-result"
png_text meta[] = { png_text meta[] = {
{PNG_TEXT_COMPRESSION_NONE, "Software", VERSION}, {PNG_TEXT_COMPRESSION_NONE, "Software", VERSION},
{PNG_TEXT_COMPRESSION_NONE, "Channel", desc, sizeof(desc)}, {PNG_TEXT_COMPRESSION_NONE, "Channel", desc, sizeof(desc)},
@@ -340,8 +339,8 @@ int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, c
} }
if(opts->map != NULL && opts->map[0] != '\0'){ if(opts->map != NULL && opts->map[0] != '\0'){
greyscale = 0;
}
greyscale = 0;
}


FILE *pngfile; FILE *pngfile;


@@ -384,15 +383,15 @@ int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, c
png_write_info(png_ptr, info_ptr); png_write_info(png_ptr, info_ptr);


// Move prow into crow, crow ~ color rows, if required // Move prow into crow, crow ~ color rows, if required
rgb_t *crow[img->nrow];
if(!greyscale){
prow2crow(img->prow, img->nrow, palette, crow);
}
rgb_t *crow[MAX_HEIGHT];
if(!greyscale){
prow2crow(img->prow, img->nrow, palette, crow);
}
// Apply a user provided color palette // Apply a user provided color palette
if(CONTAINS(opts->type, Palleted)){ if(CONTAINS(opts->type, Palleted)){
applyUserPalette(img->prow, img->nrow, opts->palette, crow); applyUserPalette(img->prow, img->nrow, opts->palette, crow);
}
}


// Precipitation overlay // Precipitation overlay
if(CONTAINS(opts->effects, Precipitation_Overlay)){ if(CONTAINS(opts->effects, Precipitation_Overlay)){
@@ -417,7 +416,6 @@ int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, c


printf("Writing %s", outName); printf("Writing %s", outName);


// Float power macro (for gamma adjustment) // Float power macro (for gamma adjustment)
#define POWF(a, b) (b == 1.0 ? a : exp(b * log(a))) #define POWF(a, b) (b == 1.0 ? a : exp(b * log(a)))
float a = POWF(255, opts->gamma)/255; float a = POWF(255, opts->gamma)/255;


Loading…
Cancel
Save