12 #include "../stdafx.h" 
   13 #include "../zoom_func.h" 
   14 #include "../settings_type.h" 
   17 #include "../safeguards.h" 
   29 template <BlitterMode mode>
 
   40   const uint16 *src_n  = (
const uint16 *)(src->
data + src->
offset[zoom][1]);
 
   43   for (uint i = bp->
skip_top; i != 0; i--) {
 
   44     src_px = (
const Colour *)((
const byte *)src_px + *(
const uint32 *)src_px);
 
   45     src_n = (
const uint16 *)((
const byte *)src_n + *(
const uint32 *)src_n);
 
   52   const byte *remap = bp->
remap;
 
   54   for (
int y = 0; y < bp->
height; y++) {
 
   59     const Colour *src_px_ln = (
const Colour *)((
const byte *)src_px + *(
const uint32 *)src_px);
 
   63     const uint16 *src_n_ln = (
const uint16 *)((
const byte *)src_n + *(
const uint32 *)src_n);
 
   72     while (dst < dst_end) {
 
   80         if (dst + n > dst_end) {
 
   81           uint d = dst_end - dst;
 
   86           dst_end = dst + bp->
width;
 
   88           n = min<uint>(n - d, (uint)bp->
width);
 
  100     dst_end += bp->
width;
 
  102     while (dst < dst_end) {
 
  103       n = min<uint>(*src_n++, (uint)(dst_end - dst));
 
  105       if (src_px->a == 0) {
 
  116           if (src_px->a == 255) {
 
  123                 uint r = remap[
GB(m, 0, 8)];
 
  136                 uint r = remap[
GB(m, 0, 8)];
 
  147           if (src_px->a == 255) {
 
  151                 uint8 g = 
MakeDark(src_px->r, src_px->g, src_px->b);
 
  154                 uint r = remap[
GB(m, 0, 8)];
 
  165                 if (src_px->a != 0) {
 
  166                   uint8 g = 
MakeDark(src_px->r, src_px->g, src_px->b);
 
  170                 uint r = remap[
GB(m, 0, 8)];
 
  196           if (src_px->a == 255) {
 
  212           if (src_px->a == 255) {
 
  248     default: NOT_REACHED();
 
  249     case BM_NORMAL:       Draw<BM_NORMAL>      (bp, zoom); 
return;
 
  287   for (
ZoomLevel z = zoom_min; z <= zoom_max; z++) {
 
  292     dst_px_orig[z] = CallocT<Colour>(size + src_orig->
height * 2);
 
  293     dst_n_orig[z]  = CallocT<uint16>(size * 2 + src_orig->
height * 4 * 2);
 
  295     uint32 *dst_px_ln = (uint32 *)dst_px_orig[z];
 
  296     uint32 *dst_n_ln  = (uint32 *)dst_n_orig[z];
 
  300     for (uint y = src_orig->
height; y > 0; y--) {
 
  302       uint16 *dst_n = (uint16 *)(dst_n_ln + 1);
 
  304       uint16 *dst_len = dst_n++;
 
  309       for (uint x = src_orig->
width; x > 0; x--) {
 
  311         uint t = a > 0 && a < 255 ? 1 : a;
 
  313         if (last != t || len == 65535) {
 
  329             uint8 rgb_max = 
max(src->
r, 
max(src->
g, src->
b));
 
  332             if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
 
  333             *dst_n |= rgb_max << 8;
 
  337             dst_px->r = colour.r;
 
  338             dst_px->g = colour.g;
 
  339             dst_px->b = colour.b;
 
  347         } 
else if (len == 1) {
 
  361       dst_n  = (uint16 *)
AlignPtr(dst_n, 4);
 
  363       *dst_px_ln = (uint8 *)dst_px - (uint8 *)dst_px_ln;
 
  364       *dst_n_ln  = (uint8 *)dst_n  - (uint8 *)dst_n_ln;
 
  366       dst_px_ln = (uint32 *)dst_px;
 
  367       dst_n_ln =  (uint32 *)dst_n;
 
  370     lengths[z][0] = (byte *)dst_px_ln - (byte *)dst_px_orig[z]; 
 
  371     lengths[z][1] = (byte *)dst_n_ln  - (byte *)dst_n_orig[z];
 
  375   for (
ZoomLevel z = zoom_min; z <= zoom_max; z++) {
 
  376     len += lengths[z][0] + lengths[z][1];
 
  387   memset(dst, 0, 
sizeof(*dst));
 
  389   for (
ZoomLevel z = zoom_min; z <= zoom_max; z++) {
 
  390     dst->
offset[z][0] = z == zoom_min ? 0 : lengths[z - 1][1] + dst->
offset[z - 1][1];
 
  393     memcpy(dst->
data + dst->
offset[z][0], dst_px_orig[z], lengths[z][0]);
 
  394     memcpy(dst->
data + dst->
offset[z][1], dst_n_orig[z],  lengths[z][1]);
 
  396     free(dst_px_orig[z]);