title: How to get the best performance when getting the color of 1 specific pixel, for 35 images?
body: <p>So here's the deal: I have an ASP.Net API set up on Azure that consists of 2 parts: <strong>a scheduled job that fetches 35 images (Width: 2000px, Height: 1450px)</strong> from an external website and saves it to my server.
  The second part is an GET API that has an X and Y value as parameter. Now the thing that I want to do is the following:
  When the user enters the X - Y, I want the API to go through all 35 images and get the color of that specific point.</p>
  
  <p>I currently have this:</p>
  
  <pre><code>string Data = "";
  
  
  foreach (string FilePath in   Directory.GetFiles(HttpContext.Current.Server.MapPath("~/Content/Images/")))
  { 
       Bitmap ImageHolder = new Bitmap(FilePath);
       Color color = ImageHolder.GetPixel(PixelX, PixelY);
  
       string ColorString = color.R.ToString() + " " + color.G.ToString() + " " + color.B.ToString();
       string Time = Path.GetFileNameWithoutExtension(FilePath);
  
       Data = Data + Time + "|" + ColorString + " ";
  }
  return Data;
  </code></pre>
  
  <p>Response:</p>
  
  <blockquote>
    <p>1015|0 0 0 1020|0 0 0 1025|0 0 0 1030|0 0 0 1035|0 0 0 1040|0 0 0 1045|0 0 0 1050|0 0 0 1055|0 0 0 1100|0 0 0 1105|0 0 0 1110|0 0 0 1115|0 0 0 1120|0 0 0 1125|0 0 0 1130|0 0 0 1135|0 0 0 1140|0 0 0 1145|0 0 0 1150|0 0 0 1155|0 0 0 1200|0 0 0 1205|0 0 0 1210|0 0 0 1215|0 0 0 1220|0 0 0 1225|0 0 0 1230|0 0 0 1235|0 0 0 1240|0 0 0 1245|0 0 0 1250|0 0 0 </p>
  </blockquote>
  
  <p>Now, this all works. But, when I host this and use it as an API, the response time <strong>is sometimes over 6000 miliseconds.</strong> </p>
  
  <p>By using the StopWatch, I see that the all the code runs fine, <strong>but that it sometimes takes up to 500 miliseconds when the code runs:</strong></p>
  
  <pre><code>Bitmap ImageHolder = new Bitmap(FilePath);
  </code></pre>
  
  <p>Any ideas on how to decrease the response time and speeding the process up? Pre-calculating everything in the scheduled crone-job seems to be an effort as the images are quite big, and when storing them we would talk about a lot of points.</p>