📄 image.c
字号:
#include <stdlib.h>#include <stdio.h>#include "image.h"#include "fft-spectra.h"color_t *get_color(char *string){ color_t *color = malloc(sizeof(color_t)); unsigned int r,g,b; sscanf(string,"#%2x%2x%2x",&r,&g,&b); color->r = r; color->g = g; color->b = b; return color;}void image_fill_rectangle(image_t *img,color_t *color, int x,int y,int width,int height){ int rowstride = img->width*3; int idx,h,w; guchar *ptr; if ( x+width>img->width ) exit_nicely("FIXME: img width=%d, x=%d, w=%d\n",img->width,x,width); if ( y+height>img->height ) exit_nicely("FIXME: img height=%d, y=%d, h=%d\n",img->height,y,height); for (h=0; h<height; h++) { idx = rowstride*h + x*3; ptr = &(img->data[idx]); for (w=0; w<width; w++) { if ( ptr+3>&(img->data[img->width*img->height*3])) exit_nicely("FIXME: image_fill_rectangle .. w=%d h=%d idx=%d; width=%d height=%d\n", w,h,idx,img->width,img->height); *ptr = color->r; ptr++; *ptr = color->g; ptr++; *ptr = color->b; ptr++; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -