コード例 #1
0
        private void SaveLUT(ExtractFlags flags, string basePath, string part, string fname, ulong key, string ocioPath, MapInfo mapInfo)
        {
            if (!Directory.Exists(Path.Combine(basePath, part)))
            {
                Directory.CreateDirectory(Path.Combine(basePath, part));
            }

            if (key == 0)
            {
                return;
            }

            using (Stream lutStream = OpenFile(key))
            {
                if (lutStream == null)
                {
                    return;
                }

                lutStream.Position = 128;

                string lut = LUT.SPILUT1024x32(lutStream);
                using (Stream spilut = File.OpenWrite(Path.Combine(basePath, part, $"{fname}.spi3d")))
                    using (TextWriter spilutWriter = new StreamWriter(spilut))
                    {
                        spilutWriter.WriteLine(lut);
                        using (TextWriter ocioWriter = File.AppendText(Path.Combine(ocioPath)))
                        {
                            ocioWriter.WriteLine(OCIOChunk(mapInfo, fname));
                        }
                    }
            }
        }
コード例 #2
0
ファイル: LUTTest.cs プロジェクト: wesgrant/AudioLib
        public void TestReadFile()
        {
            var l = new LUT();

            l.ReadFile("1N914_tf.txt");
            var v = l.GetValue(8.0f);

            Assert.AreEqual(0.6785316, v, 0.000001);

            v = l.GetValue(0.0f);
            Assert.AreEqual(0.0, v, 0.0003);
        }
