Replies: 1 comment
-
can you raise a pull request? Please note I've just merged a huge pull into the master branch so things have changed drastically now. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
`
#ifndef _swap_int16_t
#define _swap_int16_t(a, b)
{
int16_t t = a;
a = b;
b = t;
}
#endif
//private
void MatrixPanel_I2S_DMA::_steepDrawPixelRGB(bool steep, int16_t x, int16_t y, uint8_t r, uint8_t g, uint8_t b)
{
if (steep) drawPixelRGB888(y,x,r,g,b);
else drawPixelRGB888(x,y,r,g,b);
}
//public
//Wu's line algorithm, fix point version
void MatrixPanel_I2S_DMA::writeLineAA(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
{
int32_t dx = x1 - x0;
if (dx < 0) dx = -dx;
int32_t dy = y1 - y0;
if (dy < 0) dy = -dy;
if (dx == 0)
{
drawFastVLine(x0, min(y0,y1), dy, color);
return;
}
if (dy == 0)
{
drawFastHLine(min(x0,x1), y0, dx, color);
return;
}
if (dy == dx)
{
drawLine(x0,y0,x1,y1, color);
return;
}
bool steep = dy > dx;
if (steep)
{
_swap_int16_t(x0, y0);
_swap_int16_t(x1, y1);
}
if (x0 > x1)
{
_swap_int16_t(x0, x1);
_swap_int16_t(y0, y1);
}
uint8_t r,g,b;
color565to888(color, r, g, b);
_steepDrawPixelRGB(steep, x0, y0, r, g, b);
_steepDrawPixelRGB(steep, x1, y1, r, g, b);
int32_t gradient = ((y1-y0)<< 16)/(x1-x0);

int32_t y = (y0 << 16) + gradient;
int16_t gcolor;
uint8_t _r,_g,_b;
for (int x = x0 + 1; x <= x1 - 1; x++)
{
gcolor = (y >> 8)& 255;
_r = (r * gcolor) >> 8;
_g = (g * gcolor) >> 8;
_b = (b * gcolor) >> 8;
int16_t _y = y >> 16;
_steepDrawPixelRGB(steep, x, _y, r-_r, g-_g, b-_b);
_steepDrawPixelRGB(steep, x, _y + 1, _r, _g, _b);
y += gradient;
}
}
`
If not correct gamma-table (one pixel with a value of 255 will be noticeably different from two adjacent pixels with a value of 127):
Beta Was this translation helpful? Give feedback.
All reactions