title: c# Out of Memory Exception with System.Drawing.Image
body: <p>I wanna create a pdf with 2 images. One of the image is a text and the other is a watermark to draw on top of the first one. Well when I load the first image everything is ok but then I try to load the watermark image and get the "Out of Memory" exception. I've got memory (printed the memory usage was like 20MB) and can open the image in my computer (I'm using one I took from google just to test until I don't get the real one).</p>
  
  <p><a href="https://i.stack.imgur.com/bNK2f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bNK2f.png" alt="Image I&#39;m using to test this feature"></a></p>
  
  <p>The code where I get the exception is this one:</p>
  
  <pre><code>      using (System.Drawing.Image imgOriginal = System.Drawing.Image.FromFile(sOriginalPath, true))
        {
          using (System.Drawing.Image imgLogo = System.Drawing.Image.FromFile(sLogoPath, true)) //This is where it throws the exception
          {
            using (Graphics gra = Graphics.FromImage(imgOriginal))
            {
              Bitmap bmLogo = new Bitmap(imgLogo);
              int nWidth = bmLogo.Size.Width;
              int nHeight = bmLogo.Size.Height;
              int nLeft = (imgOriginal.Width / 2) - (nWidth / 2);
              int nTop = (imgOriginal.Height / 2) - (nHeight / 2);
              gra.DrawImage(bmLogo, nLeft, nTop, nWidth, nHeight);
            }
            return imgOriginal;
          }
        }
  </code></pre>
  
  <p>I've seen the other questions like mine but:</p>
  
  <ul>
  <li>It doesn't seem memory problem</li>
  <li>It doesn't seem image problem</li>
  </ul>
  
  <p>Can you help me? Thanks :)</p>