112 lines
3.0 KiB
C
112 lines
3.0 KiB
C
#include "point.h"
|
||
#include "vgagl.h"
|
||
|
||
#if 0
|
||
//画点
|
||
void draw_dot(PFBDEV pFbdev, POINT p, uint8_t r, uint8_t g, uint8_t b) {
|
||
uint32_t offset;
|
||
uint8_t color[2];
|
||
color[0] = COLOR16(r, g, b) & 0x00FF;
|
||
color[1] = COLOR16(r, g, b) >> 8;
|
||
// color[2] = r;
|
||
// color[3] = 0x0; //透明度
|
||
|
||
offset = p.y * pFbdev->fb_fix.line_length + 2 * p.x;
|
||
//将操作映射到内存中
|
||
fb_memcpy((void *)pFbdev->fb_mem + pFbdev->fb_mem_offset + offset, color, 2);
|
||
}
|
||
|
||
void draw_dot_c(PFBDEV pFbdev, POINT p, uint16_t c) {
|
||
uint32_t offset;
|
||
uint8_t color[2];
|
||
// color[0] = COLOR16(r, g, b) & 0x00FF;
|
||
// color[1] = COLOR16(r, g, b) >>8;
|
||
// color[2] = r;
|
||
// color[3] = 0x0; //透明度
|
||
|
||
offset = p.y * pFbdev->fb_fix.line_length + 2 * p.x;
|
||
//将操作映射到内存中
|
||
// fb_memcpy((void *)pFbdev->fb_mem + pFbdev->fb_mem_offset + offset,
|
||
// color, 2);
|
||
//
|
||
long location =
|
||
(p.x + pFbdev->fb_var.xoffset) * (pFbdev->fb_var.bits_per_pixel / 8) +
|
||
(p.y + pFbdev->fb_var.yoffset) * pFbdev->fb_fix.line_length;
|
||
*((uint16_t *)(pFbdev->fb_mem + location)) = c;
|
||
}
|
||
|
||
//画点
|
||
void draw_dot_with_trans(PFBDEV pFbdev, POINT p, uint8_t r, uint8_t g,
|
||
uint8_t b, uint8_t t) {
|
||
uint32_t offset;
|
||
uint8_t color[4];
|
||
color[0] = b;
|
||
color[1] = g;
|
||
color[2] = r;
|
||
color[3] = t; //透明度
|
||
|
||
offset = p.y * pFbdev->fb_fix.line_length + 4 * p.x;
|
||
//将操作映射到内存中
|
||
fb_memcpy((void *)pFbdev->fb_mem + pFbdev->fb_mem_offset + offset, color, 4);
|
||
}
|
||
|
||
//画点
|
||
void draw_x_y_dot(PFBDEV pFbdev, int x, int y, uint8_t r, uint8_t g,
|
||
uint8_t b) {
|
||
POINT p;
|
||
p.x = x;
|
||
p.y = y;
|
||
|
||
// draw_dot(pFbdev, p, r, g, b);
|
||
}
|
||
|
||
//画点
|
||
void draw_x_y_dot_with_trans(PFBDEV pFbdev, int x, int y, uint8_t r, uint8_t g,
|
||
uint8_t b, uint8_t t) {
|
||
POINT p;
|
||
p.x = x;
|
||
p.y = y;
|
||
|
||
draw_dot_with_trans(pFbdev, p, r, g, b, t);
|
||
}
|
||
|
||
//画点
|
||
void draw_x_y_color_dot(PFBDEV pFbdev, int x, int y, RGBT c) {
|
||
draw_x_y_dot(pFbdev, x, y, c.r, c.g, c.b);
|
||
}
|
||
|
||
//画点
|
||
void draw_x_y_color_dot_with_trans(PFBDEV pFbdev, int x, int y, RGBT c) {
|
||
draw_x_y_dot_with_trans(pFbdev, x, y, c.r, c.g, c.b, c.t);
|
||
}
|
||
|
||
//画点 color8位,分别代表RGBT
|
||
void draw_x_y_color_dot_with_string(PFBDEV pFbdev, int x, int y,
|
||
const char *temp) {
|
||
RGBT rgbt = getRGBT(temp);
|
||
|
||
draw_x_y_dot_with_trans(pFbdev, x, y, rgbt.r, rgbt.g, rgbt.b, rgbt.t);
|
||
}
|
||
#endif
|
||
|
||
#define outside(x, y) (x < 0 || x > __xres || y < 0 || y > __yres)
|
||
// 画点 color16位
|
||
#if 0
|
||
void setpixel(int x, int y, int c)
|
||
{
|
||
//if (outside(x, y))
|
||
// return;
|
||
long location = (x + __xoffset) * 2 + (y + __yoffset) * __line_length;
|
||
*((int16_t*)(currFbdev.fb_mem + location)) = c;
|
||
}
|
||
#endif //0
|
||
|
||
#define ASSIGNVP16(x, y, vp) vp = VBUF + (y)*BYTEWIDTH + (x)*2;
|
||
#define ASSIGNVPOFFSET16(x, y, vp) vp = (y)*BYTEWIDTH + (x)*2;
|
||
|
||
void setpixel(int x, int y, int c)
|
||
{
|
||
int8_t * vp;
|
||
ASSIGNVP16(x, y, vp);
|
||
*(uint16_t *)vp = (uint16_t)c;
|
||
} |