private void GetAdditionalData(object o) { BitmapFile file = o as BitmapFile; try { if (!file.FileItem.IsRaw) { using (Bitmap bmp = new Bitmap(file.FileItem.FileName)) { // Luminance ImageStatisticsHSL hslStatistics = new ImageStatisticsHSL(bmp); file.LuminanceHistogramPoints = ConvertToPointCollection(hslStatistics.Luminance.Values); // RGB ImageStatistics rgbStatistics = new ImageStatistics(bmp); file.RedColorHistogramPoints = ConvertToPointCollection(rgbStatistics.Red.Values); file.GreenColorHistogramPoints = ConvertToPointCollection(rgbStatistics.Green.Values); file.BlueColorHistogramPoints = ConvertToPointCollection(rgbStatistics.Blue.Values); } } } catch (Exception ex) { Log.Error(ex); } }
public Settings() { ConfigFile = Path.Combine(DataFolder, "settings.xml"); CameraPresets = new AsyncObservableCollection <CameraPreset>(); DefaultSession = new PhotoSession(); PhotoSessions = new ObservableCollection <PhotoSession>(); SelectedBitmap = new BitmapFile(); ImageLoading = false; CameraProperties = new CameraPropertyEnumerator(); DeviceConfigs = new CustomConfigEnumerator(); ResetSettings(); }
public Settings() { ConfigFile = Path.Combine(DataFolder, "settings.json"); CameraPresets = new AsyncObservableCollection <CameraPreset>(); DefaultSession = new PhotoSession(true, TranslationStrings.MenuSessionName); SelectedSession = new PhotoSession(true, "History"); PhotoSessions = new ObservableCollection <PhotoSession>(); SelectedBitmap = new BitmapFile(); ImageLoading = false; CameraProperties = new CameraPropertyEnumerator(); DeviceConfigs = new CustomConfigEnumerator(); PluginSettings = new ObservableCollection <PluginSetting>(); ResetSettings(); }
public void SetData(BitmapFile file, FileItem fileItem) { if (fileItem == null || fileItem.FileInfo == null) { return; } fileItem.LoadInfo(); file.FileName = Path.GetFileNameWithoutExtension(fileItem.FileName); file.Comment = ""; if (fileItem.FileInfo.ExifTags.ContainName("Iptc.Application2.Caption")) { file.Comment = fileItem.FileInfo.ExifTags["Iptc.Application2.Caption"]; } file.Metadata.Clear(); foreach (ValuePair item in fileItem.FileInfo.ExifTags.Items) { file.Metadata.Add(new DictionaryItem() { Name = item.Name, Value = item.Value }); } file.BlueColorHistogramPoints = ConvertToPointCollection(fileItem.FileInfo.HistogramBlue); file.RedColorHistogramPoints = ConvertToPointCollection(fileItem.FileInfo.HistogramRed); file.GreenColorHistogramPoints = ConvertToPointCollection(fileItem.FileInfo.HistogramGreen); file.LuminanceHistogramPoints = ConvertToPointCollection(fileItem.FileInfo.HistogramLuminance); file.InfoLabel = Path.GetFileName(file.FileItem.FileName); file.InfoLabel += String.Format(" | {0}x{1}", fileItem.FileInfo.Width, fileItem.FileInfo.Height); if (fileItem.FileInfo.ExifTags.ContainName("Exif.Photo.ExposureTime")) { file.InfoLabel += " | E " + fileItem.FileInfo.ExifTags["Exif.Photo.ExposureTime"]; } if (fileItem.FileInfo.ExifTags.ContainName("Exif.Photo.FNumber")) { file.InfoLabel += " | " + fileItem.FileInfo.ExifTags["Exif.Photo.FNumber"]; } if (fileItem.FileInfo.ExifTags.ContainName("Exif.Photo.ISOSpeedRatings")) { file.InfoLabel += " | ISO " + fileItem.FileInfo.ExifTags["Exif.Photo.ISOSpeedRatings"]; } if (fileItem.FileInfo.ExifTags.ContainName("Exif.Photo.ExposureBiasValue")) { file.InfoLabel += " | " + fileItem.FileInfo.ExifTags["Exif.Photo.ExposureBiasValue"]; } if (fileItem.FileInfo.ExifTags.ContainName("Exif.Photo.FocalLength")) { file.InfoLabel += " | " + fileItem.FileInfo.ExifTags["Exif.Photo.FocalLength"]; } }
public static void Highlight(BitmapFile file, bool under, bool over) { if (!under && !over) { return; } if (file == null || file.DisplayImage == null) { return; } var bitmap = Highlight(file.DisplayImage.Clone(), under, over); bitmap.Freeze(); file.DisplayImage = bitmap; }
public unsafe void Highlight(BitmapFile file, bool under, bool over) { if (!under && !over) { return; } if (file == null || file.DisplayImage == null) { return; } WriteableBitmap bitmap = file.DisplayImage.Clone(); int color1 = ConvertColor(Colors.Blue); int color2 = ConvertColor(Colors.Red); int treshold = 2; using (BitmapContext bitmapContext = bitmap.GetBitmapContext()) { for (var i = 0; i < bitmapContext.Width * bitmapContext.Height; i++) { int num1 = bitmapContext.Pixels[i]; byte a = (byte)(num1 >> 24); int num2 = (int)a; if (num2 == 0) { num2 = 1; } int num3 = 65280 / num2; //Color col = Color.FromArgb(a, (byte)((num1 >> 16 & (int)byte.MaxValue) * num3 >> 8), // (byte)((num1 >> 8 & (int)byte.MaxValue) * num3 >> 8), // (byte)((num1 & (int)byte.MaxValue) * num3 >> 8)); byte R = (byte)((num1 >> 16 & byte.MaxValue) * num3 >> 8); byte G = (byte)((num1 >> 8 & byte.MaxValue) * num3 >> 8); byte B = (byte)((num1 & byte.MaxValue) * num3 >> 8); if (under && R < treshold && G < treshold && B < treshold) { bitmapContext.Pixels[i] = color1; } if (over && R > 255 - treshold && G > 255 - treshold && B > 255 - treshold) { bitmapContext.Pixels[i] = color2; } } } bitmap.Freeze(); file.DisplayImage = bitmap; }
public Settings() { ConfigFile = Path.Combine(DataFolder, "settings.xml"); CameraPresets = new AsyncObservableCollection<CameraPreset>(); DefaultSession = new PhotoSession(); PhotoSessions = new ObservableCollection<PhotoSession>(); SelectedBitmap = new BitmapFile(); ImageLoading = false; VideoTypes = new ObservableCollection<VideoType> { new VideoType("HD 1080 16:9", 1920, 1080), new VideoType("UXGA 4:3", 1600, 1200), new VideoType("HD 720 16:9", 1280, 720), new VideoType("Super VGA 4:3", 800, 600), }; CameraProperties = new CameraPropertyEnumerator(); DeviceConfigs = new CustomConfigEnumerator(); ResetSettings(); }
public Settings() { ConfigFile = Path.Combine(DataFolder, "settings.xml"); CameraPresets = new AsyncObservableCollection <CameraPreset>(); DefaultSession = new PhotoSession(); PhotoSessions = new ObservableCollection <PhotoSession>(); SelectedBitmap = new BitmapFile(); ImageLoading = false; VideoTypes = new ObservableCollection <VideoType> { new VideoType("HD 1080 16:9", 1920, 1080), new VideoType("UXGA 4:3", 1600, 1200), new VideoType("HD 720 16:9", 1280, 720), new VideoType("Super VGA 4:3", 800, 600), }; CameraProperties = new CameraPropertyEnumerator(); DeviceConfigs = new CustomConfigEnumerator(); ResetSettings(); }
public void GetMetadata(BitmapFile file, WriteableBitmap writeableBitmap) { Exiv2Helper exiv2Helper = new Exiv2Helper(); try { exiv2Helper.Load(file.FileItem.FileName, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight); file.Metadata.Clear(); foreach (var exiv2Data in exiv2Helper.Tags) { file.Metadata.Add(new DictionaryItem() { Name = exiv2Data.Value.Tag, Value = exiv2Data.Value.Value }); } if (ServiceProvider.Settings.ShowFocusPoints) { writeableBitmap.Lock(); foreach (Rect focuspoint in exiv2Helper.Focuspoints) { DrawRect(writeableBitmap, (int)focuspoint.X, (int)focuspoint.Y, (int)(focuspoint.X + focuspoint.Width), (int)(focuspoint.Y + focuspoint.Height), Colors.Aqua, ServiceProvider.Settings.LowMemoryUsage ? 2 : 7); } writeableBitmap.Unlock(); } if (exiv2Helper.Tags.ContainsKey("Exif.Image.Orientation") && !file.FileItem.IsRaw) { if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "bottom, right") { writeableBitmap = writeableBitmap.Rotate(180); } if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "right, top") { writeableBitmap = writeableBitmap.Rotate(90); } if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "left, bottom") { writeableBitmap = writeableBitmap.Rotate(270); } } if (ServiceProvider.Settings.RotateIndex != 0) { switch (ServiceProvider.Settings.RotateIndex) { case 1: writeableBitmap = writeableBitmap.Rotate(90); break; case 2: writeableBitmap = writeableBitmap.Rotate(180); break; case 3: writeableBitmap = writeableBitmap.Rotate(270); break; } } } catch (Exception exception) { Log.Error("Error loading metadata ", exception); } writeableBitmap.Freeze(); file.DisplayImage = writeableBitmap; file.InfoLabel = Path.GetFileName(file.FileItem.FileName); file.InfoLabel += String.Format(" | {0}x{1}", exiv2Helper.Width, exiv2Helper.Height); if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ExposureTime")) { file.InfoLabel += " | E " + exiv2Helper.Tags["Exif.Photo.ExposureTime"].Value; } if (exiv2Helper.Tags.ContainsKey("Exif.Photo.FNumber")) { file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.FNumber"].Value; } if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ISOSpeedRatings")) { file.InfoLabel += " | ISO " + exiv2Helper.Tags["Exif.Photo.ISOSpeedRatings"].Value; } if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ExposureBiasValue")) { file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.ExposureBiasValue"].Value; } if (exiv2Helper.Tags.ContainsKey("Exif.Photo.FocalLength")) { file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.FocalLength"].Value; } }
public unsafe void Highlight(BitmapFile file, bool under, bool over) { if (!under && !over) return; if (file == null || file.DisplayImage == null) return; WriteableBitmap bitmap = file.DisplayImage.Clone(); int color1 = ConvertColor(Colors.Blue); int color2 = ConvertColor(Colors.Red); int treshold = 2; using (BitmapContext bitmapContext = bitmap.GetBitmapContext()) { for (var i = 0; i < bitmapContext.Width*bitmapContext.Height; i++) { int num1 = bitmapContext.Pixels[i]; byte a = (byte) (num1 >> 24); int num2 = (int) a; if (num2 == 0) num2 = 1; int num3 = 65280/num2; //Color col = Color.FromArgb(a, (byte)((num1 >> 16 & (int)byte.MaxValue) * num3 >> 8), // (byte)((num1 >> 8 & (int)byte.MaxValue) * num3 >> 8), // (byte)((num1 & (int)byte.MaxValue) * num3 >> 8)); byte R = (byte) ((num1 >> 16 & byte.MaxValue)*num3 >> 8); byte G = (byte) ((num1 >> 8 & byte.MaxValue)*num3 >> 8); byte B = (byte) ((num1 & byte.MaxValue)*num3 >> 8); if (under && R < treshold && G < treshold && B < treshold) bitmapContext.Pixels[i] = color1; if (over && R > 255 - treshold && G > 255 - treshold && B > 255 - treshold) bitmapContext.Pixels[i] = color2; } } bitmap.Freeze(); file.DisplayImage = bitmap; }
private void GenerateCache(BitmapFile file, WriteableBitmap writeableBitmap) { //WriteableBitmap bitmap = writeableBitmap.Clone(); //SaveThumb(file.FileItem.SmallThumb, 255, bitmap); //SaveThumb(file.FileItem.LargeThumb, 1920, bitmap); }
public void GetBitmap(BitmapFile bitmapFile) { if (_isworking) { _nextfile = bitmapFile; return; } _nextfile = null; _isworking = true; _currentfile = bitmapFile; _currentfile.RawCodecNeeded = false; if (!File.Exists(_currentfile.FileItem.FileName)) { Log.Error("File not found " + _currentfile.FileItem.FileName); StaticHelper.Instance.SystemMessage = "File not found " + _currentfile.FileItem.FileName; } else { //Metadata.Clear(); try { if (_currentfile.FileItem.IsRaw) { WriteableBitmap writeableBitmap = null; Log.Debug("Loading raw file."); BitmapDecoder bmpDec = BitmapDecoder.Create(new Uri(_currentfile.FileItem.FileName), BitmapCreateOptions.None, BitmapCacheOption.Default); if (bmpDec.CodecInfo != null) { Log.Debug("Raw codec: " + bmpDec.CodecInfo.FriendlyName); } if (bmpDec.Thumbnail != null) { WriteableBitmap bitmap = new WriteableBitmap(bmpDec.Thumbnail); bitmap.Freeze(); bitmapFile.DisplayImage = bitmap; } if (ServiceProvider.Settings.LowMemoryUsage) { if (bmpDec.Thumbnail != null) { writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Thumbnail); } else { writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Frames[0]); double dw = 2000 / writeableBitmap.Width; writeableBitmap = writeableBitmap.Resize((int)(writeableBitmap.PixelWidth * dw), (int)(writeableBitmap.PixelHeight * dw), WriteableBitmapExtensions.Interpolation. Bilinear); } bmpDec = null; } else { writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Frames.Single()); } GetMetadata(_currentfile, writeableBitmap); Log.Debug("Loading raw file done."); } else { BitmapImage bi = new BitmapImage(); // BitmapImage.UriSource must be in a BeginInit/EndInit block. bi.BeginInit(); if (ServiceProvider.Settings.LowMemoryUsage) { bi.DecodePixelWidth = 2000; } bi.UriSource = new Uri(_currentfile.FileItem.FileName); bi.EndInit(); WriteableBitmap writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bi); GetMetadata(_currentfile, writeableBitmap); Log.Debug("Loading bitmap file done."); } } catch (FileFormatException) { _currentfile.RawCodecNeeded = true; Log.Debug("Raw codec not installed or unknown file format"); StaticHelper.Instance.SystemMessage = "Raw codec not installed or unknown file format"; } catch (Exception exception) { Log.Error(exception); } if (_nextfile == null) { Thread threadPhoto = new Thread(GetAdditionalData); threadPhoto.Start(_currentfile); _currentfile.OnBitmapLoaded(); _currentfile = null; _isworking = false; } else { _isworking = false; GetBitmap(_nextfile); } } }
public void SetData(BitmapFile file, FileItem fileItem) { if (fileItem == null || fileItem.FileInfo == null) return; fileItem.LoadInfo(); file.FileName = Path.GetFileNameWithoutExtension(fileItem.FileName); file.Comment = ""; if (fileItem.FileInfo.ExifTags.ContainName("Iptc.Application2.Caption")) file.Comment = fileItem.FileInfo.ExifTags["Iptc.Application2.Caption"]; file.Metadata.Clear(); foreach (ValuePair item in fileItem.FileInfo.ExifTags.Items) { file.Metadata.Add(new DictionaryItem() { Name = item.Name, Value = item.Value }); } file.BlueColorHistogramPoints = ConvertToPointCollection(fileItem.FileInfo.HistogramBlue); file.RedColorHistogramPoints = ConvertToPointCollection(fileItem.FileInfo.HistogramRed); file.GreenColorHistogramPoints = ConvertToPointCollection(fileItem.FileInfo.HistogramGreen); file.LuminanceHistogramPoints = ConvertToPointCollection(fileItem.FileInfo.HistogramLuminance); // file.InfoLabel = Path.GetFileName(file.FileItem.FileName); file.InfoLabel = ""; //file.InfoLabel += String.Format(" | {0}x{1}", fileItem.FileInfo.Width, fileItem.FileInfo.Height); if (fileItem.FileInfo.ExifTags.ContainName("Exif.Photo.ExposureTime")) { file.InfoLabel += "E " + fileItem.FileInfo.ExifTags["Exif.Photo.ExposureTime"]; } if (fileItem.FileInfo.ExifTags.ContainName("Exif.Photo.FNumber")) { file.InfoLabel += " | " + fileItem.FileInfo.ExifTags["Exif.Photo.FNumber"]; } if (fileItem.FileInfo.ExifTags.ContainName("Exif.Photo.ISOSpeedRatings")) { file.InfoLabel += " | ISO " + fileItem.FileInfo.ExifTags["Exif.Photo.ISOSpeedRatings"]; } if (fileItem.FileInfo.ExifTags.ContainName("Exif.Photo.FocalLength")) { file.InfoLabel += " | " + fileItem.FileInfo.ExifTags["Exif.Photo.FocalLength"]; } SetImageInfo(fileItem); }
public static void Highlight(BitmapFile file, bool under, bool over) { if (!under && !over) return ; if (file == null || file.DisplayImage == null) return; var bitmap = Highlight(file.DisplayImage.Clone(), under, over); bitmap.Freeze(); file.DisplayImage = bitmap; }
public Settings() { ConfigFile = Path.Combine(DataFolder, "settings.xml"); CameraPresets = new AsyncObservableCollection<CameraPreset>(); DefaultSession = new PhotoSession(); PhotoSessions = new ObservableCollection<PhotoSession>(); SelectedBitmap = new BitmapFile(); ImageLoading = false; CameraProperties = new CameraPropertyEnumerator(); DeviceConfigs = new CustomConfigEnumerator(); ResetSettings(); }
public void GetBitmap(BitmapFile bitmapFile) { if (_isworking) { _nextfile = bitmapFile; return; } _nextfile = null; _isworking = true; _currentfile = bitmapFile; _currentfile.RawCodecNeeded = false; if (!File.Exists(_currentfile.FileItem.FileName)) { Log.Error("File not found " + _currentfile.FileItem.FileName); StaticHelper.Instance.SystemMessage = "File not found " + _currentfile.FileItem.FileName; } else { //Metadata.Clear(); try { if (_currentfile.FileItem.IsRaw) { WriteableBitmap writeableBitmap = null; Log.Debug("Loading raw file."); BitmapDecoder bmpDec = BitmapDecoder.Create(new Uri(_currentfile.FileItem.FileName), BitmapCreateOptions.None, BitmapCacheOption.Default); if (bmpDec.CodecInfo != null) Log.Debug("Raw codec: " + bmpDec.CodecInfo.FriendlyName); if (bmpDec.Thumbnail != null) { WriteableBitmap bitmap = new WriteableBitmap(bmpDec.Thumbnail); bitmap.Freeze(); bitmapFile.DisplayImage = bitmap; } if (ServiceProvider.Settings.LowMemoryUsage) { if (bmpDec.Thumbnail != null) { writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Thumbnail); } else { writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Frames[0]); double dw = 2000/writeableBitmap.Width; writeableBitmap = writeableBitmap.Resize((int) (writeableBitmap.PixelWidth*dw), (int) (writeableBitmap.PixelHeight*dw), WriteableBitmapExtensions.Interpolation. Bilinear); } bmpDec = null; } else { writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bmpDec.Frames.Single()); } GetMetadata(_currentfile, writeableBitmap); Log.Debug("Loading raw file done."); } else { BitmapImage bi = new BitmapImage(); // BitmapImage.UriSource must be in a BeginInit/EndInit block. bi.BeginInit(); if (ServiceProvider.Settings.LowMemoryUsage) bi.DecodePixelWidth = 2000; bi.UriSource = new Uri(_currentfile.FileItem.FileName); bi.EndInit(); WriteableBitmap writeableBitmap = BitmapFactory.ConvertToPbgra32Format(bi); GetMetadata(_currentfile, writeableBitmap); Log.Debug("Loading bitmap file done."); } } catch (FileFormatException) { _currentfile.RawCodecNeeded = true; Log.Debug("Raw codec not installed or unknown file format"); StaticHelper.Instance.SystemMessage = "Raw codec not installed or unknown file format"; } catch (Exception exception) { Log.Error(exception); } if (_nextfile == null) { Thread threadPhoto = new Thread(GetAdditionalData); threadPhoto.Start(_currentfile); _currentfile.OnBitmapLoaded(); _currentfile = null; _isworking = false; } else { _isworking = false; GetBitmap(_nextfile); } } }
public void GetMetadata(BitmapFile file, WriteableBitmap writeableBitmap) { Exiv2Helper exiv2Helper = new Exiv2Helper(); try { exiv2Helper.Load(file.FileItem.FileName, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight); file.Metadata.Clear(); foreach (var exiv2Data in exiv2Helper.Tags) { file.Metadata.Add(new DictionaryItem() {Name = exiv2Data.Value.Tag, Value = exiv2Data.Value.Value}); } if (ServiceProvider.Settings.ShowFocusPoints) { writeableBitmap.Lock(); foreach (Rect focuspoint in exiv2Helper.Focuspoints) { DrawRect(writeableBitmap, (int) focuspoint.X, (int) focuspoint.Y, (int) (focuspoint.X + focuspoint.Width), (int) (focuspoint.Y + focuspoint.Height), Colors.Aqua, ServiceProvider.Settings.LowMemoryUsage ? 2 : 7); } writeableBitmap.Unlock(); } if (exiv2Helper.Tags.ContainsKey("Exif.Image.Orientation") && !file.FileItem.IsRaw) { if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "bottom, right") writeableBitmap = writeableBitmap.Rotate(180); if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "right, top") writeableBitmap = writeableBitmap.Rotate(90); if (exiv2Helper.Tags["Exif.Image.Orientation"].Value == "left, bottom") writeableBitmap = writeableBitmap.Rotate(270); } if (ServiceProvider.Settings.RotateIndex != 0) { switch (ServiceProvider.Settings.RotateIndex) { case 1: writeableBitmap = writeableBitmap.Rotate(90); break; case 2: writeableBitmap = writeableBitmap.Rotate(180); break; case 3: writeableBitmap = writeableBitmap.Rotate(270); break; } } } catch (Exception exception) { Log.Error("Error loading metadata ", exception); } writeableBitmap.Freeze(); file.DisplayImage = writeableBitmap; file.InfoLabel = Path.GetFileName(file.FileItem.FileName); file.InfoLabel += String.Format(" | {0}x{1}", exiv2Helper.Width, exiv2Helper.Height); if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ExposureTime")) file.InfoLabel += " | E " + exiv2Helper.Tags["Exif.Photo.ExposureTime"].Value; if (exiv2Helper.Tags.ContainsKey("Exif.Photo.FNumber")) file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.FNumber"].Value; if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ISOSpeedRatings")) file.InfoLabel += " | ISO " + exiv2Helper.Tags["Exif.Photo.ISOSpeedRatings"].Value; if (exiv2Helper.Tags.ContainsKey("Exif.Photo.ExposureBiasValue")) file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.ExposureBiasValue"].Value; if (exiv2Helper.Tags.ContainsKey("Exif.Photo.FocalLength")) file.InfoLabel += " | " + exiv2Helper.Tags["Exif.Photo.FocalLength"].Value; }