Mercurial > MadButterfly
comparison src/shape_image.c @ 1433:7bd6c0e88ec8
Fix issue of showing image incorrectly.
- It is discussed in ticket #23 that objects are refreshed partially.
- It is actually only for image since multiple image share a image
paint, it will modify sampling matrix when they transforming.
Values of later ones would over-write eariler ones.
- It is fixed by move matrix setting until drawing.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 11 Apr 2011 12:45:20 +0800 |
parents | bae104d8d247 |
children |
comparison
equal
deleted
inserted
replaced
1432:8e8c9ab3818f | 1433:7bd6c0e88ec8 |
---|---|
57 shape_t shape; | 57 shape_t shape; |
58 | 58 |
59 co_aix x, y; | 59 co_aix x, y; |
60 co_aix w, h; | 60 co_aix w, h; |
61 co_aix poses[4][2]; | 61 co_aix poses[4][2]; |
62 co_aix sample_matrix[6]; | |
62 | 63 |
63 redraw_man_t *rdman; | 64 redraw_man_t *rdman; |
64 } sh_image_t; | 65 } sh_image_t; |
65 | 66 |
66 static void sh_image_free(shape_t *shape); | 67 static void sh_image_free(shape_t *shape); |
118 void sh_image_transform(shape_t *shape) { | 119 void sh_image_transform(shape_t *shape) { |
119 sh_image_t *img = (sh_image_t *)shape; | 120 sh_image_t *img = (sh_image_t *)shape; |
120 paint_t *paint; | 121 paint_t *paint; |
121 co_aix (*poses)[2]; | 122 co_aix (*poses)[2]; |
122 co_aix img_matrix[6]; | 123 co_aix img_matrix[6]; |
123 co_aix rev_matrix[6]; | |
124 co_aix x_factor, y_factor; | 124 co_aix x_factor, y_factor; |
125 int img_w, img_h; | 125 int img_w, img_h; |
126 int i; | 126 int i; |
127 | 127 |
128 poses = img->poses; | 128 poses = img->poses; |
162 img_matrix[1] *= x_factor; | 162 img_matrix[1] *= x_factor; |
163 y_factor = img->h / img_h; | 163 y_factor = img->h / img_h; |
164 img_matrix[3] *= y_factor; | 164 img_matrix[3] *= y_factor; |
165 img_matrix[4] *= y_factor; | 165 img_matrix[4] *= y_factor; |
166 } | 166 } |
167 compute_reverse(img_matrix, rev_matrix); | 167 compute_reverse(img_matrix, img->sample_matrix); |
168 paint_image_set_matrix(sh_get_fill(shape), rev_matrix); | |
169 } | 168 } |
170 | 169 |
171 /*! \brief Draw image for an image shape. | 170 /*! \brief Draw image for an image shape. |
172 * | 171 * |
173 * \note Image is not rescaled for size of the shape. | 172 * \note Image is not rescaled for size of the shape. |
174 */ | 173 */ |
175 void sh_image_draw(shape_t *shape, mbe_t *cr) { | 174 void sh_image_draw(shape_t *shape, mbe_t *cr) { |
176 sh_image_t *img = (sh_image_t *)shape; | 175 sh_image_t *img = (sh_image_t *)shape; |
177 | 176 |
177 paint_image_set_matrix(sh_get_fill(shape), img->sample_matrix); | |
178 | |
178 mbe_move_to(cr, img->poses[0][0], img->poses[0][1]); | 179 mbe_move_to(cr, img->poses[0][0], img->poses[0][1]); |
179 mbe_line_to(cr, img->poses[1][0], img->poses[1][1]); | 180 mbe_line_to(cr, img->poses[1][0], img->poses[1][1]); |
180 mbe_line_to(cr, img->poses[2][0], img->poses[2][1]); | 181 mbe_line_to(cr, img->poses[2][0], img->poses[2][1]); |
181 mbe_line_to(cr, img->poses[3][0], img->poses[3][1]); | 182 mbe_line_to(cr, img->poses[3][0], img->poses[3][1]); |
182 mbe_close_path(cr); | 183 mbe_close_path(cr); |