⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 image.c

📁 网络摄像头的webserver
💻 C
字号:
#include <stdlib.h>#include "config.h"#include "image.h"voidimage_copy(struct image *dst, const struct image *src){	image_dup(dst, src);	if (src->buf)		memcpy(dst->buf, src->buf, dst->bufsize);	else	{		image_destroy(dst);		dst->buf = NULL;	}}voidimage_new(struct image *img, unsigned int x, unsigned int y){	img->x = x;	img->y = y;	img->bufsize = x * y * 3;	img->buf = malloc(img->bufsize);}voidimage_destroy(struct image *img){	free(img->buf);}voidimage_dup(struct image *dst, const struct image *src){	memcpy(dst, src, sizeof(*dst));	dst->buf = malloc(dst->bufsize);}voidimage_move(struct image *dst, const struct image *src){	image_destroy(dst);	memcpy(dst, src, sizeof(*dst));}floatimage_brightness(struct image *img){	int i;	float sum = 0;	unsigned char *p = img->buf;	for (i=0; i<img->x*img->y; i++) {		sum += *p;		p++;	}	sum /= (img->x * img->y * 3);	return sum;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -