Added some consistency
This commit is contained in:
parent
848e82274a
commit
02b3923976
|
@ -1,5 +1,5 @@
|
|||
IMAGECON=./out/imagecon
|
||||
OBJS=out/imagecon.o out/png.o out/color.o out/dither.o out/ham.o out/palette.o out/file.o out/sliced_ham.o out/quant.o
|
||||
OBJS=out/imagecon.o out/png.o out/color.o out/dither.o out/ham.o out/palette.o out/file.o out/sliced_ham.o out/quant.o out/utils.o
|
||||
WARN_ERROR=-Werror
|
||||
HOST_WARNINGS=$(WARN_ERROR) -pedantic-errors -Wfatal-errors -Wall -Wextra -Wno-unused-parameter -Wshadow -limagequant
|
||||
HOST_CFLAGS=$(HOST_WARNINGS) -O3
|
||||
|
|
|
@ -92,35 +92,10 @@ color_setDitheredPixel(imagecon_image_t* ic, int x, int y, dither_color_t color)
|
|||
{
|
||||
dither_color_t *d = &ic->dithered[(y*ic->width)+x];
|
||||
|
||||
if (color.r > 255) {
|
||||
color.r = 255;
|
||||
}
|
||||
if (color.r < 0) {
|
||||
color.r = 0;
|
||||
}
|
||||
if (color.g > 255) {
|
||||
color.g = 255;
|
||||
}
|
||||
if (color.g < 0) {
|
||||
color.g = 0;
|
||||
}
|
||||
if (color.b > 255) {
|
||||
color.b = 255;
|
||||
}
|
||||
if (color.b < 0) {
|
||||
color.b = 0;
|
||||
}
|
||||
if (color.a > 255) {
|
||||
color.a = 255;
|
||||
}
|
||||
if (color.a < 0) {
|
||||
color.a = 0;
|
||||
}
|
||||
|
||||
d->r = color.r;
|
||||
d->g = color.g;
|
||||
d->b = color.b;
|
||||
d->a = color.a;
|
||||
d->r = COLOR8(color.r);
|
||||
d->g = COLOR8(color.g);
|
||||
d->b = COLOR8(color.b);
|
||||
d->a = COLOR8(color.a);
|
||||
}
|
||||
|
||||
amiga_color_t
|
||||
|
|
|
@ -13,6 +13,7 @@ dither_getPalettedColor(dither_data_t data)
|
|||
float
|
||||
_gamma(float x)
|
||||
{
|
||||
//return x * 1.0;
|
||||
return x * 0.55;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ _ham_createHams(imagecon_image_t* ic)
|
|||
|
||||
|
||||
static void
|
||||
_ham_outputBitplanes(char* outFilename, imagecon_image_t* ic)
|
||||
_ham_outputBitplanes(imagecon_image_t* ic, char* outFilename)
|
||||
{
|
||||
if (config.verbose) {
|
||||
printf("outputHamBitplanes\n");
|
||||
|
@ -250,9 +250,9 @@ ham_process(imagecon_image_t* ic, char* outFilename)
|
|||
}
|
||||
|
||||
if (config.outputBitplanes) {
|
||||
_ham_outputBitplanes(outFilename, ic);
|
||||
_ham_outputBitplanes(ic, outFilename);
|
||||
}
|
||||
|
||||
palette_output(outFilename, ic);
|
||||
palette_output(ic, outFilename);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,9 +61,6 @@ abort_(const char * s, ...)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
generateQuantizedImage(imagecon_image_t* ic, int usePalette)
|
||||
{
|
||||
|
@ -119,6 +116,10 @@ generateQuantizedImage(imagecon_image_t* ic, int usePalette)
|
|||
}
|
||||
|
||||
ic->numColors = pal->count;
|
||||
|
||||
liq_attr_destroy(attr);
|
||||
liq_image_destroy(image);
|
||||
liq_result_destroy(res);
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,7 +153,7 @@ generateQuant2(imagecon_image_t* ic)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
generatePalettedImage(imagecon_image_t* ic)
|
||||
{
|
||||
if (config.verbose) {
|
||||
|
@ -200,8 +201,8 @@ generatePalettedImage(imagecon_image_t* ic)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
outputBitplanes(char* outFilename, imagecon_image_t* ic)
|
||||
static void
|
||||
outputBitplanes(imagecon_image_t* ic, char* outFilename)
|
||||
{
|
||||
if (config.verbose) {
|
||||
printf("outputBitplanes...\n");
|
||||
|
@ -270,15 +271,17 @@ outputBitplanes(char* outFilename, imagecon_image_t* ic)
|
|||
fwrite(&plane[y*byteWidth], byteWidth, 1, fp);
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
free_vector(bitplanes, numBitPlanes);
|
||||
if (config.verbose) {
|
||||
printf("done\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
outputMask(char* outFilename, imagecon_image_t* ic)
|
||||
static void
|
||||
outputMask(imagecon_image_t* ic, char* outFilename)
|
||||
{
|
||||
if (config.verbose) {
|
||||
printf("outputMask...\n");
|
||||
|
@ -316,13 +319,13 @@ outputMask(char* outFilename, imagecon_image_t* ic)
|
|||
}
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
free_vector(bitplanes, numBitPlanes);
|
||||
if (config.verbose) {
|
||||
printf("done\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
generateEHBImage(imagecon_image_t* ic)
|
||||
{
|
||||
if (config.maxColors > 32) {
|
||||
|
@ -376,14 +379,14 @@ processFile(char* outFilename, imagecon_image_t* ic)
|
|||
}
|
||||
|
||||
if (config.outputBitplanes) {
|
||||
outputBitplanes(outFilename, ic);
|
||||
outputBitplanes(ic, outFilename);
|
||||
}
|
||||
|
||||
if (config.outputMask) {
|
||||
outputMask(outFilename, ic);
|
||||
outputMask(ic, outFilename);
|
||||
}
|
||||
|
||||
palette_output(outFilename, ic);
|
||||
palette_output(ic, outFilename);
|
||||
}
|
||||
|
||||
if (config.verbose) {
|
||||
|
@ -392,7 +395,7 @@ processFile(char* outFilename, imagecon_image_t* ic)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
splitFiles(char* inputFile, int* count, char*** vector)
|
||||
{
|
||||
char* ptr = inputFile;
|
||||
|
@ -423,7 +426,7 @@ splitFiles(char* inputFile, int* count, char*** vector)
|
|||
|
||||
#define max(x,y) (x > y ? x : y)
|
||||
|
||||
void
|
||||
static void
|
||||
combineImages(imagecon_image_t** images, int numImages, imagecon_image_t* ic)
|
||||
{
|
||||
ic->width = 0;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define RGB24TORGB12(x) (x >> 4)
|
||||
#define CLAMP(x) (x > 255.0 ? 255.0 : (x < -255.0 ? -255.0 : x))
|
||||
#define COLOR8(x) (x > 255.0 ? 255.0 : (x < 0.0 ? 0.0 : x))
|
||||
|
||||
typedef struct {
|
||||
int maxColors;
|
||||
|
@ -73,6 +74,7 @@ typedef struct {
|
|||
#include "file.h"
|
||||
#include "palette.h"
|
||||
#include "quant.h"
|
||||
#include "utils.h"
|
||||
|
||||
extern imagecon_config_t config;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ void palette_loadFile(imagecon_image_t* ic)
|
|||
|
||||
|
||||
void
|
||||
palette_output(char* outFilename, imagecon_image_t* ic)
|
||||
palette_output(imagecon_image_t* ic, char* outFilename)
|
||||
{
|
||||
if (config.verbose) {
|
||||
printf("outputPalette...%d colors\n", ic->numColors);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
void
|
||||
palette_output(char* outFilename, imagecon_image_t* ic);
|
||||
palette_output(imagecon_image_t* ic, char* outFilename);
|
||||
|
||||
void
|
||||
palette_loadFile(imagecon_image_t* ic);
|
||||
|
|
|
@ -122,4 +122,5 @@ png_read(char* file_name, imagecon_image_t* ic)
|
|||
}
|
||||
|
||||
ic->amigaImage = calloc(ic->width*ic->height, 1);
|
||||
ic->dithered = 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
#include "imagecon.h"
|
||||
|
||||
void
|
||||
free_vector(char** vector, int size)
|
||||
{
|
||||
for (int i = 0; i < size; i++) {
|
||||
free(vector[i]);
|
||||
}
|
||||
free(vector);
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
void
|
||||
free_vector(char** vector, int size);
|
Loading…
Reference in New Issue