📄 pmpimage.c
字号:
for (x_pos = 0; x_pos < image_width; x_pos++) { *(p_img+0) = *(rc+0); *(p_img+1) = *(rc+1); *(p_img+2) = *(rc+2); p_img = p_img + 3; rc = rc + 3; } } if (i->rgb != image) free(i->rgb); i->rgb = img;}inline void do_alpha_revolve_updown(struct image *i){ unsigned char *img=NULL; int y_pos=0, x_pos=0; int image_width = i->width; int image_height = i->height; unsigned char *p = i->alpha; unsigned char *rc = NULL; unsigned char *p_img = NULL; img = (unsigned char *)malloc(image_width*image_height); assert(img); p_img = img; memset((void *)img, 0x00, image_width*image_height); for (y_pos = image_height-1; y_pos >= 0; y_pos--) { rc = p + y_pos*image_width; for (x_pos = 0; x_pos < image_width; x_pos++) *p_img++ = *rc++; } if (i->alpha != alpha) free(i->alpha); i->alpha = img;}//旋转180度实现函数inline void do_rotate_horizontal(struct image *i){ unsigned char *img=NULL, *p_img=NULL; int y_pos=0; int image_width = i->width; int image_height = i->height; unsigned char *p= i->rgb; img = (unsigned char*)malloc(image_width*image_height*3); assert(img); p_img = img; p += image_width*image_height*3; for(y_pos = image_width * image_height; y_pos > 0; y_pos--) { p -= 3; *(p_img+0) = *(p+0); *(p_img+1) = *(p+1); *(p_img+2) = *(p+2); p_img += 3; } if (i->rgb != image) free(i->rgb); i->rgb = img;}inline void do_alpha_rotate_horizontal(struct image *i){ unsigned char *img=NULL, *p_img=NULL; int y_pos=0; int image_width = i->width; int image_height = i->height; unsigned char *p= i->alpha; img = (unsigned char*)malloc(image_width*image_height); assert(img); p_img = img; p += image_width*image_height; for(y_pos = image_width*image_height; y_pos > 0; y_pos--) *p_img++ = *p--; if (i->alpha != alpha) free(i->alpha); i->alpha = img;}//逆时针旋转90度实现函数inline void do_rotate_anti_clockwise_vertical(struct image *i){ unsigned char *img=NULL, *p_img=NULL, *rc=NULL; int x_pos=0, y_pos=0; int image_width = i->width; int image_height = i->height; unsigned char *p= i->rgb; img = (unsigned char*)malloc(image_width*image_height*3); assert(img); p_img = img; for(y_pos = 0; y_pos<image_height; y_pos++, p_img += 3) { rc = p_img + ((image_width*3)*image_height); for(x_pos = 0; x_pos<image_width;x_pos++) { rc -= image_height*3; *(rc+0) = *(p++); *(rc+1) = *(p++); *(rc+2) = *(p++); } } if (i->rgb != image) free(i->rgb); i->rgb = img; i->width = image_height; i->height = image_width;}inline void do_alpha_rotate_anti_clockwise_vertical(struct image *i){ unsigned char *img=NULL, *p_img=NULL, *rc=NULL; int x_pos=0, y_pos=0; int image_width = i->width; int image_height = i->height; unsigned char *p= i->alpha; img = (unsigned char*)malloc(image_width*image_height); assert(img); p_img = img; for(y_pos = 0; y_pos<image_height; y_pos++, p_img++) { rc = p_img + (image_width*image_height); for(x_pos=0; x_pos<image_width; x_pos++) { rc -= image_height; *rc = *p++; } } if (i->alpha != alpha) free(i->alpha); i->alpha = img; i->width = image_height; i->height = image_width;}//顺时针旋转90度inline void do_rotate_clockwise_vertical(struct image *i){ int image_width = i->width; int image_height = i->height; unsigned char *p = i->rgb; unsigned char *img=NULL, *p_img=NULL, *rc=NULL; int x_pos=0, y_pos=0; img = (unsigned char*) malloc(image_width * image_height * 3); assert(img); p_img = img + (image_height - 1) * 3; for(y_pos = 0; y_pos < image_height; y_pos++, p_img -= 3) { rc = p_img; for(x_pos = 0; x_pos < image_width; x_pos++, rc += image_height*3) { *(rc+0) = *(p++); *(rc+1) = *(p++); *(rc+2) = *(p++); } } if (i->rgb != image) free(i->rgb); i->rgb = img; i->width = image_height; i->height = image_width;}inline void do_alpha_rotate_clockwise_vertical(struct image *i){ int image_width = i->width; int image_height = i->height; unsigned char *p = i->alpha; unsigned char *img=NULL, *p_img=NULL, *rc=NULL; int x_pos=0, y_pos=0; img = (unsigned char*)malloc(image_width*image_height); assert(img); p_img = img+(image_height-1); for(y_pos = 0; y_pos < image_height; y_pos++, p_img--) { rc = p_img; for(x_pos=0; x_pos<image_width; x_pos++, rc += image_height) *rc = *p++; } if (i->alpha != alpha) free(i->alpha); i->alpha = img; i->width = image_height; i->height = image_width;}void do_image_comment(struct image *i){ int img_width = i->width; int img_height = i->height; if (show_param.rotation_direction == DIRTION_LEFT) { do_rotate_clockwise_vertical(i); if (i->alpha != NULL) { if (i->alpha != alpha) free(i->alpha); i->alpha = alpha; i->width = img_width; i->height = img_height; do_alpha_rotate_clockwise_vertical(i); } } if (show_param.rotation_direction == DIRTION_DOWN) { do_rotate_horizontal(i); if (i->alpha != NULL) { if (i->alpha != alpha) free(i->alpha); i->alpha = alpha; i->width = img_width; i->height = img_height; do_alpha_rotate_horizontal(i); } } if (show_param.rotation_direction == DIRTION_RIGHT) { do_rotate_anti_clockwise_vertical(i); } if (show_param.left_right_dirtion == REVOLVE_RIGHT_DIRTION) { do_revolve_left(i); if (i->alpha != NULL) { if (i->alpha != alpha) free(i->alpha); i->alpha = alpha; i->width = img_width; i->height = img_height; do_alpha_revolve_left(i); } } if (show_param.updown_direction == REVOLVE_DOWN_DIRTION) { do_revolve_updown(i); if (i->alpha != NULL) { if (i->alpha != alpha) free(i->alpha); i->alpha = alpha; i->width = img_width; i->height = img_height; do_alpha_revolve_updown(i); } }}void do_little_scale(struct image *i){ if ((i->width < show_param.screen_width/20) || (i->width < show_param.screen_height/20)) return; else { if ((i->rgb != image) && (i->rgb != NULL)) { free(i->rgb); } i->rgb = image; i->width = show_param.source_width; i->height = show_param.source_height; do_image_comment(i); show_param.show_width -= show_param.show_width/10; show_param.show_height -= show_param.show_height/10; do_image_resize(i, show_param.show_width, show_param.show_height); if (i->alpha != NULL) { if (i->alpha != alpha) free(i->alpha); i->alpha = alpha; i->width = show_param.source_width; i->height = show_param.source_height; do_alpha_resize(i, show_param.show_width, show_param.show_height); } }}void do_large_scale(struct image *i){ if ((i->width > show_param.screen_width*5) || (i->width > show_param.screen_height*5)) return; else { if ((i->rgb != NULL) && (i->rgb != image)) free(i->rgb); i->rgb = image; i->width = show_param.source_width; i->height = show_param.source_height; do_image_comment(i); show_param.show_width += show_param.show_width/10; show_param.show_height += show_param.show_height/10; do_image_resize(i, show_param.show_width, show_param.show_height); if (i->alpha != NULL) { if (i->alpha != alpha) free(i->alpha); i->alpha = alpha; i->width = show_param.source_width; i->height = show_param.source_height; do_alpha_resize(i, show_param.show_width, show_param.show_height); } }}void do_image_full_screen(struct image *i, int ignoreaspect){ int xsize=0, ysize=0; if (i->rgb != image) free(i->rgb); if (i->alpha != alpha) free(i->alpha); i->rgb = image; i->alpha = alpha; i->width = show_param.source_width; i->height = show_param.source_height; do_image_comment(i); if((i->width > show_param.screen_width) || (i->height > show_param.screen_height)) { xsize = i->width; ysize = i->height; if(ignoreaspect) { if(i->width > show_param.screen_width) xsize = show_param.screen_width; if(i->height > show_param.screen_height) ysize = show_param.screen_height; goto have_sizes; } else { if((i->height * show_param.screen_width/i->width) <= show_param.screen_height) { xsize = show_param.screen_width; ysize = i->height * show_param.screen_width/i->width; goto have_sizes; } if((i->width * show_param.screen_height/i->height) <= show_param.screen_width) { xsize = i->width * show_param.screen_height/i->height; ysize = show_param.screen_height; goto have_sizes; } } } else { xsize = i->width; ysize = i->height; if(ignoreaspect) { if(i->width < show_param.screen_width) xsize = show_param.screen_width; if(i->height < show_param.screen_height) ysize = show_param.screen_height; goto have_sizes; } if((i->height * show_param.screen_width/i->width) <= show_param.screen_height) { xsize = show_param.screen_width; ysize = i->height * show_param.screen_width/i->width; goto have_sizes; } if((i->width * show_param.screen_height/i->height) <= show_param.screen_width) { xsize = i->width * show_param.screen_height/i->height; ysize = show_param.screen_height; goto have_sizes; } return; }have_sizes: if (i->rgb != image) free(i->rgb); i->rgb = (unsigned char *)malloc(IMAGE_BUFFER_SIZE*3); memset(i->rgb , 0x00, IMAGE_BUFFER_SIZE*3); memcpy(i->rgb , image, IMAGE_BUFFER_SIZE*3); i->width = show_param.source_width; i->height = show_param.source_height; do_image_comment(i); do_image_resize(i, xsize, ysize); if (i->alpha != NULL) { if (i->alpha != alpha) free(i->alpha); i->alpha = (unsigned char *)malloc(IMAGE_BUFFER_SIZE); memset(i->alpha, 0x00, IMAGE_BUFFER_SIZE); memcpy(i->alpha, alpha, IMAGE_BUFFER_SIZE); i->width = show_param.source_width; i->height = show_param.source_height; do_alpha_resize(i, xsize, ysize); } i->width = xsize; i->height = ysize; show_param.show_width = xsize; show_param.show_height = ysize; image_data_process(&p_image); image_dofresh();}int load_image_comment(char *filename, int *x_size, int *y_size){ int x_image, y_image; int (*load)(char *, unsigned char *, unsigned char **, int, int);#ifdef FBV_SUPPORT_GIF if(fh_gif_id(filename)) { if(fh_gif_getsize(filename, &x_image, &y_image) == FH_ERROR_OK) { load = fh_gif_load; goto identified; } }#endif#ifdef FBV_SUPPORT_PNG if(fh_png_id(filename)) { if(fh_png_getsize(filename, &x_image, &y_image) == FH_ERROR_OK) { load = fh_png_load; goto identified;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -