fix segfault
This commit is contained in:
parent
a047deda99
commit
ec1fefc32e
2 changed files with 15 additions and 8 deletions
14
Makefile
14
Makefile
|
@ -1,18 +1,22 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -g -L. -lm -O3 -march=native
|
CFLAGS = -Wall -L. -lm -O3 -march=native
|
||||||
|
CDEBUGFLAGS = -Wall -L. -lm -g
|
||||||
SOURCE = main.c
|
SOURCE = main.c
|
||||||
TARGET = enhancer
|
TARGET = enhancer
|
||||||
|
|
||||||
# Default target
|
# Default target
|
||||||
all: $(TARGET)
|
all: release
|
||||||
|
|
||||||
# Rule to build the executable
|
# Rule to build the executable
|
||||||
$(TARGET): $(SOURCE)
|
release: $(SOURCE)
|
||||||
$(CC) $(CFLAGS) -o $@ $<
|
$(CC) $(CFLAGS) -o $(TARGET) $<
|
||||||
|
|
||||||
|
debug: $(SOURCE)
|
||||||
|
$(CC) $(CDEBUGFLAGS) -o $(TARGET)_debug $<
|
||||||
|
|
||||||
# Rule to clean up object files and the executable
|
# Rule to clean up object files and the executable
|
||||||
clean:
|
clean:
|
||||||
rm -f $(TARGET) *.o
|
rm -f $(TARGET) $(TARGET)_debug *.o
|
||||||
|
|
||||||
# Phony targets
|
# Phony targets
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
7
main.c
7
main.c
|
@ -76,6 +76,8 @@ void vibrancer(unsigned char *pixel) {
|
||||||
g = pixel[1],
|
g = pixel[1],
|
||||||
b = pixel[2];
|
b = pixel[2];
|
||||||
|
|
||||||
|
printf("%d %d %d\n", r, g, b);
|
||||||
|
|
||||||
// TODO remove unnecessary calculations
|
// TODO remove unnecessary calculations
|
||||||
int min_rgb = min3(r, g, b);
|
int min_rgb = min3(r, g, b);
|
||||||
int max_rgb = max3(r, g, b);
|
int max_rgb = max3(r, g, b);
|
||||||
|
@ -99,7 +101,6 @@ void vibrancer(unsigned char *pixel) {
|
||||||
pixel[0] = clamp(r, 0, 255);
|
pixel[0] = clamp(r, 0, 255);
|
||||||
pixel[1] = clamp(g, 0, 255);
|
pixel[1] = clamp(g, 0, 255);
|
||||||
pixel[2] = clamp(b, 0, 255);
|
pixel[2] = clamp(b, 0, 255);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
@ -118,7 +119,9 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
int width, height, channels;
|
int width, height, channels;
|
||||||
|
|
||||||
unsigned char *img = stbi_load(input, &width, &height, &channels, 3);
|
unsigned char *img = stbi_load(input, &width, &height, &channels, 0);
|
||||||
|
|
||||||
|
printf("Width: %d, Height: %d, Channels: %d\n", width, height, channels);
|
||||||
|
|
||||||
if (img == NULL) {
|
if (img == NULL) {
|
||||||
printf("Error loading image\n");
|
printf("Error loading image\n");
|
||||||
|
|
Loading…
Reference in a new issue