コード例 #1
0
        public static void RenderPreview(String filePath)
        {
            if (imagePreview != null)
            {
                imagePreview.Dispose();
            }
            imagePreview = null;

            Reader.ReadFile(filePath);
            fileSizeString = Reader.GetFileSizeString(filePath);
            Bitmap image = Reader.image;

            if (image != null)
            {
                ImageFilters filters      = new ImageFilters();
                int          iconsChecked = 0;
                if (FilterSettings.isIconBTN)
                {
                    iconsChecked++;
                }
                if (FilterSettings.isIconPAS)
                {
                    iconsChecked++;
                }
                if (FilterSettings.isIconATC)
                {
                    iconsChecked++;
                }
                if (FilterSettings.isIconDISBTN)
                {
                    iconsChecked++;
                }
                if (FilterSettings.isIconDISPAS)
                {
                    iconsChecked++;
                }
                if (FilterSettings.isIconDISATC)
                {
                    iconsChecked++;
                }
                if (FilterSettings.isIconATT)
                {
                    iconsChecked++;
                }
                if (FilterSettings.isIconUPG)
                {
                    iconsChecked++;
                }

                if (iconsChecked == 1)
                {
                    if (FilterSettings.isIconBTN)
                    {
                        image = filters.AddIconBorder(image, IconTypes.BTN);
                    }
                    if (FilterSettings.isIconPAS)
                    {
                        image = filters.AddIconBorder(image, IconTypes.PAS);
                    }
                    if (FilterSettings.isIconATC)
                    {
                        image = filters.AddIconBorder(image, IconTypes.ATC);
                    }
                    if (FilterSettings.isIconDISBTN)
                    {
                        image = filters.AddIconBorder(image, IconTypes.DISBTN);
                    }
                    if (FilterSettings.isIconDISPAS)
                    {
                        image = filters.AddIconBorder(image, IconTypes.DISPAS);
                    }
                    if (FilterSettings.isIconDISATC)
                    {
                        image = filters.AddIconBorder(image, IconTypes.DISATC);
                    }
                    if (FilterSettings.isIconATT)
                    {
                        image = filters.AddIconBorder(image, IconTypes.ATT);
                    }
                    if (FilterSettings.isIconUPG)
                    {
                        image = filters.AddIconBorder(image, IconTypes.UPG);
                    }
                    errorMsg = "";
                }
                else
                {
                    if (FilterSettings.war3IconType == War3IconType.ClassicIcon && iconsChecked > 1 && image.Width == 64 && image.Height == 64)
                    {
                        errorMsg = "Cannot display multiple icon filters";
                    }
                    else if (FilterSettings.war3IconType == War3IconType.ReforgedIcon && iconsChecked > 1 && image.Width == 256 && image.Height == 256)
                    {
                        errorMsg = "Cannot display multiple icon filters";
                    }
                    else
                    {
                        errorMsg = "";
                    }
                }

                if (FilterSettings.isResized)
                {
                    image = ImageFilters.ResizeBitmap(image, FilterSettings.resizeX, FilterSettings.resizeY);
                }
            }
            else
            {
                errorMsg = Reader.errorMsg;
            }

            imagePreview = image;
        }
コード例 #2
0
        public static bool Convert(string file, int currentEntryNumber = 0)
        {
            bool success = false;

            fileEntry = file;
            Converter.currentEntryNumber = currentEntryNumber;

            Reader.ReadFile(file);

            List <Bitmap> filteredImages = new List <Bitmap>();
            List <string> prefix         = new List <string>();

            if (Reader.image != null)
            {
                if (FilterSettings.war3IconType == War3IconType.None)
                {
                    ExportSettings.prefix = "";
                    if (FilterSettings.isResized)
                    {
                        //imageToConvert.Mutate(x => x.Resize(FilterSettings.resizeX, FilterSettings.resizeY)); // Old ImageSharp resize function
                        Reader.image = ImageFilters.ResizeBitmap(Reader.image, FilterSettings.resizeX, FilterSettings.resizeY);
                    }

                    success = Write(Reader.image);
                }
                else
                {
                    errorMsg = "Image dimensions did not match selected icon dimensions.";
                    ImageFilters filters = new ImageFilters();

                    if ((FilterSettings.war3IconType == War3IconType.ClassicIcon && Reader.image.Width == 64 && Reader.image.Height == 64) || (FilterSettings.war3IconType == War3IconType.ReforgedIcon && Reader.image.Width == 256 && Reader.image.Height == 256))
                    {
                        if (FilterSettings.isIconBTN)
                        {
                            prefix.Add("BTN");
                            filteredImages.Add(filters.AddIconBorder(Reader.image, IconTypes.BTN));
                        }
                        if (FilterSettings.isIconPAS)
                        {
                            prefix.Add("PAS");
                            filteredImages.Add(filters.AddIconBorder(Reader.image, IconTypes.PAS));
                        }
                        if (FilterSettings.isIconATC)
                        {
                            prefix.Add("ATC");
                            filteredImages.Add(filters.AddIconBorder(Reader.image, IconTypes.ATC));
                        }
                        if (FilterSettings.isIconDISBTN)
                        {
                            prefix.Add("DISBTN");
                            filteredImages.Add(filters.AddIconBorder(Reader.image, IconTypes.DISBTN));
                        }
                        if (FilterSettings.isIconDISPAS)
                        {
                            prefix.Add("DISPAS");
                            filteredImages.Add(filters.AddIconBorder(Reader.image, IconTypes.DISPAS));
                        }
                        if (FilterSettings.isIconDISATC)
                        {
                            prefix.Add("DISATC");
                            filteredImages.Add(filters.AddIconBorder(Reader.image, IconTypes.DISATC));
                        }
                        if (FilterSettings.isIconATT)
                        {
                            prefix.Add("ATT");
                            filteredImages.Add(filters.AddIconBorder(Reader.image, IconTypes.ATT));
                        }
                        if (FilterSettings.isIconUPG)
                        {
                            prefix.Add("UPG");
                            filteredImages.Add(filters.AddIconBorder(Reader.image, IconTypes.UPG));
                        }

                        errorMsg = "No icon selected.";

                        for (int i = 0; i < filteredImages.Count; i++)
                        {
                            if (FilterSettings.isResized)
                            {
                                //filteredImages[i].Mutate(x => x.Resize(FilterSettings.resizeX, FilterSettings.resizeY)); // Old ImageSharp resize function
                                filteredImages[i] = ImageFilters.ResizeBitmap(filteredImages[i], FilterSettings.resizeX, FilterSettings.resizeY);
                            }
                            ExportSettings.prefix = prefix[i];
                            success  = Write(filteredImages[i]);
                            errorMsg = "";
                        }
                    }
                }
            }
            else
            {
                errorMsg = Reader.errorMsg;
            }

            return(success);
        }