135 uint rx = 0; |
139 uint rx = 0; |
136 src = &sprite->data[ScaleByZoom(y, (ZoomLevel)i) * sprite->width]; |
140 src = &sprite->data[ScaleByZoom(y, (ZoomLevel)i) * sprite->width]; |
137 |
141 |
138 for (int x = 0; x < UnScaleByZoom(sprite->width, (ZoomLevel)i); x++) { |
142 for (int x = 0; x < UnScaleByZoom(sprite->width, (ZoomLevel)i); x++) { |
139 uint color = 0; |
143 uint color = 0; |
140 int count = 0; |
|
141 |
144 |
142 /* Get the color keeping in mind the zoom-level */ |
145 /* Get the color keeping in mind the zoom-level */ |
143 for (int j = 0; j < ScaleByZoom(1, (ZoomLevel)i); j++) { |
146 for (int j = 0; j < ScaleByZoom(1, (ZoomLevel)i); j++) { |
144 if (src->m != 0) { color = src->m; count++; } |
147 if (src->m != 0) color = src->m; |
145 src++; |
148 src++; |
146 rx++; |
149 rx++; |
147 /* Because of the scaling it might happen we read outside the buffer. Avoid that. */ |
150 /* Because of the scaling it might happen we read outside the buffer. Avoid that. */ |
148 if (rx == sprite->width) break; |
151 if (rx == sprite->width) break; |
149 } |
152 } |
150 /* If more than 12.5% of the pixels are non-transparent, make thisone non-transparent too */ |
|
151 if (count < ScaleByZoom(1, (ZoomLevel)i) / 8) color = 0; |
|
152 |
153 |
153 if (last_color == 0 || color == 0) { |
154 if (last_color == 0 || color == 0) { |
154 if (count_index != 0) { |
155 if (count_index != 0) { |
155 /* Write how many non-transparent bytes we get */ |
156 /* Write how many non-transparent bytes we get */ |
156 temp_dst[count_index] = pixels; |
157 temp_dst[count_index] = pixels; |