Ejemplo n.º 1
0
        private void deletePlugin(int numberInList)
        {
            DialogResult window = DialogMan.ShowConfirm(
                this,
                LangMan.Get("delete-plugin-warning"),
                windowTitle: LangMan.Get("warning"),
                yesBtnText: LangMan.Get("delete-plugin"),
                yesBtnImage: deleteBtn.Image,
                darkMode: DarkMode,
                topMost: TopMost
                );

            if (window == DialogResult.Yes)
            {
                listView1.Items[numberInList].Remove();
                imageList1.Images[numberInList].Dispose();

                string pluginFolder = Path.Combine(PluginMan.pluginsFolder, codenames[numberInList]);
                if (File.Exists(pluginFolder))
                {
                    FileMan.MoveFileOrFolderToRecycleBin(pluginFolder);
                }
                else
                {
                    DialogMan.ShowInfo(
                        this,
                        LangMan.Get("plugin-not-found"),
                        LangMan.Get("error"),
                        DarkMode,
                        TopMost
                        );
                }
                RefreshPluginsList();
            }
        }
        private void setZoomFactor(int newZoomFactor)
        {
            if (newZoomFactor < 1)
            {
                newZoomFactor = 1;
            }
            if (newZoomFactor > 250)
            {
                newZoomFactor = 250;
            }

            if (newZoomFactor != zoomFactor)
            {
                zoomFactor = newZoomFactor;

                zoomLabel.Text = LangMan.Get("zoom") + ": " + zoomFactor.ToString() + "%";

                setAutoZoom(false);

                int newWidth  = Convert.ToInt32(width * zoomFactor / 100);
                int newHeight = Convert.ToInt32(height * zoomFactor / 100);

                pictureBox.Size = new Size(newWidth, newHeight);

                updatePictureBoxLocation();
            }
        }
Ejemplo n.º 3
0
        public SelectionForm(Panel srcPanel, bool darkMode)
        {
            picturePanel = srcPanel;

            MinimumSize = new Size(gripSize * 4, gripSize * 4);

            whitePen.DashStyle  = DashStyle.Dot;
            blackPen.DashStyle  = DashStyle.Dot;
            blackPen.DashOffset = 1;

            InitializeComponent();

            gripBrush = new SolidBrush(darkMode ? ThemeMan.DarkPaleColor : ThemeMan.LightPaleColor);
            selectionMenu.DarkMode = darkMode;

            cutBtn.Text                = LangMan.Get("cut");
            cropBtn.Text               = LangMan.Get("crop");
            selectionCopyBtn.Text      = LangMan.Get("copy");
            selectionSelectAllBtn.Text = LangMan.Get("select-all");
            editSelectionBtn.Text      = LangMan.Get("edit-selection") + " ...";

            if (darkMode)
            {
                cutBtn.Image                = Properties.Resources.white_cut;
                cropBtn.Image               = Properties.Resources.white_crop;
                selectionCopyBtn.Image      = Properties.Resources.white_copy;
                selectionSelectAllBtn.Image = Properties.Resources.white_selectall;
                editSelectionBtn.Image      = Properties.Resources.white_editsel;
            }
        }
Ejemplo n.º 4
0
        public override FileTypeMan.OpenResult Open(string path)
        {
            try
            {
                CPSD psd     = new CPSD();
                int  nResult = psd.Load(path);
                switch (nResult)
                {
                case -1:
                    return(new FileTypeMan.OpenResult
                    {
                        ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                    });

                default:
                    return(new FileTypeMan.OpenResult
                    {
                        Bmp = Image.FromHbitmap(psd.GetHBitmap())
                    });
                }
            }
            catch
            {
                return(new FileTypeMan.OpenResult
                {
                    ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                });
            }
        }
Ejemplo n.º 5
0
        private void deletePlugin(int numberInList)
        {
            DialogResult window = DialogMan.ShowConfirm(
                this,
                LangMan.Get("delete-plugin-warning"),
                windowTitle: LangMan.Get("warning"),
                yesBtnText: LangMan.Get("delete-plugin"),
                yesBtnImage: deleteBtn.Image,
                darkMode: DarkMode
                );

            if (window == DialogResult.Yes)
            {
                listView1.Items[numberInList].Remove();
                imageList1.Images[numberInList].Dispose();

                string pluginFolder = Path.Combine(PluginMan.pluginsFolder, codenames[numberInList]);
                if (FileSystem.DirectoryExists(pluginFolder))
                {
                    FileSystem.DeleteDirectory(pluginFolder, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin, UICancelOption.DoNothing);
                }
                else
                {
                    DialogMan.ShowInfo(
                        this,
                        LangMan.Get("plugin-not-found"),
                        LangMan.Get("error"),
                        DarkMode
                        );
                }
                RefreshPluginsList();
            }
        }
Ejemplo n.º 6
0
 private void openWithCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     if (settingsStarted)
     {
         try
         {
             if (openWithCheckBox.Checked)
             {
                 Registry.SetValue("HKEY_CLASSES_ROOT\\*\\shell\\QuickPictureViewer", "", "Open with Quick Picture Viewer");
                 Registry.SetValue("HKEY_CLASSES_ROOT\\*\\shell\\QuickPictureViewer", "Icon", string.Format("\"{0}picture.ico\"", AppDomain.CurrentDomain.BaseDirectory));
                 Registry.SetValue("HKEY_CLASSES_ROOT\\*\\shell\\QuickPictureViewer\\command", "", string.Format("\"{0}quick-picture-viewer.exe\" \"%V\"", AppDomain.CurrentDomain.BaseDirectory));
             }
             else
             {
                 RegistryKey RegKey = Registry.ClassesRoot.OpenSubKey("*\\shell\\QuickPictureViewer", true);
                 RegKey.DeleteSubKeyTree("");
             }
         }
         catch
         {
             settingsStarted = false;
             DialogMan.ShowInfo(
                 this,
                 LangMan.Get("context-menu-notice"),
                 LangMan.Get("error"),
                 DarkMode,
                 TopMost
                 );
             openWithCheckBox.Checked = !openWithCheckBox.Checked;
             settingsStarted          = true;
         }
     }
 }
 public override FileTypeMan.OpenResult Open(string path)
 {
     try
     {
         string tempJpg = ConvertImage(path);
         if (tempJpg == null)
         {
             return(new FileTypeMan.OpenResult
             {
                 ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
             });
         }
         else
         {
             return(new FileTypeMan.OpenResult
             {
                 Bmp = new Bitmap(tempJpg)
             });
         }
     }
     catch
     {
         return(new FileTypeMan.OpenResult
         {
             ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
         });
     }
 }
Ejemplo n.º 8
0
 private void InitLanguage()
 {
     Text                = LangMan.Get("about");
     updatesBtn.Text     = " " + LangMan.Get("check-for-app-updates");
     descTextBox.Text    = LangMan.Get("app-description");
     makeDefaultBtn.Text = LangMan.Get("set-as-default-image-viewer");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
Ejemplo n.º 9
0
 private void InitLanguage()
 {
     Text             = LangMan.Get("edit-selection");
     widthLabel.Text  = LangMan.Get("width") + ":";
     heightLabel.Text = LangMan.Get("height") + ":";
     okButton.Text    = NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDOK);
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
Ejemplo n.º 10
0
        private void NavPanel_Load(object sender, System.EventArgs e)
        {
            owner = Parent as MainForm;

            infoTooltip.SetToolTip(navPrevBtn, LangMan.Get("prev-image") + " | " + LangMan.Get("left-arrow"));
            infoTooltip.SetToolTip(navNextBtn, LangMan.Get("next-image") + " | " + LangMan.Get("right-arrow"));
            infoTooltip.SetToolTip(navSlideshowBtn, LangMan.Get("slideshow") + " | Ctrl+Shift+S");

            Location = new Point(borderSpacing, Parent.ClientRectangle.Height - extraBottomMargin - Height - borderSpacing);
        }
 private void InitLanguage()
 {
     infoTooltip.SetToolTip(autoZoomBtn, LangMan.Get("auto-zoom") + " | Ctrl+A");
     infoTooltip.SetToolTip(opacityBtn, LangMan.Get("change-window-opacity") + " | Ctrl+O");
     zoomLabel.Text     = LangMan.Get("zoom") + ": " + LangMan.Get("auto");
     checkboardBtn.Text = LangMan.Get("checkboard-background");
     newWindowBtn.Text  = LangMan.Get("new-window");
     quitPipBtn.Text    = LangMan.Get("exit-picture-in-picture");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
Ejemplo n.º 12
0
        private void InfoForm_Load(object sender, EventArgs e)
        {
            SetDarkMode(DarkMode);
            InitLanguage();

            if (directoryName != null)
            {
                string path = Path.Combine(directoryName, fileName);

                fileNameTextBox.Text = fileName;
                folderTextBox.Text   = directoryName;
                fullPathTextBox.Text = path;

                diskSizeTextBox.Text  = Converter.PathToSize(path);
                extensionTextBox.Text = Path.GetExtension(path).Substring(1, Path.GetExtension(path).Length - 1).ToUpper();

                createdTextBox.Text  = File.GetCreationTime(path).ToShortDateString() + " - " + File.GetCreationTime(path).ToLongTimeString();
                modifiedTextBox.Text = File.GetLastWriteTime(path).ToShortDateString() + " - " + File.GetLastWriteTime(path).ToLongTimeString();

                propertiesButton.Visible = true;
            }

            double inchesWidth  = bitmap.Width / bitmap.HorizontalResolution;
            double inchesHeight = bitmap.Height / bitmap.VerticalResolution;
            double cmWidth      = inchesWidth * 2.54;
            double cmHeight     = inchesHeight * 2.54;

            compressionTextBox.Text = getImageCompression(bitmap);

            sizeTextBox.Text       = bitmap.Width + " x " + bitmap.Height + " " + LangMan.Get("pixels");
            megapixelsTextBox.Text = ((((float)bitmap.Height * bitmap.Width) / 1000000)).ToString("0.##") + " " + LangMan.Get("megapixels");
            resolutionTextBox.Text = Math.Round(bitmap.HorizontalResolution) + " x " + Math.Round(bitmap.VerticalResolution) + " DPI";
            inchesTextBox.Text     = inchesWidth.ToString("0.##") + " x " + inchesHeight.ToString("0.##") + " " + LangMan.Get("inches");
            cmTextBox.Text         = cmWidth.ToString("0.##") + " x " + cmHeight.ToString("0.##") + " " + LangMan.Get("centimeters");

            int firstRatio  = bitmap.Width / GCD(bitmap.Width, bitmap.Height);
            int secondRatio = bitmap.Height / GCD(bitmap.Width, bitmap.Height);

            ratioTextBox.Text = string.Format("{0} : {1} (", firstRatio, secondRatio);
            if (firstRatio == secondRatio)
            {
                ratioTextBox.Text += LangMan.Get("square");
            }
            else if (firstRatio > secondRatio)
            {
                ratioTextBox.Text += LangMan.Get("landscape");
            }
            else
            {
                ratioTextBox.Text += LangMan.Get("portrait");
            }
            ratioTextBox.Text += ")";

            fileNameTextBox.Focus();
        }
 private void InitLanguage()
 {
     Text = "SVG " + LangMan.Get("type-options");
     presetsLabel.Text        = LangMan.Get("presets") + ":";
     widthLabel.Text          = LangMan.Get("width") + ":";
     heightLabel.Text         = LangMan.Get("height") + ":";
     defaultSizeButton.Text   = LangMan.Get("original-size");
     autoSizeBtn.Text         = LangMan.Get("auto-size");
     okButton.Text            = " " + LangMan.Get("resize-svg");
     aspectRatioCheckbox.Text = LangMan.Get("maintain-aspect-ratio");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
 private void InitLanguage()
 {
     Text          = LangMan.Get("set-as-desktop-background");
     fitLabel.Text = LangMan.Get("choose-fit") + ":";
     okButton.Text = " " + LangMan.Get("set-background");
     fitComboBox.Items.Add(LangMan.Get("fill"));
     fitComboBox.Items.Add(LangMan.Get("fit"));
     fitComboBox.Items.Add(LangMan.Get("stretch"));
     fitComboBox.Items.Add(LangMan.Get("tile"));
     fitComboBox.Items.Add(LangMan.Get("center"));
     fitComboBox.Items.Add(LangMan.Get("span"));
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
        public static string GetFolder()
        {
            CommonOpenFileDialog dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            dialog.Title          = LangMan.Get("open-recursive");
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                string p = dialog.FileName;
                dialog.Dispose();
                return(p);
            }
            return(null);
        }
Ejemplo n.º 16
0
 private void InitLanguage()
 {
     Text = LangMan.Get("plugin-manager");
     listView1.Columns[0].Text = LangMan.Get("plugin");
     listView1.Columns[1].Text = LangMan.Get("desc");
     listView1.Columns[2].Text = LangMan.Get("created-by");
     listView1.Columns[3].Text = LangMan.Get("version");
     addPluginBtn.Text         = " " + LangMan.Get("browse-for-plugins");
     deleteBtn.Text            = LangMan.Get("delete-plugin");
     openFileDialog1.Title     = LangMan.Get("browse-for-plugins");
     morePluginsBtn.Text       = " " + LangMan.Get("more-plugins");
     pluginWebsiteBtn.Text     = LangMan.Get("plugin-website");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
Ejemplo n.º 17
0
 private void InitLanguage()
 {
     Text = LangMan.Get("print-conf");
     setMarginsButton.Text   = LangMan.Get("set-margins-btn");
     okButton.Text           = LangMan.Get("print");
     leftLabel.Text          = LangMan.Get("left") + ":";
     rightLabel.Text         = LangMan.Get("right") + ":";
     topLabel.Text           = LangMan.Get("top") + ":";
     bottomLabel.Text        = LangMan.Get("bottom") + ":";
     documentLabel.Text      = LangMan.Get("title") + ":";
     centerCheckbox.Text     = LangMan.Get("center-image");
     horizontalCheckBox.Text = LangMan.Get("landscape-orientation");
     marginsLabel.Text       = LangMan.Get("margins") + ":";
     marginsCheckBox.Text    = LangMan.Get("margin-bounds");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
        private void okButton_Click(object sender, EventArgs e)
        {
            MainForm mf  = Owner as MainForm;
            Bitmap   bmp = SvgWrapper.ParseSvg(path, (int)widthNumeric.Value, (int)heightNumeric.Value);

            switch (SvgWrapper.CurrentError)
            {
            case SvgWrapper.Error.NoError:
                mf.openImage(bmp, Path.GetDirectoryName(path), Path.GetFileName(path));
                break;

            case SvgWrapper.Error.UnableToOpen:
                mf.showSuggestion(SvgWrapper.TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path), MainForm.SuggestionIcon.Warning);
                break;
            }
            Close();
        }
Ejemplo n.º 19
0
 public override FileTypeMan.OpenResult Open(string path)
 {
     try
     {
         return(new FileTypeMan.OpenResult
         {
             Bmp = new Icon(path, 128, 128).ToBitmap()
         });
     }
     catch
     {
         return(new FileTypeMan.OpenResult
         {
             ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
         });
     }
 }
Ejemplo n.º 20
0
 private void setMarginsButton_Click(object sender, EventArgs e)
 {
     try
     {
         printPreviewControl1.Document.DefaultPageSettings.Margins.Left   = Convert.ToInt32(leftMarginTextBox.Value);
         printPreviewControl1.Document.DefaultPageSettings.Margins.Top    = Convert.ToInt32(topMarginTextBox.Value);
         printPreviewControl1.Document.DefaultPageSettings.Margins.Right  = Convert.ToInt32(rightMarginTextBox.Value);
         printPreviewControl1.Document.DefaultPageSettings.Margins.Bottom = Convert.ToInt32(bottomMarginTextBox.Value);
         printPreviewControl1.InvalidatePreview();
     }
     catch
     {
         DialogMan.ShowInfo(
             LangMan.Get("plugin-not-found"),
             LangMan.Get("print-margins-error"),
             DarkMode
             );
     }
 }
Ejemplo n.º 21
0
 private void InitLanguage()
 {
     Text                          = LangMan.Get("settings");
     langPage.Text                 = LangMan.Get("localization");
     startupPage.Text              = LangMan.Get("startup");
     restartLabel1.Text            = "* " + LangMan.Get("restart-required");
     restartLabel2.Text            = "* " + LangMan.Get("restart-required");
     systemThemeRadio.Text         = LangMan.Get("use-system-setting");
     lightThemeRadio.Text          = LangMan.Get("light");
     darkThemeRadio.Text           = LangMan.Get("dark");
     themePage.Text                = LangMan.Get("theme");
     startupLabel.Text             = LangMan.Get("app-startup-actions") + ":";
     startupPasteCheckBox.Text     = LangMan.Get("paste-from-clipboard");
     startupBoundsCheckBox.Text    = LangMan.Get("restore-last-window-bounds");
     updatesCheckBox.Text          = LangMan.Get("check-for-app-updates");
     favExtLabel.Text              = LangMan.Get("fav-external-app") + ":";
     browseBtn.Text                = " " + LangMan.Get("browse");
     slideshowPage.Text            = LangMan.Get("slideshow");
     slideshowTimeLabel.Text       = LangMan.Get("switching-time") + ":";
     mousePage.Text                = LangMan.Get("input");
     slideshowSecondsLabel.Text    = LangMan.Get("seconds");
     slideshowCounterCheckBox.Text = LangMan.Get("show-slideshow-counter");
     fullscrCursorCheckBox.Text    = LangMan.Get("fullscreen-cursor");
     langLabel.Text                = LangMan.Get("ui-lang") + ":";
     translatedByLabel.Text        = LangMan.Get("translated-by") + ": ";
     escToExitCheckBox.Text        = string.Format(LangMan.Get("esc-to-exit"), "Esc");
     mouseWheelActionLabel.Text    = LangMan.Get("mouse-wheel-action") + ":";
     mouseWheelActionRadio1.Text   = LangMan.Get("scroll-up-down");
     mouseWheelActionRadio2.Text   = LangMan.Get("zoom-in-out");
     mouseWheelActionRadio3.Text   = LangMan.Get("next-prev-image");
     themeRestart.Text             = LangMan.Get("restart");
     localizationRestart.Text      = LangMan.Get("restart");
     contextMenuLabel.Text         = LangMan.Get("context-menu") + ":";
     makeDefaultBtn.Text           = LangMan.Get("set-as-default-image-viewer");
     navBarPage.Text               = LangMan.Get("navigation-bar");
     navBarCheckBox.Text           = LangMan.Get("enable-navigation-bar");
     navBarFullscreenCheckBox.Text = LangMan.Get("nav-bar-fullscreen");
     openWithCheckBox.Text         = LangMan.Get("open-with-qpv");
     browseWithCheckBox.Text       = LangMan.Get("browse-folder-with-qpv");
     helpTranslateBtn.Text         = LangMan.Get("help-us-translate-app");
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
Ejemplo n.º 22
0
        public override FileTypeMan.OpenResult Open(string path)
        {
            Bitmap bmp = ParseSvg(path);

            if (bmp != null)
            {
                return new FileTypeMan.OpenResult
                       {
                           Bmp = bmp
                       }
            }
            ;
            else
            {
                return new FileTypeMan.OpenResult
                       {
                           ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                       }
            };
        }
Ejemplo n.º 23
0
        public static FileTypeMan.OpenResult CustomSizeOpen(string path, int Width = -1, int Height = -1)
        {
            Bitmap bmp = ParseSvg(path, Width, Height);

            if (bmp != null)
            {
                return new FileTypeMan.OpenResult
                       {
                           Bmp = bmp
                       }
            }
            ;
            else
            {
                return new FileTypeMan.OpenResult
                       {
                           ErrorMessage = "SVG - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                       }
            };
        }
        private void setAutoZoom(bool b)
        {
            autoZoom = b;

            if (b)
            {
                pictureBox.Dock = DockStyle.Fill;

                zoomLabel.Text = LangMan.Get("zoom") + ": " + LangMan.Get("auto");

                Height = Convert.ToInt32(Width / ratio);
                if (Height == MaximumSize.Height)
                {
                    Width = Convert.ToInt32(Height * ratio);
                }
            }
            else
            {
                pictureBox.Dock = DockStyle.None;
            }
        }
Ejemplo n.º 25
0
 private void InitLanguage()
 {
     Text = LangMan.Get("image-info");
     fileNameLabel.Text   = LangMan.Get("file") + ":";
     folderLabel.Text     = LangMan.Get("folder") + ":";
     fullPathLabel.Text   = LangMan.Get("full-path") + ":";
     diskSizeLabel.Text   = LangMan.Get("disk-size") + ":";
     ratioLabel.Text      = LangMan.Get("aspect-ratio") + ":";
     resolutionLabel.Text = LangMan.Get("resolution") + ":";
     createdLabel.Text    = LangMan.Get("created") + ":";
     modifiedLabel.Text   = LangMan.Get("modified") + ":";
     infoTooltip.SetToolTip(copyNameButton, LangMan.Get("copy"));
     infoTooltip.SetToolTip(copyFolderButton, LangMan.Get("copy"));
     infoTooltip.SetToolTip(copyPathButton, LangMan.Get("copy"));
     extensionLabel.Text   = LangMan.Get("extension") + ":";
     compressionLabel.Text = LangMan.Get("compression") + ":";
     propertiesButton.Text = " " + LangMan.Get("file-properties");
     sizeLabel.Text        = LangMan.Get("size") + " (px):";
     megapixelsLabel.Text  = LangMan.Get("size") + " (mp):";
     inchesLabel.Text      = LangMan.Get("print-size") + " (in):";
     cmLabel.Text          = LangMan.Get("print-size") + " (cm):";
     infoTooltip.SetToolTip(closeBtn, NativeMan.GetMessageBoxText(NativeMan.DialogBoxCommandID.IDCLOSE) + " | Alt+F4");
 }
Ejemplo n.º 26
0
 public override FileTypeMan.OpenResult Open(string path)
 {
     try
     {
         byte[] rawWebP = File.ReadAllBytes(path);
         using (WebP webp = new WebP())
         {
             WebPDecoderOptions decoderOptions = new WebPDecoderOptions();
             decoderOptions.use_threads = 1;
             decoderOptions.alpha_dithering_strength = 100;
             return(new FileTypeMan.OpenResult
             {
                 Bmp = webp.Decode(rawWebP, decoderOptions)
             });
         }
     }
     catch
     {
         return(new FileTypeMan.OpenResult
         {
             ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
         });
     }
 }
Ejemplo n.º 27
0
        public override FileTypeMan.OpenResult Open(string path)
        {
            try
            {
                using (var image = Pfim.Pfim.FromFile(path))
                {
                    PixelFormat format;

                    switch (image.Format)
                    {
                    case Pfim.ImageFormat.Rgba32:
                        format = PixelFormat.Format32bppArgb;
                        break;

                    case Pfim.ImageFormat.Rgb24:
                        format = PixelFormat.Format24bppRgb;
                        break;

                    case Pfim.ImageFormat.Rgba16:
                        format = PixelFormat.Format16bppArgb1555;
                        break;

                    case Pfim.ImageFormat.Rgb8:
                        format = PixelFormat.Format8bppIndexed;
                        break;

                    default:
                        return(new FileTypeMan.OpenResult
                        {
                            ErrorMessage = TypeName + " - " + LangMan.Get("unsupported-pixel-format") + ": " + Path.GetFileName(path)
                        });
                    }

                    try
                    {
                        if (TmpGcHandle != null && TmpGcHandle.IsAllocated)
                        {
                            TmpGcHandle.Free();
                        }
                        TmpGcHandle = GCHandle.Alloc(image.Data, GCHandleType.Pinned);
                        var data = Marshal.UnsafeAddrOfPinnedArrayElement(image.Data, 0);

                        return(new FileTypeMan.OpenResult
                        {
                            Bmp = new Bitmap(image.Width, image.Height, image.Stride, format, data)
                        });
                    }
                    catch
                    {
                        return(new FileTypeMan.OpenResult
                        {
                            ErrorMessage = TypeName + " - " + LangMan.Get("memory-error") + ": " + Path.GetFileName(path)
                        });
                    }
                }
            }
            catch
            {
                return(new FileTypeMan.OpenResult
                {
                    ErrorMessage = TypeName + " - " + LangMan.Get("unable-open-file") + ": " + Path.GetFileName(path)
                });
            }
        }