src/blitter/8bpp_optimized.cpp
branchnoai
changeset 9627 6a7c8ead2328
parent 9626 79f2b5a0cdd7
child 9628 b5c2449616b5
equal deleted inserted replaced
9626:79f2b5a0cdd7 9627:6a7c8ead2328
       
     1 /* $Id$ */
       
     2 
       
     3 /** @file 8bpp_optimized.cpp */
       
     4 
     1 #include "../stdafx.h"
     5 #include "../stdafx.h"
     2 #include "../zoom.hpp"
     6 #include "../zoom.hpp"
     3 #include "../gfx.h"
     7 #include "../gfx.h"
     4 #include "../debug.h"
     8 #include "../debug.h"
     5 #include "8bpp_optimized.hpp"
     9 #include "8bpp_optimized.hpp"
   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;