Files
template/user_proc.c
T

27 lines
758 B
C
Raw Normal View History

2026-09-13 20:57:03 +08:00
#include <stdint.h>
#include "user_proc.h"
//绘制十字交叉线
void draw_cross(GrayImage *img, int x, int y, int size, uint8_t color){
if(!img || !img->data) return;
//获取图像宽度和高度
int w = img->width;
int h = img->height;
if(x<0 || x>=w || y<0 || y>=h) return;
//定义一个二维数组指针方便访问像素
uint8_t **image = img->rows;
for(int dx=-size;dx<=size;dx++){
int nx = x + dx;
if(nx>=0 && nx<w){
image[y][nx] = color;
}
}
for(int dy=-size;dy<=size;dy++){
int ny = y + dy;
if(ny>=0 && ny<h){
image[ny][x] = color;
}
}
}
void img_proc(GrayImage *img){
draw_cross(img, img->width/2, img->height/2, 20, 0);
}