generated from bob/template
Initial commit
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user