title: How to blur SDL_Surface without shaders?
body: <p>I want to add blur effect to drawing text. I use <code>SDL2</code> and <code>SDL_TTF</code>.<br>
  <code>SDL_Surface</code> has a transparency.<br>
  <em>How to do it without shaders?</em>
  Below is the algorithm that I use. This is a simple averaging.</p>
  
  <pre><code>    Uint32 p;
      Uint8 r, g, b, a;       
      int x, y, px, py;
      int blur_sum_factor;
      for (y = 0; y &lt; sfc_blur-&gt;h; y++)
      {
          for (x = 0; x &lt; sfc_blur-&gt;w; x++)
          {
              double rd = 0.0, gd = 0.0, bd = 0.0, ad = 0.0;
              blur_sum_factor = 0;
              for (py = -blur_size; py &lt;= blur_size; py++)
              {
                  for (px = -blur_size; px &lt;= blur_size; px++)
                  {
                      int x1 = x + px;
                      int y1 = y + py;
                      if (x1 &lt; 0 || x1 &gt;= sfc_blur-&gt;w || y1 &lt; 0 || y1 &gt;= sfc_blur-&gt;h)
                          continue;
                      p = get_pixel32(sfc_blur, x1, y1);
                      SDL_GetRGBA(p, sfc_blur-&gt;format, &amp;r, &amp;g, &amp;b, &amp;a);
                      rd += r;
                      gd += g;
                      bd += b;
                      blur_sum_factor++;
                      ad += a;
                  }
              }
              rd /= blur_sum_factor;
              gd /= blur_sum_factor;
              bd /= blur_sum_factor;
              ad /= blur_sum_factor;
              r = (Uint8)rd;
              g = (Uint8)gd;
              b = (Uint8)bd;
              a = (Uint8)ad;
              p = SDL_MapRGBA(sfc_blur_target-&gt;format, r, g, b, a);
              put_pixel32(sfc_blur_target, x, y, p);
          }
      }
  </code></pre>
  
  <p>In result I have a dark area around the text.
  <img src="https://i.stack.imgur.com/QZIDy.png" alt="enter image description here"> (red background for better demonstration - the blur is applied only to text with transparency.)</p>
  
  <p>p.s. I had never used shaders. And in this task I can't use shaders (even if I wanted it).</p>