当前位置: 首页>>代码示例>>C#>>正文


C# FileItem.SaveInfo方法代码示例

本文整理汇总了C#中CameraControl.Core.Classes.FileItem.SaveInfo方法的典型用法代码示例。如果您正苦于以下问题:C# FileItem.SaveInfo方法的具体用法?C# FileItem.SaveInfo怎么用?C# FileItem.SaveInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CameraControl.Core.Classes.FileItem的用法示例。


在下文中一共展示了FileItem.SaveInfo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateCache


//.........这里部分代码省略.........
                        PhotoUtils.RunAndWait(dcraw_exe, string.Format(" -e \"{0}\"", fileItem.FileName));
                        string thumb = Path.Combine(Path.GetDirectoryName(fileItem.FileName),
                            Path.GetFileNameWithoutExtension(fileItem.FileName) + ".thumb.jpg");
                        if (File.Exists(thumb))
                        {
                            deleteFile = true;
                            filename = thumb;
                        }
                    }
                }
                catch (Exception exception)
                {
                    Log.Error("Error get dcraw thumb", exception);
                }
            }

            GetMetadata(fileItem);
            try
            {
                var rotation = 0;

                if (fileItem.FileInfo.ExifTags.ContainName("Exif.Image.Orientation"))
                {
                    if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "bottom, right")
                        rotation = 180;

                    //if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "top, left")
                    //    writeableBitmap = writeableBitmap.Rotate(180);

                    if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "right, top")
                        rotation = 90;

                    if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "left, bottom")
                        rotation = 270;
                }

                using (MemoryStream fileStream = new MemoryStream(File.ReadAllBytes(filename)))
                {
                    BitmapDecoder bmpDec = BitmapDecoder.Create(fileStream,
                                                                BitmapCreateOptions.PreservePixelFormat,
                                                                BitmapCacheOption.OnLoad);

                    bmpDec.DownloadProgress += (o, args) => StaticHelper.Instance.LoadingProgress = args.Progress;

                    if (rotation == 90 || rotation == 270)
                        fileItem.FileInfo.SetSize(bmpDec.Frames[0].PixelHeight, bmpDec.Frames[0].PixelWidth);
                    else
                        fileItem.FileInfo.SetSize(bmpDec.Frames[0].PixelWidth, bmpDec.Frames[0].PixelHeight);

                    double dw = (double)LargeThumbSize / bmpDec.Frames[0].PixelWidth;
                    WriteableBitmap writeableBitmap =
                        BitmapFactory.ConvertToPbgra32Format(GetBitmapFrame(bmpDec.Frames[0],
                                                                            (int)(bmpDec.Frames[0].PixelWidth * dw),
                                                                            (int)(bmpDec.Frames[0].PixelHeight * dw),
                                                                            BitmapScalingMode.Linear));

                    LoadHistogram(fileItem, writeableBitmap);
                    Save2Jpg(writeableBitmap, fileItem.LargeThumb);

                    dw = (double)SmallThumbSize / writeableBitmap.PixelWidth;
                    writeableBitmap = writeableBitmap.Resize((int)(writeableBitmap.PixelWidth * dw),
                                                             (int)(writeableBitmap.PixelHeight * dw),
                                                             WriteableBitmapExtensions.Interpolation.Bilinear);

                    if (rotation > 0)
                        writeableBitmap = writeableBitmap.Rotate(rotation);

                    Save2Jpg(writeableBitmap, fileItem.SmallThumb);
                    //var thumb = LoadSmallImage(fileItem);
                    //thumb.Freeze();
                    fileItem.Thumbnail = LoadImage(fileItem.SmallThumb);
                }

                //using (MagickImage image = new MagickImage(filename))
                //{
                //    if (rotation == 90 || rotation == 270)
                //        fileItem.FileInfo.SetSize(image.Height, image.Width);
                //    else
                //        fileItem.FileInfo.SetSize(image.Width, image.Height);

                //    double dw = (double)LargeThumbSize / image.Width;
                //    image.Thumbnail(dw*100);
                //    LoadHistogram(fileItem, image);
                //    image.Write(fileItem.LargeThumb);
                //    dw = (double)LargeThumbSize / image.Width;
                //    image.Thumbnail(dw * 100);
                //    image.Write(fileItem.SmallThumb);
                //    fileItem.Thumbnail = LoadImage(fileItem.SmallThumb);
                //}

                fileItem.IsLoaded = true;
                fileItem.SaveInfo();
                if (deleteFile)
                    File.Delete(filename);
            }
            catch (Exception exception)
            {
                Log.Error("Error generating cache " + fileItem.FileName, exception);
            }
        }
开发者ID:btugade,项目名称:digiCamControl,代码行数:101,代码来源:BitmapLoader.cs

示例2: GenerateCache

        public void GenerateCache(FileItem fileItem)
        {
            bool deleteFile = false;
            if (fileItem == null)
                return;
            if (!File.Exists(fileItem.FileName))
                return;

            if ((File.Exists(fileItem.LargeThumb) && File.Exists(fileItem.SmallThumb)) && File.Exists(fileItem.InfoFile))
                return;

            if (fileItem.Loading)
                return;

            fileItem.Loading = true;

            PhotoUtils.WaitForFile(fileItem.FileName);
            string filename = fileItem.FileName;
            if (fileItem.IsMovie)
            {
                try
                {
                    string ffmpeg_exe = Path.Combine(Settings.ApplicationFolder, "ffmpeg.exe");
                    if (File.Exists(ffmpeg_exe))
                    {
                        string thumb = Path.Combine(Path.GetDirectoryName(fileItem.FileName),
                            Path.GetFileNameWithoutExtension(fileItem.FileName) + ".thumb.jpg");
                        PhotoUtils.RunAndWait(ffmpeg_exe, String.Format("-i \"{0}\" -ss 00:00:01.000 -f image2 -vframes 1 \"{1}\"", fileItem.FileName, thumb));
                        if (File.Exists(thumb))
                        {
                            deleteFile = true;
                            filename = thumb;
                        }
                    }
                }
                catch (Exception exception)
                {
                    Log.Error("Error get video thumb", exception);
                }
            }
            if (fileItem.IsRaw)
            {
                try
                {
                    string dcraw_exe = Path.Combine(Settings.ApplicationFolder, "dcraw.exe");
                    if (File.Exists(dcraw_exe))
                    {
                        string thumb = Path.Combine(Path.GetTempPath(),
                            Path.GetFileNameWithoutExtension(fileItem.FileName) + ".thumb.jpg");
                        PhotoUtils.RunAndWait(dcraw_exe,
                            string.Format(" -e -O \"{0}\" \"{1}\"", thumb, fileItem.FileName));
                        if (File.Exists(thumb))
                        {
                            deleteFile = true;
                            filename = thumb;
                        }
                    }
                }
                catch (Exception exception)
                {
                    Log.Error("Error get dcraw thumb", exception);
                }
            }

            GetMetadata(fileItem);
            try
            {
                using (MagickImage image = new MagickImage(filename))
                {
                    fileItem.FileInfo.SetSize(image.Width, image.Height);

                    double dw = (double)LargeThumbSize / image.Width;
                    image.FilterType = FilterType.Box;
                    image.Thumbnail((int)(image.Width * dw), (int)(image.Height * dw));

                    if (!ServiceProvider.Settings.DisableHardwareAccelerationNew)
                        image.UnsharpMask(1, 1, 0.5, 0.1);

                    PhotoUtils.CreateFolder(fileItem.LargeThumb);
                    image.Write(fileItem.LargeThumb);
                    fileItem.IsLoaded = true;
                    fileItem.Loading = false;

                    dw = (double)SmallThumbSize / image.Width;
                    image.Thumbnail((int)(image.Width * dw), (int)(image.Height * dw));

                    if (!ServiceProvider.Settings.DisableHardwareAccelerationNew)
                        image.UnsharpMask(1, 1, 0.5, 0.1);

                    PhotoUtils.CreateFolder(fileItem.SmallThumb);
                    image.Write(fileItem.SmallThumb);

                    fileItem.Thumbnail = LoadImage(fileItem.SmallThumb);
                }
                fileItem.SaveInfo();
                SetImageInfo(fileItem);
                if (deleteFile)
                    File.Delete(filename);
                OnMetaDataUpdated(fileItem);
            }
//.........这里部分代码省略.........
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:101,代码来源:BitmapLoader.cs

示例3: GenerateCache

        public void GenerateCache(FileItem fileItem)
        {
            bool deleteFile = false;
            if (fileItem == null)
                return;
            if (!File.Exists(fileItem.FileName))
                return;
            
            if ((File.Exists(fileItem.LargeThumb) && File.Exists(fileItem.SmallThumb)) && File.Exists(fileItem.InfoFile))
                return;

            string filename = fileItem.FileName;
            if (fileItem.IsRaw)
            {
                string s = Path.Combine(Path.GetDirectoryName(fileItem.FileName),
                                        Path.GetFileNameWithoutExtension(fileItem.FileName) + ".jpg");
                if (File.Exists(s))
                {
                    filename = s;
                }
                else
                {
                    try
                    {
                        string dcraw_exe = Path.Combine(Settings.ApplicationFolder, "dcraw.exe");
                        if (File.Exists(dcraw_exe))
                        {
                            PhotoUtils.RunAndWait(dcraw_exe, string.Format(" -e {0}", fileItem.FileName));
                            string thumb = Path.Combine(Path.GetDirectoryName(fileItem.FileName),
                                        Path.GetFileNameWithoutExtension(fileItem.FileName) + ".thumb.jpg");
                            if (File.Exists(thumb))
                            {
                                deleteFile = true;
                                filename = thumb;
                            }
                        }
                    }
                    catch (Exception exception)
                    {
                        Log.Error("Error get dcraw thumb", exception);
                    }
                }
            }

            GetMetadata(fileItem);
            try
            {
                using (MemoryStream fileStream = new MemoryStream(File.ReadAllBytes(filename)))
                {
                    BitmapDecoder bmpDec = BitmapDecoder.Create(fileStream,
                                                                BitmapCreateOptions.PreservePixelFormat,
                                                                BitmapCacheOption.OnLoad);

                    bmpDec.DownloadProgress += (o, args) => StaticHelper.Instance.LoadingProgress = args.Progress;

                    fileItem.FileInfo.Width = bmpDec.Frames[0].PixelWidth;
                    fileItem.FileInfo.Height = bmpDec.Frames[0].PixelHeight;

                    double dw = (double) LargeThumbSize/bmpDec.Frames[0].PixelWidth;
                    WriteableBitmap writeableBitmap =
                        BitmapFactory.ConvertToPbgra32Format(GetBitmapFrame(bmpDec.Frames[0],
                                                                            (int) (bmpDec.Frames[0].PixelWidth*dw),
                                                                            (int) (bmpDec.Frames[0].PixelHeight*dw),
                                                                            BitmapScalingMode.Linear));

                    LoadHistogram(fileItem, writeableBitmap);
                    Save2Jpg(writeableBitmap, fileItem.LargeThumb);

                    dw = (double) SmallThumbSize/writeableBitmap.PixelWidth;
                    writeableBitmap = writeableBitmap.Resize((int) (writeableBitmap.PixelWidth*dw),
                                                             (int) (writeableBitmap.PixelHeight*dw),
                                                             WriteableBitmapExtensions.Interpolation.Bilinear);

                    if (fileItem.FileInfo.ExifTags.ContainName("Exif.Image.Orientation") )
                    {
                        if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "bottom, right")
                            writeableBitmap = writeableBitmap.Rotate(180);

                        //if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "top, left")
                        //    writeableBitmap = writeableBitmap.Rotate(180);

                        if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "right, top")
                            writeableBitmap = writeableBitmap.Rotate(90);

                        if (fileItem.FileInfo.ExifTags["Exif.Image.Orientation"] == "left, bottom")
                            writeableBitmap = writeableBitmap.Rotate(270);
                    }

                    Save2Jpg(writeableBitmap, fileItem.SmallThumb);
                    fileItem.Thumbnail = LoadSmallImage(fileItem);
                    fileItem.IsLoaded = true;
                    fileItem.SaveInfo();
                    if (deleteFile)
                        File.Delete(filename);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Error generating cache", exception);
            }
//.........这里部分代码省略.........
开发者ID:tomriddle1234,项目名称:digiCamControl,代码行数:101,代码来源:BitmapLoader.cs

示例4: LoadHistogram

        public void LoadHistogram(FileItem item)
        {
            try
            {
                var fileInfo = item.FileInfo;
                if (fileInfo!=null)
                {
                    if (fileInfo.IsLoading)
                        return;
                    fileInfo.IsLoading = true;
                }
                if (fileInfo == null || fileInfo.ExifTags == null || fileInfo.ExifTags.Items.Count == 0)
                {
                    GetMetadata(item);
                    fileInfo = item.FileInfo;
                    fileInfo.IsLoading = true;
                }
                if (!File.Exists(item.SmallThumb))
                {
                    fileInfo.IsLoading = false;
                    return;
                }

                using (MagickImage image = new MagickImage(item.SmallThumb))
                {
                    var Blue = new int[256];
                    var Green = new int[256];
                    var Red = new int[256];
                    var Luminance = new int[256];
                    Dictionary<MagickColor, int> h = image.Histogram();
                    foreach (var i in h)
                    {
                        byte R = i.Key.R;
                        byte G = i.Key.G;
                        byte B = i.Key.B;
                        Blue[B] += i.Value;
                        Green[G] += i.Value;
                        Red[R] += i.Value;
                        int lum = (R + R + R + B + G + G + G + G) >> 3;
                        Luminance[lum] += i.Value;
                    }
                    fileInfo.HistogramBlue = Blue;
                    fileInfo.HistogramGreen = Green;
                    fileInfo.HistogramRed = Red;
                    fileInfo.HistogramLuminance = Luminance;
                    fileInfo.IsLoading = false;
                    item.FileInfo = fileInfo;
                }
                item.SaveInfo();
                if (ServiceProvider.Settings.SelectedBitmap.FileItem == item)
                {
                    SetData(ServiceProvider.Settings.SelectedBitmap,
                                 ServiceProvider.Settings.SelectedBitmap.FileItem);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Unable to load histogram", ex);
            }

            //item.FileInfo.HistogramBlue = SmoothHistogram(item.FileInfo.HistogramBlue);
            //item.FileInfo.HistogramGreen = SmoothHistogram(item.FileInfo.HistogramGreen);
            //item.FileInfo.HistogramRed = SmoothHistogram(item.FileInfo.HistogramRed);
            //item.FileInfo.HistogramLuminance = SmoothHistogram(item.FileInfo.HistogramLuminance);
        }
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:65,代码来源:BitmapLoader.cs


注:本文中的CameraControl.Core.Classes.FileItem.SaveInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。