示例#1
0
        protected override Document OnLoad(Stream input)
        {
            // reset settings cache on fresh loaded files
            pvrMetaDataCache = null;

            // Setup loading engine
            if (LoadEngineMode == PvrEngineEnum.None)
            {
                ShowLoadSetupDialogBox();
            }

            if (LoadEngineMode == PvrEngineEnum.PuyoTools)
            {
                loadedPvrPuyo = new PvrTextureDecoder(input);
                var img       = loadedPvrPuyo.GetImage();
                var imgNative = ImageSharpExtensions.ToBitmap(img);
                return(Document.FromImage(imgNative));
            }
            else if (LoadEngineMode == PvrEngineEnum.ShenmueDK)
            {
                PVRT.EnableBuffering = false;
                loadedPvr            = new PVRT(input);
                return(Document.FromImage(loadedPvr.CreateBitmap()));
            }
            else
            {
                throw new Exception("User canceled the operation!");
            }
        }
        private void button_genPrev_Click(object sender, EventArgs e)
        {
            SixLabors.ImageSharp.Image <Bgra32> tmpImg = ImageSharpExtensions.ToImageSharpImage(_img);

            var pf = (PvrPixelFormat)comboBox_PixelFormat.SelectedItem;
            var df = (PvrDataFormat)comboBox_DataFormat.SelectedItem;
            var dr = comboBox_Dithering.SelectedIndex;
            var em = checkBox_eyeMode.Checked;

            using (var ms = new MemoryStream())
            {
                // Temp encode to pvr
                PvrTextureEncoder tmpImgRaw = new PvrTextureEncoder(tmpImg, pf, df);
                tmpImgRaw.DitheringMode = dr;
                if (em == false)
                {
                    tmpImgRaw.MetricMode = 0;
                }
                else
                {
                    tmpImgRaw.MetricMode = 1;
                }

                tmpImgRaw.Save(ms);
                ms.Seek(0, SeekOrigin.Begin);

                //Tmp decode for preview
                var tmpPreview = new PvrTextureDecoder(ms);
                var img        = tmpPreview.GetImage();
                var imgNative  = ImageSharpExtensions.ToBitmap(img);

                pictureBox_PVRPreview.Image = imgNative;

                pictureBox_PVRPreview.Update();
                panel1.Update();
            }
        }