diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-06-04 00:41:50 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-06-04 00:43:25 -0400 |
commit | 1f5c772a25aee961d02587de4f867bd2861fe0b8 (patch) | |
tree | 951385bf6950adfc9d5aada1ebada5430cd745a5 | |
parent | 4176d499ef3ccd1803e5d8a5d0baf3b7f4237458 (diff) |
upscale
-rw-r--r-- | demos/upscale.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/demos/upscale.c b/demos/upscale.c index 02d4ec32..50195e3b 100644 --- a/demos/upscale.c +++ b/demos/upscale.c @@ -92,39 +92,50 @@ out: typedef struct pixman_f_transform pixman_f_transform_t; static pixman_image_t * -scale_image (pixman_image_t *image, double scale_factor) +scale_image (pixman_image_t *image, double scale_x, double scale_y) { pixman_image_t *result; int old_width = pixman_image_get_width (image); int old_height = pixman_image_get_height (image); - int new_width = sqrt (0.5 * old_width * scale_factor * 0.5 * old_width * scale_factor + - 0.5 * old_height * scale_factor * 0.5 * old_height * scale_factor) * 2; - int new_height = new_width; + int new_width = scale_x * old_width + 0.5; + int new_height = scale_y * old_height + 0.5; pixman_f_transform_t ftransform; + pixman_f_transform_t iftransform; pixman_transform_t transform; result = pixman_image_create_bits ( PIXMAN_a8r8g8b8, new_width, new_height, NULL, -1); - pixman_f_transform_init_translate ( - &ftransform, - old_width / 2.0, - old_height / 2.0); + pixman_f_transform_init_identity (&ftransform); + + pixman_f_transform_translate ( + &ftransform, NULL, - 0.5 * old_width, - 0.5 * old_height); pixman_f_transform_scale ( - &ftransform, NULL, scale_factor, scale_factor); + &ftransform, NULL, scale_x, scale_y); + +#if 0 +#define RADS(d) \ + ((d / 360.0) * 2 * G_PI) pixman_f_transform_rotate ( - &ftransform, NULL, sin (30.0), cos (30.0)); + &ftransform, NULL, cos (RADS (10.0)), sin (RADS (10.0))); +#endif pixman_f_transform_translate ( &ftransform, NULL, 0.5 * new_width, 0.5 * new_height); - if (!pixman_f_transform_invert (&ftransform, &ftransform)) +#if 0 +#endif + + if (!pixman_f_transform_invert (&iftransform, &ftransform)) printf ("no invert\n"); - pixman_transform_from_pixman_f_transform (&transform, &ftransform); + pixman_transform_from_pixman_f_transform (&transform, &iftransform); pixman_image_set_transform (image, &transform); #if 0 + pixman_image_set_filter (image, PIXMAN_FILTER_BILINEAR, NULL, 0); pixman_image_set_sampling (image, PIXMAN_SAMPLE_BOX); #endif @@ -156,7 +167,9 @@ main (int argc, char **argv) return -1; } - result = scale_image (image, 1/4.0); + printf ("Loaded file\n"); + + result = scale_image (image, 1/4.0, 3); show_image (result); |