title: How can I merge bitmap (Alpha Bitmap and Main Bitmap) in C#?
body: <pre><code>        ```
  if (alpha != null &amp;&amp; input != null)
          {
  
              Bitmap output = new Bitmap(input.Width, input.Height, PixelFormat.Format32bppArgb);
              var rect = new Rectangle(0, 0, input.Width, input.Height);
              var bitsAlpha = alpha.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
              var bitsInput = input.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
              var bitsOutput = output.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
              unsafe
              {
                  for (int y = 0; y &lt; input.Height; y++)
                  {
                      byte* ptrAlpha = (byte*)bitsAlpha.Scan0 + y * bitsAlpha.Stride;
                      byte* ptrInput = (byte*)bitsInput.Scan0 + y * bitsInput.Stride;
                      byte* ptrOutput = (byte*)bitsOutput.Scan0 + y * bitsOutput.Stride;
                      for (int x = 0; x &lt; input.Width; x++)
                      {
                          ptrOutput[4 * x] = ptrInput[4 * x];           // blue
                          ptrOutput[4 * x + 1] = ptrInput[4 * x + 1];   // green
                          ptrOutput[4 * x + 2] = ptrInput[4 * x + 2];   // red
                          ptrOutput[4 * x + 3] = ptrAlpha[4 * x];        // alpha
                      }
                  }
              }
              alpha.UnlockBits(bitsAlpha);
              input.UnlockBits(bitsInput);
              output.UnlockBits(bitsOutput);
  
  
              return output;
          }
  ```
  </code></pre>
  <p>I changed the PixelFormat to Format8bppIndexed.I set the pixel format to Format8bppIndexed and came to this conclusion <a href="https://i.stack.imgur.com/XdsmL.png" rel="nofollow noreferrer">image</a> . Please help me</p>