Esempio n. 1
0
int do_resol_adjust(int resol_x, int resol_y, struct image *img)
{
    Log(LOG_DEBUG, "function:%s --- paralist{resol_x=%d,resol_y=%d}\n", __func__, resol_x, resol_y);

    int screen_width = 0, screen_height = 0;
    unsigned char * new_image = NULL, *new_alpha = NULL;

//	get_led_size(CONF_PATH, &screen_width, &screen_height);

    if (RESOL_SCREEN == resol_x && RESOL_SCREEN == resol_y) {
        // fit to screen resolution
        resol_x = screen_width;
        resol_y = screen_height;
        new_image = color_average_resize(img->rgb, img->width, img->height, resol_x, resol_y);
    } else if ((0 < resol_x && 0 < resol_y)) {
        // specific resolution
        new_image = color_average_resize(img->rgb, img->width, img->height, resol_x, resol_y);
    } else
        // original resolution
        return -1;

    if (img->alpha)
        new_alpha = alpha_resize(img->alpha, img->width, img->height, resol_x, resol_y);

    free(img->rgb);
    free(img->alpha);

    img->rgb = new_image;
    img->alpha = new_alpha;
    img->width = resol_x;
    img->height = resol_y;

    return 0;
}
void scale_pic(unsigned char **buffer, int x1, int y1, int xstart, int ystart, int xsize, int ysize,
			   int *imx, int *imy, int *dxp, int *dyp, int *dxo, int *dyo, int alpha)
{
	float xfact=0, yfact=0;
	int txsize=0, tysize=0;
	int txstart =xstart, tystart= ystart;
	
	if (xsize > (ex-xstart)) txsize= (ex-xstart);
	else  txsize= xsize; 
	if (ysize > (ey-ystart)) tysize= (ey-ystart);
	else tysize=ysize;
	xfact= 1000*txsize/x1;
	xfact= xfact/1000;
	yfact= 1000*tysize/y1;
	yfact= yfact/1000;
	
	if ( xfact <= yfact)
	{
		*imx=(int)x1*xfact;
		*imy=(int)y1*xfact;
	}
	else
	{
		*imx=(int)x1*yfact;
		*imy=(int)y1*yfact;
	}
	if ((x1 != *imx) || (y1 != *imy))
		*buffer=color_average_resize(*buffer,x1,y1,*imx,*imy,alpha);

	*dxp=0;
	*dyp=0;
	*dxo=txstart;
	*dyo=tystart;
}
Esempio n. 3
0
int do_scale_adjust(int scale, struct image *img)
{
    Log(LOG_DEBUG, "function:%s --- paralist{scale=%d}\n", __func__, scale);

    if (SCALE_DEF != scale && scale >= SCALE_MIN && scale <= SCALE_MAX) {
        int nx = 0, ny = 0;
        unsigned char * new_image = NULL, *new_alpha = NULL;

        nx = (int) img->width * scale / 100;
        ny = (int) img->height * scale / 100;

        new_image = color_average_resize(img->rgb, img->width, img->height, nx, ny);

        if (img->alpha)
            new_alpha = alpha_resize(img->alpha, img->width, img->height, nx, ny);

        free(img->rgb);
        free(img->alpha);

        img->rgb = new_image;
        img->alpha = new_alpha;
        img->width = nx;
        img->height = ny;
    }

    return 0;
}
Esempio n. 4
0
static inline void do_fit_to_screen(struct image *i, int screen_width, int screen_height, int ignoreaspect, int cal)
{
	if((i->width > screen_width) || (i->height > screen_height))
	{
		unsigned char * new_image, * new_alpha = NULL;
		int nx_size = i->width, ny_size = i->height;
		
		if(ignoreaspect)
		{
			if(i->width > screen_width)
				nx_size = screen_width;
			if(i->height > screen_height)
				ny_size = screen_height;
		}
		else
		{
			if((i->height * screen_width / i->width) <= screen_height)
			{
				nx_size = screen_width;
				ny_size = i->height * screen_width / i->width;
			}
			else
			{
				nx_size = i->width * screen_height / i->height;
				ny_size = screen_height;
			}
		}
		
		if(cal)
			new_image = color_average_resize(i->rgb, i->width, i->height, nx_size, ny_size);
		else
			new_image = simple_resize(i->rgb, i->width, i->height, nx_size, ny_size);
		
		if(i->alpha)
			new_alpha = alpha_resize(i->alpha, i->width, i->height, nx_size, ny_size);
		
		if(i->do_free)
		{
			free(i->alpha);
			free(i->rgb);
		}
		
		i->rgb = new_image;
		i->alpha = new_alpha;
		i->do_free = 1;
		i->width = nx_size;
		i->height = ny_size;
	}
}