コード例 #3
0
    { ///<summary>execute command</summary>
        public static void Execute(vtkObject sender, vtkObjectEventArgs e)
        {
            //Global Variable Declaration Skipped
            rangeStart = rangeStart + 0.1;
            rangeEnd   = rangeEnd + 0.1;
            if ((rangeEnd) > 1.0)
            {
                rangeStart = 0.0;
                rangeEnd   = 0.2;
            }

            LUT.SetHueRange((double)rangeStart, (double)rangeEnd);
            LUT.Build();
        }
コード例 #4
0
        public void InitializeDevice()
        {
            DevInfo.DeviceID = "Low Profile - Mr. Fuzz";
#if DEBUG
            DevInfo.DeviceID = DevInfo.DeviceID + " - Dev";
#endif
            DevInfo.Developer = "Valdemar Erlingsson";
            //DevInfo.EditorHeight = e.Height;
            //DevInfo.EditorWidth = e.Width;
            DevInfo.HasEditor    = false;
            DevInfo.Name         = "Mr. Fuzz";
            DevInfo.ProgramCount = 1;
            DevInfo.Type         = DeviceType.Effect;
            DevInfo.Version      = 1000;
            DevInfo.VstId        = DeviceUtilities.GenerateIntegerId(DevInfo.DeviceID);

            PortInfo[0].Direction        = PortDirection.Input;
            PortInfo[0].Name             = "Mono Input";
            PortInfo[0].NumberOfChannels = 1;

            PortInfo[1].Direction        = PortDirection.Output;
            PortInfo[1].Name             = "Stereo Output";
            PortInfo[1].NumberOfChannels = 2;

            for (int i = 0; i < ParameterInfo.Length; i++)
            {
                var p = new Parameter();
                p.Display        = "0.5";
                p.Index          = (uint)i;
                p.Name           = ParameterNames[i];
                p.Steps          = 0;
                p.Value          = 0.5;
                ParameterInfo[i] = p;
            }

            HpInput    = new Highpass1((float)Samplerate);
            TFStage    = new MrFuzz.TFStage((float)Samplerate);
            DiodeStage = new LUT();
            DiodeStage.ReadRecord(Table.DiodeResponse);
            DiodeStage.Table = Utils.MovingAve(DiodeStage.Table, (int)(DiodeStage.Table.Length / 200.0));
            DiodeStage.Table = Table.Upsample(DiodeStage.Table, 100000);
            LowpassFilter    = new Lowpass1((float)Samplerate);
            HpOutput         = new Highpass1((float)Samplerate);

            // initialize all blocks
            UpdateAll();
        }
コード例 #5
0
        public static Bitmap Run(Bitmap bmp)
        {
            //1. Dystrybuanta
            Histogram hist = new Histogram(bmp);

            double[] dystrybuantaR = dystrybuanta(hist.R);
            double[] dystrybuantaG = dystrybuanta(hist.G);
            double[] dystrybuantaB = dystrybuanta(hist.B);
            //2. LookUp Table
            LUT lookupR = new LUT();
            LUT lookupG = new LUT();
            LUT lookupB = new LUT();

            for (int i = 0; i < 256; i++)
            {
                lookupR[i] = (int)(((dystrybuantaR[i] - dystrybuantaR[0]) / (1 - dystrybuantaR[0])) * (dystrybuantaR.Length - 1));
                lookupR[i] = (lookupR[i] > 255)? 255 : lookupR[i];
                lookupR[i] = (lookupR[i] < 0) ? 0 : lookupR[i];

                lookupG[i] = (int)(((dystrybuantaG[i] - dystrybuantaG[0]) / (1 - dystrybuantaG[0])) * (dystrybuantaG.Length - 1));
                lookupG[i] = (lookupG[i] > 255) ? 255 : lookupG[i];
                lookupG[i] = (lookupG[i] < 0) ? 0 : lookupG[i];

                lookupB[i] = (int)(((dystrybuantaB[i] - dystrybuantaB[0]) / (1 - dystrybuantaB[0])) * (dystrybuantaB.Length - 1));
                lookupB[i] = (lookupB[i] > 255) ? 255 : lookupB[i];
                lookupB[i] = (lookupB[i] < 0) ? 0 : lookupB[i];
            }
            //3. Wprowadzanie zmian
            Bitmap retVal = new Bitmap(bmp.Width, bmp.Height);

            for (int x = 0; x < retVal.Width; x++)
            {
                for (int y = 0; y < retVal.Height; y++)
                {
                    Color c      = bmp.GetPixel(x, y);
                    int   valueR = c.R;
                    int   valueG = c.G;
                    int   valueB = c.B;
                    int   newR   = (int)lookupR[valueR];
                    int   newG   = (int)lookupG[valueG];
                    int   newB   = (int)lookupB[valueB];
                    retVal.SetPixel(x, y, Color.FromArgb(newR, newG, newB));
                }
            }

            return(retVal);
        }
コード例 #6
0
        private void importLUTToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (anim.bmp == null)
            {
                MessageBox.Show("Impossibile caricare la palette senza un GFX caricato precedentemente.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (anim.bmp.Palette.Entries.Length == 0)
            {
                MessageBox.Show("Il GFX selezionato non ha la modalità palette, quindi è inutile che tenti di caricare la palette, mongoloide! Scherzavo XD non te la prendere u.u", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "LUT file|*.LUT";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                lut         = new LUT();
                lut.Palette = anim.bmp.Palette;
                lut.OpenLUT(openFileDialog.FileName);
                anim.bmp.Palette      = lut.ClutIndex(0);
                nPaletteIndex.Enabled = true;
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: hamburger1984/Bubobubo
        static void Main(string[] args)
        {
            int maxDigits  = 16; // TODO: 16
            var upperLimit = (long)Math.Pow(10, maxDigits);
            var maxNumber  = upperLimit - 1L;

            Log.Info($"Searching power sums for {maxDigits} digits, 0..{maxNumber}");

            var sw = Stopwatch.StartNew();

            Powers = new LUT <long>(10, maxDigits * 2, delegate((uint col, uint row)position)
            {
                if (position.row == 0)
                {
                    return(1);
                }

                if (position.col == 0)
                {
                    return(0);
                }

                return(IntPow(position.col, position.row));
            });
コード例 #8
0
ファイル: GFModel.cs プロジェクト: yorki00/SPICA
        public void Write(BinaryWriter Writer)
        {
            uint SectionsCount = (uint)(Materials.Count + Meshes.Count + 1);

            Writer.Write(MagicNum);
            Writer.Write(SectionsCount);

            GFSection.SkipPadding(Writer.BaseStream);

            long StartPosition = Writer.BaseStream.Position;

            new GFSection(MagicStr).Write(Writer);

            List <string> ShaderNames   = new List <string>();
            List <string> TextureNames  = new List <string>();
            List <string> MaterialNames = new List <string>();
            List <string> MeshNames     = new List <string>();

            foreach (GFMaterial Mat in Materials)
            {
                ShaderNames.Add(Mat.ShaderName);
                TextureNames.Add(Mat.TextureCoords[0].Name);
                TextureNames.Add(Mat.TextureCoords[1].Name);
                TextureNames.Add(Mat.TextureCoords[2].Name);
                TextureNames.Add(GetLUTName(Mat.LUT0HashId));
                TextureNames.Add(GetLUTName(Mat.LUT1HashId));
                TextureNames.Add(GetLUTName(Mat.LUT2HashId));
                MaterialNames.Add(Mat.MaterialName);
            }

            foreach (GFMesh Mesh in Meshes)
            {
                MeshNames.Add(Mesh.Name);
            }

            WriteHashTable(Writer, ShaderNames);
            WriteHashTable(Writer, TextureNames);
            WriteHashTable(Writer, MaterialNames);
            WriteHashTable(Writer, MeshNames);

            Writer.Write(BBoxMinVector);
            Writer.Write(BBoxMaxVector);
            Writer.Write(Transform);

            //TODO: Figure out what is this.
            Writer.Write(0);
            Writer.Write(0x10);
            Writer.Write(0ul);
            Writer.Write(0ul);
            Writer.Write(0ul);

            Writer.Write((uint)Skeleton.Count);

            Writer.BaseStream.Seek(0xc, SeekOrigin.Current);

            foreach (GFBone Bone in Skeleton)
            {
                Bone.Write(Writer);
            }

            GFSection.SkipPadding(Writer.BaseStream);

            Writer.Write(LUTs.Count);
            Writer.Write(0x420);

            GFSection.SkipPadding(Writer.BaseStream);

            foreach (GFLUT LUT in LUTs)
            {
                LUT.Write(Writer);
            }

            long EndPosition = Writer.BaseStream.Position;

            Writer.BaseStream.Seek(StartPosition + 8, SeekOrigin.Begin);

            Writer.Write((uint)(EndPosition - StartPosition - 0x10));

            Writer.BaseStream.Seek(EndPosition, SeekOrigin.Begin);

            foreach (GFMaterial Mat in Materials)
            {
                Mat.Write(Writer);
            }

            foreach (GFMesh Mesh in Meshes)
            {
                Mesh.Write(Writer);
            }
        }
コード例 #9
0
ファイル: Category.cs プロジェクト: tsanov/wincompose
 public static EmojiCategory FromEmojiString(string str)
 {
     return(LUT.TryGetValue(str, out var ret) ? ret : null);
 }
コード例 #10
0
        public VHDLDocument Watermark(WatermarkOptions options)
        {
            var doc = options.WotermarikingDocument.Document;

            var IOBuffesLayer = new IOBuffesLayer(_document);

            IOBuffesLayer.Parse();

            options.WatermarkSettings.ForEach(x => x.Signal       = IOBuffesLayer.WhetherEquivalent(x.Signal));
            options.SignatureOutputSettings.ForEach(x => x.Signal = IOBuffesLayer.WhetherEquivalent(x.Signal));

            List <WatermarkBit> watermarkBits = new List <WatermarkBit>();

            options.SignatureOutputSettings.ForEach(ports =>
            {
                for (int j = 0; j < ports.SignatureCode.Length; j++)
                {
                    if (ports.SignatureCode[j] != '-')
                    {
                        var newWB = new WatermarkBit()
                        {
                            IsOne  = ports.SignatureCode[j] == '1',
                            Signal =
                                doc.Router.AssignmentSignal(null, ports.Signal, ports.Signal.Enumeration?.GetBit(j))
                        };
                        newWB.Signal.IsSource = false;
                        watermarkBits.Add(newWB);
                    }
                }
            });

            //var wbit2 = watermarkBits.FirstOrDefault();
            //var routes2 = doc.Router.GetRoutes(wbit2.Signal.Defenition);

            //var d = routes2.Signals.Where(signal => signal.IsSource == null).ToList();
            //var e = routes2.Signals.Where(signal => signal.IsSource != null && !signal.IsSource.Value).ToList();
            //var c = routes2.Signals.Where(signal => signal.IsSource != null && signal.IsSource.Value).ToList();


            //-----------------DECODER----------------------------------------
            var isWatermark = _document.Router.InserSignalDefenition("IS_WATERMARK", "STD_LOGIC");
            var decoder     = new Decoder(doc, isWatermark);

            var decoderSettings = options.WatermarkSettings.Where(x => x.IsUsed)
                                  .Select(a => new DecoderSignalCode(doc.Router.AssignmentSignal(decoder, a.Signal), a.ActivaionCode))
                                  .ToList();


            decoder.CodedSignals.AddRange(decoderSettings);
            _document.AddVHDLInBehaviorSection(decoder.ToString());

            //-----------------DECODER----------------------------------------


            //----------------------Lut work----------------------------------

            /**var signatureBus = _document.Router.CreateBus("WATERMARKED_OUT");
             * int i = 0;
             * options.WotermarikingDocument.FreeLuts.ForEach(lut =>
             * {
             *  ChangeLutConstIputs(lut, isWatermark, options.WotermarikingDocument.ConstValueGenerators);
             *  ChangeLutInitVector(lut, true);
             *  var newLutOutput = signatureBus.GetWire(i);
             *
             *  InjectLutOutput(lut, newLutOutput.Defenition);
             *  i++;
             * });
             * var watermarkedSignalDefenition = signatureBus.BuildSignal();**/

            LUTComponents components = new LUTComponents(doc);

            var lutForExtenion = _document.Maps
                                 .Where(map => LUT.IsLUT(map.Entity) && !options.WotermarikingDocument.FreeLuts.Contains(map))
                                 .Select(map => MapLUT.FromMap(map)).ToList();

            lutForExtenion.ForEach(lut => lut.ExtendLUT(components)); //Extends lut

            var freeInputs = lutForExtenion.Select(x => x.GetFreeInput()).ToList();

            List <MapLUT> lutsForInsertion = new List <MapLUT>(lutForExtenion); //Merge all luts

            //lutsForInsertion.AddRange(); //AddFreeLut


            lutsForInsertion.ForEach(lut =>
            {
                var watermarkBit = watermarkBits.FirstOrDefault(wb => wb.LUT == null);
                if (watermarkBit != null)
                {
                    var port = lut.GetFreeInput(); //TODO
                    lut.AddLutAssigment(Assignment.Create(lut, port, isWatermark));
                    lut.ConstValuePort(port, watermarkBit.IsOne);
                    watermarkBit.LUT = lut;
                }
            });

            //-----------------------------------------------------------------------------------------
            watermarkBits.GroupBy(x => x.Signal.Defenition).ToList().ForEach(def =>
            {
                var ficitonSignal = _document.Router
                                    .InserSignalDefenition(
                    "FO" + Helper.NewGuidName(),
                    def.Key.ValueType,
                    def.Key.Enumeration?.CloneEnumeration());

                doc.Router.RedirectAllSources(def.Key, ficitonSignal);
                def.ToList().ForEach(wbit =>
                {
                    wbit.RealSignal = doc.Router.GetRoutes(ficitonSignal)
                                      .Signals.FirstOrDefault(x => (x.Enumeration == null && wbit.Signal.Enumeration == null) ||
                                                              (x.Enumeration == null && wbit.Signal.Enumeration == null && x.Enumeration.IsSameBus(wbit.Signal.Enumeration)));

                    Mux mux       = new Mux();
                    mux.To        = wbit.Signal;
                    mux.Condition = doc.Router.AssignmentSignal(mux, isWatermark) + " = '1'";
                    mux.Else      = wbit.RealSignal;
                    mux.Then      = wbit.LUT.GetOutput();
                    mux.Insert(_document);
                });
            });

            return(_document);
        }
コード例 #11
0
        public void InitializeDevice()
        {
            DevInfo.DeviceID = "Low Profile - Smash Master";
#if DEBUG
            DevInfo.DeviceID = DevInfo.DeviceID + " - Dev";
#endif
            DevInfo.Developer    = "Valdemar Erlingsson";
            DevInfo.EditorHeight = 0;
            DevInfo.EditorWidth  = 0;
            DevInfo.HasEditor    = false;
            DevInfo.Name         = "Smash Master";
            DevInfo.ProgramCount = 1;
            DevInfo.Type         = DeviceType.Effect;
            DevInfo.Version      = 1000;
            DevInfo.VstId        = DeviceUtilities.GenerateIntegerId(DevInfo.DeviceID);

            PortInfo[0].Direction        = PortDirection.Input;
            PortInfo[0].Name             = "Stereo Input";
            PortInfo[0].NumberOfChannels = 2;

            PortInfo[1].Direction        = PortDirection.Output;
            PortInfo[1].Name             = "Stereo Output";
            PortInfo[1].NumberOfChannels = 2;

            for (int i = 0; i < ParameterInfo.Length; i++)
            {
                var p = new Parameter();
                p.Display        = "0.5";
                p.Index          = (uint)i;
                p.Name           = ParameterNames[i];
                p.Steps          = 0;
                p.Value          = 0.5;
                ParameterInfo[i] = p;
            }

            Hp1        = new Highpass1((float)Samplerate);
            LpNoise    = new Lowpass1((float)Samplerate);
            GainTF     = new Gain(this.Samplerate);
            PostGain   = new postGain(Samplerate);
            SaturateLP = new Lowpass1((float)Samplerate);
            ClipperHP  = new Highpass1((float)Samplerate);

            Clipper = new LUT();
            Clipper.ReadRecord(Tables.D1N914TF.Split('\n'));
            Clipper.Table = Tables.Upsample(Clipper.Table, 100000);

            Tonestack = new Tonestack((float)Samplerate);
            TF2       = new TF2(Samplerate);
            Contour   = new Contour(Samplerate);
            OutHP     = new Highpass1((float)Samplerate);
            OutLP     = new Lowpass1((float)Samplerate);

            // 16Hz, remove DC bias from input
            Hp1.SetParam(0, 16f);
            LpNoise.SetParam(0, 3500f);
            ClipperHP.SetParam(0, 10f);
            SaturateLP.SetParam(0, 15000);
            Tonestack.FenderMode = true;
            Tonestack.setComponents(0.022e-6, 0.22e-6, 0.022e-6, 1000, 5e6, 6.8e3, 25e3, 1e3, 100e3);
            OutHP.SetParam(0, 30f);

            // initialize all blocks
            UpdateAll();
        }
コード例 #12
0
ファイル: Visualizer.cs プロジェクト: thegodi/Gygax
        private static GeometryModel3D[] GetCameraPlanar(CameraPosition camera)
        {
            List <GeometryModel3D> models = new List <GeometryModel3D>();

            var model = new MeshGeometryModel3D();

            var length = (camera.FocalLength / Math.Sqrt(Math.Pow(camera.Height, 2) + Math.Pow(camera.Width, 2)));

            var p1 = camera.CameraCenter +
                     length * (CameraPosition.GetCornerPointToAxis(camera, camera.Orientation,
                                                                   CameraPosition.Direction.TopLeft));

            var p2 = camera.CameraCenter +
                     length * (CameraPosition.GetCornerPointToAxis(camera, camera.Orientation,
                                                                   CameraPosition.Direction.TopRight));

            var p3 = camera.CameraCenter +
                     length * (CameraPosition.GetCornerPointToAxis(camera, camera.Orientation,
                                                                   CameraPosition.Direction.BottomRight));

            var p4 = camera.CameraCenter +
                     length * (CameraPosition.GetCornerPointToAxis(camera, camera.Orientation,
                                                                   CameraPosition.Direction.BottomLeft));

            model.Geometry = PrimitiveBuilder.GetRect(p1.ToVector3(), p2.ToVector3(), p3.ToVector3(), p4.ToVector3());

            //model.Material = new PhongMaterial
            //{
            //    DiffuseMap = new BitmapImage(new Uri(camera.File))
            //};

            ////model.Material = PhongMaterials.Yellow;

            ////Viewport.Items.Add(model);
            //models.Add(model);

            var linemodel = new LineGeometryModel3D();
            var lb        = new LineBuilder();

            lb.AddLine(camera.CameraCenter.ToVector3(), p1.ToVector3());
            lb.AddLine(camera.CameraCenter.ToVector3(), p2.ToVector3());
            lb.AddLine(camera.CameraCenter.ToVector3(), p3.ToVector3());
            lb.AddLine(camera.CameraCenter.ToVector3(), p4.ToVector3());
            lb.AddLine(p1.ToVector3(), p2.ToVector3());
            lb.AddLine(p2.ToVector3(), p3.ToVector3());
            lb.AddLine(p3.ToVector3(), p4.ToVector3());
            lb.AddLine(p4.ToVector3(), p1.ToVector3());
            lb.AddLine(p1.ToVector3(), p3.ToVector3());
            lb.AddLine(p2.ToVector3(), p4.ToVector3());

            linemodel.Geometry = lb.ToLineGeometry3D();
            linemodel.Color    = LUT.GetRandomColor();

            linemodel.Name = "PlanarCamera_" + Path.GetFileName(camera.File).Split('.').First() + "_" + camera.Id;

            models.Add(linemodel);

            MeshBuilder         mb = new MeshBuilder();
            MeshGeometryModel3D modelCameraCenter = new MeshGeometryModel3D();

            mb.AddSphere(camera.CameraCenter.ToVector3(), 0.03);
            mb.AddSphere(p1.ToVector3(), 0.03);
            modelCameraCenter.Geometry = mb.ToMeshGeometry3D();

            modelCameraCenter.Material = new PhongMaterial()
            {
                DiffuseColor = linemodel.Color,
                AmbientColor = linemodel.Color
            };


            //models.Add(modelCameraCenter);

            return(models.ToArray());
        }