Nothing changed. Really.
Dithering is still pretty much fvcked up on 256colors mode. Iunno why
This commit is contained in:
parent
44418ac242
commit
7673f7e239
12
src/colors.c
12
src/colors.c
|
@ -91,17 +91,17 @@ int closest_color(palette_t pal, rgba8 color)
|
||||||
|
|
||||||
int closest_256(palette_t pal, rgba8 color)
|
int closest_256(palette_t pal, rgba8 color)
|
||||||
{
|
{
|
||||||
(void)pal; (void)color;
|
(void)pal;
|
||||||
if (color.r == color.g && color.g == color.b)
|
if (color.r == color.g && color.g == color.b)
|
||||||
{
|
{
|
||||||
if (color.r < 8) return 16;
|
if (color.r < 8) return 16;
|
||||||
if (color.r > 248) return 231;
|
if (color.r > 248) return 231;
|
||||||
return 232 + ceil((color.r - 8.0) / 247.0 * 24.0);
|
return 232 + (int)ceil((color.r - 8.0) / 247.0 * 24.0);
|
||||||
}
|
}
|
||||||
uint8_t oc = 16;
|
int oc = 16;
|
||||||
oc += 36 * ceil(color.r / 255.0 * 5.0);
|
oc += 36 * (int)ceil(color.r / 255.0 * 5.0);
|
||||||
oc += 6 * ceil(color.g / 255.0 * 5.0);
|
oc += 6 * (int)ceil(color.g / 255.0 * 5.0);
|
||||||
oc += ceil(color.b / 255.0 * 5.0);
|
oc += (int)ceil(color.b / 255.0 * 5.0);
|
||||||
return oc;
|
return oc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
src/image.c
16
src/image.c
|
@ -32,15 +32,15 @@ image_t *image_resize(image_t *img, int width, int height)
|
||||||
void __dither_update_pixel(image_t *img, int x, int y, int err[3], float bias)
|
void __dither_update_pixel(image_t *img, int x, int y, int err[3], float bias)
|
||||||
{
|
{
|
||||||
if (x < 0 || x >= img->width || y < 0 || y >= img->height) return;
|
if (x < 0 || x >= img->width || y < 0 || y >= img->height) return;
|
||||||
rgba8 pix = img->pixels[x + y * img->width];
|
int i = x + y * img->width;
|
||||||
|
rgba8 pix = img->pixels[i];
|
||||||
int dst[3] = { pix.r, pix.g, pix.b };
|
int dst[3] = { pix.r, pix.g, pix.b };
|
||||||
dst[0] += (int)((float)err[0] * bias);
|
dst[0] += (int)(((float)err[0]) * bias);
|
||||||
dst[1] += (int)((float)err[1] * bias);
|
dst[1] += (int)(((float)err[1]) * bias);
|
||||||
dst[2] += (int)((float)err[2] * bias);
|
dst[2] += (int)(((float)err[2]) * bias);
|
||||||
pix.r = (dst[0] > 255 ? 255 : (dst[0] < 0 ? 0 : dst[0]));
|
img->pixels[i].r = (dst[0] > 255 ? 255 : (dst[0] < 0 ? 0 : dst[0]));
|
||||||
pix.g = (dst[1] > 255 ? 255 : (dst[1] < 0 ? 0 : dst[1]));
|
img->pixels[i].g = (dst[1] > 255 ? 255 : (dst[1] < 0 ? 0 : dst[1]));
|
||||||
pix.b = (dst[2] > 255 ? 255 : (dst[2] < 0 ? 0 : dst[2]));
|
img->pixels[i].b = (dst[2] > 255 ? 255 : (dst[2] < 0 ? 0 : dst[2]));
|
||||||
memcpy(&img->pixels[x + y * img->width], &pix, sizeof(rgba8));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ void mod_blocks_prepare(asc_state_t *state)
|
||||||
case ASC_STL_TRUECOLOR:
|
case ASC_STL_TRUECOLOR:
|
||||||
case ASC_STL_ENDL:
|
case ASC_STL_ENDL:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (res != NULL)
|
if (res != NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue