title: AndEngine Merging Sprites
body: <p>I have been tackling a severe performance issue with an AndEngine powered live wallpaper for a while now (I've posted another question about it a while back, before I knew what was causing it at all), and it seems that the only way to get this to work properly is to merge a few sprites together.</p>
  
  <p>I have a half dozen or so fairly large sprites, all the same size, that get layered directly on top of each other.  I do it this way so it all looks like one image, but each part of it can be set to a different color via code whenever I'd like.  For some reason or other, layering sprites when using a blending mode that utilizes alpha at all (Even if there wasn't any alpha in the images) does some major damage to your frame rate, and I can't find any simple way around this.</p>
  
  <p>The solution I've arrived at is that I will need to do what I need to with the sprites individually, and then merge them together into one.  I've spent quite a few hours diving into various classes of AndEngine, trying not to destroy anything in the process, but I just cannot figure out how to do it.</p>
  
  <p>I'm certain that it cannot be <strong>that</strong> difficult to slap one sprite onto another, or putting the re-worked sprites back into a temporary texture atlas somehow, I just can't quite grasp how to get it going.</p>
  
  <p><strong>EDIT ::</strong> </p>
  
  <pre><code>    public void onLoadResources(){
      this.mTestAtlas = new BitmapTextureAtlas(512, 1024, TextureOptions.NEAREST_PREMULTIPLYALPHA);
  
      Bitmap b = BitmapFactory.decodeStream(layer1);
      Bitmap a =  overlay(b);
      test = new BitmapTextureAtlasSource(a);
  
      this.mTesting = BitmapTextureAtlasTextureRegionFactory.createFromSource(this.mTestAtlas, test, 0, 0);
  
      this.getEngine().getTextureManager().loadTexture(this.mTestAtlas);      
  }   
  
  public Scene onLoadScene(){
      layer1Sprite = new Sprite(x, y, width, height, this.mTesting);
      scene.attachChild(layer1Sprite);
  }
  
  public static Bitmap overlay(Bitmap bmp1) {
      Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
      Canvas canvas = new Canvas(bmOverlay);
  
      Paint layer1Paint = new Paint();
      ColorFilter layer1Filter;
      layer1Filter = new LightingColorFilter(Color.rgb(175, 0, 175), 1);
      layer1Paint.setColorFilter(layer1Filter);
      canvas.drawBitmap(bmp4, 0, 0, layer1Paint);
  
     return bmOverlay;
  
  }
  </code></pre>