public void UpdateImage(CoreImageInfo currentImageInfo) { if (m_originalBitmap != null) { m_originalBitmap.Dispose(); m_originalBitmap = null; } m_currentImageInfo = currentImageInfo; if (currentImageInfo != null) { StopAnimate(); if (m_currentImageInfo.type != CoreDll.ImageType.None) { if (m_currentImageInfo.path.Length < MAX_PATH && m_currentImageInfo.type <= CoreDll.ImageType.Icon) { try { if (LoadFileToMemoryStream(ref m_memoryStream, m_currentImageInfo.path)) { m_bitmap = new Bitmap(m_memoryStream); m_animationEnable = ImageAnimator.CanAnimate(m_bitmap); if (m_animationEnable) { m_currentlyAnimating = false; } } else { m_bitmap = null; } } catch { m_bitmap = m_core.LoadBitmap(m_currentImageInfo); } } else { m_bitmap = m_core.LoadBitmap(m_currentImageInfo); } } else { m_bitmap = null; } if (m_options.resultsOptions.ShowNeighboursImages) { ShowNeighboursImages(true); } } }
/// <summary> /// Загружаем в хранилише уменьшенное изображение по переданному пути. /// </summary> /// <param name="imageInfo"></param> /// <returns></returns> public Bitmap Get(CoreImageInfo imageInfo) { Bitmap bitmap = null; Size size = GetThumbnailSize(imageInfo); m_mutex.WaitOne(); m_storage.TryGetValue(imageInfo.id, out bitmap); if (bitmap == null || bitmap.Height != size.Height || bitmap.Width != size.Width) { m_mutex.ReleaseMutex(); // поток может работать дальше bitmap = m_core.LoadBitmap(size, imageInfo.path); m_mutex.WaitOne(); m_storage[imageInfo.id] = bitmap; } m_mutex.ReleaseMutex(); return(bitmap); }