public void LoadImage(string path, ImageBuffer destImage) { ImageBuffer cachedImage = null; if (!cachedImages.TryGetValue(path, out cachedImage)) { using (var imageStream = OpenSteam(path)) { var bitmap = new Bitmap(imageStream); cachedImage = new ImageBuffer(); ImageIOWindowsPlugin.ConvertBitmapToImage(cachedImage, bitmap); } if (cachedImage.Width < 200 && cachedImage.Height < 200) { // only cache relatively small images cachedImages.Add(path, cachedImage); } } destImage.Allocate(cachedImage.Width, cachedImage.Height, cachedImage.StrideInBytesAbs(), cachedImage.BitDepth); destImage.SetRecieveBlender(cachedImage.GetRecieveBlender()); destImage.CopyFrom(cachedImage); }
public void LoadImage(string path, ImageBuffer destImage) { lock (locker) { ImageBuffer cachedImage = null; if (!cachedImages.TryGetValue(path, out cachedImage)) { using (var imageStream = OpenSteam(path)) { var bitmap = new Bitmap(imageStream); cachedImage = new ImageBuffer(); ImageIOWindowsPlugin.ConvertBitmapToImage(cachedImage, bitmap); } if (cachedImage.Width < 200 && cachedImage.Height < 200) { // only cache relatively small images cachedImages.Add(path, cachedImage); } } destImage.CopyFrom(cachedImage); } }