Пример #1
0
        public static Image GetSprite(int species, int form, int gender, int item, bool isegg, bool shiny, int generation = -1, bool isBoxBGRed = false)
        {
            if (species == 0)
            {
                return(Resources._0);
            }

            if (generation == 3 && species == 386) // Deoxys, special consideration for Gen3 save files
            {
                form = GetDeoxysForm();
            }

            string file = PKX.GetResourceStringSprite(species, form, gender, generation, shiny);

            // Redrawing logic
            Image baseImage = (Image)Resources.ResourceManager.GetObject(file);

            if (FormConverter.IsTotemForm(species, form))
            {
                form      = FormConverter.GetTotemBaseForm(species, form);
                file      = PKX.GetResourceStringSprite(species, form, gender, generation, shiny);
                baseImage = (Image)Resources.ResourceManager.GetObject(file);
                baseImage = ImageUtil.ToGrayscale(baseImage);
            }
            if (baseImage == null)
            {
                if (shiny) // try again without shiny
                {
                    file      = PKX.GetResourceStringSprite(species, form, gender, generation);
                    baseImage = (Image)Resources.ResourceManager.GetObject(file);
                }
                if (baseImage == null)
                {
                    baseImage = (Image)Resources.ResourceManager.GetObject($"_{species}");
                }
                baseImage = baseImage != null?ImageUtil.LayerImage(baseImage, Resources.unknown, 0, 0, .5) : Resources.unknown;
            }
            if (isegg)
            {
                // Partially transparent species.
                baseImage = ImageUtil.ChangeOpacity(baseImage, 0.33);
                // Add the egg layer over-top with full opacity.
                var egg = species == 490 ? (Image)Resources.ResourceManager.GetObject("_490_e") : Resources.egg;
                baseImage = ImageUtil.LayerImage(baseImage, egg, 0, 0, 1);
            }
            if (shiny)
            {
                // Add shiny star to top left of image.
                var rare = isBoxBGRed ? Resources.rare_icon_alt : Resources.rare_icon;
                baseImage = ImageUtil.LayerImage(baseImage, rare, 0, 0, 0.7);
            }
            if (item > 0)
            {
                Image itemimg = (Image)Resources.ResourceManager.GetObject($"item_{item}") ?? Resources.helditem;
                if (generation >= 2 && generation <= 4 && 328 <= item && item <= 419) // gen2/3/4 TM
                {
                    itemimg = Resources.item_tm;
                }

                // Redraw
                int x = 22 + (15 - itemimg.Width) / 2;
                if (x + itemimg.Width > baseImage.Width)
                {
                    x = baseImage.Width - itemimg.Width;
                }
                int y = 15 + (15 - itemimg.Height);
                baseImage = ImageUtil.LayerImage(baseImage, itemimg, x, y, 1);
            }
            return(baseImage);
        }
Пример #2
0
 public static Bitmap GetBitmap(CGearBackground bg)
 {
     return(ImageUtil.GetBitmap(bg.GetImageData(), CGearBackground.Width, CGearBackground.Height));
 }
Пример #3
0
        private static Image LayerOverImageEggAsItem(Image baseImage, int species)
        {
            var egg = GetEggSprite(species);

            return(ImageUtil.LayerImage(baseImage, egg, EggOverLayerAsItemShiftX, EggOverLayerAsItemShiftY)); // similar to held item, since they can't have any
        }
        private void ExportQRCodes(object sender, EventArgs e)
        {
            SaveFile SAV     = C_SAV.SAV;
            var      boxdata = SAV.BoxData;

            if (boxdata == null)
            {
                WinFormsUtil.Alert("Box Data is null");
            }
            int ctr = 0;
            Dictionary <string, Image> qrcodes = new Dictionary <string, Image>();

            foreach (PKM pk in boxdata)
            {
                if (pk.Species == 0 || !pk.Valid || (pk.Box - 1) != C_SAV.Box.CurrentBox)
                {
                    continue;
                }
                ctr++;
                Image qr;
                switch (pk.Format)
                {
                case 7:
                    qr = QR.GenerateQRCode7((PK7)pk);
                    break;

                default:
                    if (pk.Format == 6 && !QR6Notified)     // users should not be using QR6 injection
                    {
                        WinFormsUtil.Alert(MsgQRDeprecated, MsgQRAlternative);
                        QR6Notified = true;
                    }
                    qr = QR.GetQRImage(pk.EncryptedBoxData, QR.GetQRServer(pk.Format));
                    break;
                }
                if (qr == null)
                {
                    continue;
                }
                var sprite = dragout.Image;
                var la     = new LegalityAnalysis(pk, C_SAV.SAV.Personal);
                if (la.Parsed && pk.Species != 0)
                {
                    var img = la.Valid ? Resources.valid : Resources.warn;
                    sprite = ImageUtil.LayerImage(sprite, img, 24, 0, 1);
                }
                string[] r     = pk.QRText;
                string   refer = "PKHeX Auto Legality Mod";
                qrcodes.Add(Util.CleanFileName(pk.FileName), RefreshImage(qr, sprite, r[0], r[1], r[2], $"{refer} ({pk.GetType().Name})"));
            }
            if (!Directory.Exists(Path.Combine(WorkingDirectory, "qrcodes")))
            {
                Directory.CreateDirectory(Path.Combine(WorkingDirectory, "qrcodes"));
            }
            int counter = 0;

            foreach (KeyValuePair <string, Image> qrcode in qrcodes)
            {
                Console.WriteLine(counter);
                counter++;
                qrcode.Value.Save(Path.Combine(WorkingDirectory, "qrcodes", qrcode.Key + ".png"));
            }
        }