Exemplo n.º 1
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;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
wxImage BorderInvariantResizeImage(const wxImage& image, int width, int height)
{
	if (!image.IsOk() || (width == image.GetWidth() && height == image.GetHeight()))
		return image;

	wxImage ret(width, height);
	Resizer data_resize(ret, image, false);
	data_resize();

	if (image.HasAlpha()) {
		ret.InitAlpha();
		Resizer alpha_resize(ret, image, true);
		alpha_resize();
	}

	return ret;
}
Exemplo n.º 4
0
static inline void do_enlarge(struct image *i, int screen_width, int screen_height, int ignoreaspect)
{
	if(((i->width > screen_width) || (i->height > screen_height)) && (!ignoreaspect))
		return;
	if((i->width < screen_width) || (i->height < screen_height))
	{
		int xsize = i->width, ysize = i->height;
		unsigned char * image, * alpha = NULL;
		
		if(ignoreaspect)
		{
			if(i->width < screen_width)
				xsize = screen_width;
			if(i->height < screen_height)
				ysize = screen_height;
			
			goto have_sizes;
		}
		
		if((i->height * screen_width / i->width) <= screen_height)
		{
			xsize = screen_width;
			ysize = i->height * screen_width / i->width;
			goto have_sizes;
		}
		
		if((i->width * screen_height / i->height) <= screen_width)
		{
			xsize = i->width * screen_height / i->height;
			ysize = screen_height;
			goto have_sizes;
		}
		return;
have_sizes:
		image = simple_resize(i->rgb, i->width, i->height, xsize, ysize);
		if(i->alpha)
			alpha = alpha_resize(i->alpha, i->width, i->height, xsize, ysize);
		
		if(i->do_free)
		{
			free(i->alpha);
			free(i->rgb);
		}
		
		i->rgb = image;
		i->alpha = alpha;
		i->do_free = 1;
		i->width = xsize;
		i->height = ysize;
	}
}
Exemplo n.º 5
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;
	}
}