Fixed grayscale handling in main.c and tricorn.c
Now grayscale files use a color pallete and in general should be smaller.
This commit is contained in:
@@ -7,6 +7,7 @@ void tricorn(float complex start, size_t width, ssize_t height, float res, unsig
|
||||
|
||||
// Absolute height for iteration purposes
|
||||
height = height < 0 ? height*-1 : height;
|
||||
unsigned bytesPerColor = color ? 3 : 1;
|
||||
|
||||
// Simple iteration over every pixel in the picture
|
||||
for(size_t i = 0; i < width; i++){
|
||||
@@ -15,13 +16,11 @@ void tricorn(float complex start, size_t width, ssize_t height, float res, unsig
|
||||
unsigned value = converge(start + (i*res - I*j*res),n);
|
||||
|
||||
// Pixel value position in the output array
|
||||
size_t position = (j*width +i) *3;
|
||||
size_t position = (j*width +i) * bytesPerColor;
|
||||
|
||||
|
||||
if(!color){ // Grayscale colors as specified by the assignment r = g = b
|
||||
img[position] = value;
|
||||
img[position + 1] = value;
|
||||
img[position + 2] = value;
|
||||
}
|
||||
else{ // Temporary colors with random multipliers
|
||||
img[position] = ((value*3) % 255);
|
||||
|
||||
Reference in New Issue
Block a user