Ejemplo n.º 1
0
        public void SetExtraRecords(LayerMask layerMask, LayerBlendingRanges blendingRanges, IProperties resources, string name)
        {
            this.layerMask      = layerMask;
            this.blendingRanges = blendingRanges;
            this.resources      = resources;
            this.name           = name;

            this.resources.TryGetValue <string>(ref this.name, "luni.Name");
            this.resources.TryGetValue <int>(ref this.version, "lyvr.Version");
            if (this.resources.Contains("lsct.SectionType") == true)
            {
                this.sectionType = (SectionType)this.resources.ToInt32("lsct.SectionType");
            }
            if (this.resources.Contains("lsdk.SectionType") == true)
            {
                this.sectionType = (SectionType)this.resources.ToInt32("lsdk.SectionType");
            }
            if (this.resources.Contains("SoLd.Idnt") == true)
            {
                this.placedID = this.resources.ToGuid("SoLd.Idnt");
            }
            else if (this.resources.Contains("SoLE.Idnt") == true)
            {
                this.placedID = this.resources.ToGuid("SoLE.Idnt");
            }

            JudgeType();

            foreach (var item in this.channels)
            {
                switch (item.Type)
                {
                case ChannelType.Mask:
                {
                    if (this.layerMask != null)
                    {
                        item.Width  = this.layerMask.Width;
                        item.Height = this.layerMask.Height;
                    }
                }
                break;

                case ChannelType.Alpha:
                {
                    if (this.resources.Contains("iOpa") == true)
                    {
                        byte opa = this.resources.ToByte("iOpa", "Opacity");
                        item.Opacity = opa / 255.0f;
                    }
                }
                break;
                }
            }
        }
Ejemplo n.º 2
0
        protected override void ReadValue(PsdReader reader, object userData, out LayerRecords value)
        {
            LayerRecords records = userData as LayerRecords;

            LayerMask           mask           = LayerMaskReader.Read(reader);
            LayerBlendingRanges blendingRanges = LayerBlendingRangesReader.Read(reader);
            string      name      = reader.ReadPascalString(4);
            IProperties resources = new LayerResourceReader(reader, this.EndPosition - reader.Position);

            records.SetExtraRecords(mask, blendingRanges, resources, name);
            value = records;
        }
Ejemplo n.º 3
0
        public void SetExtraRecords(LayerMask layerMask, LayerBlendingRanges blendingRanges, IProperties resources, string name)
        {
            this.layerMask      = layerMask;
            this.blendingRanges = blendingRanges;
            this.resources      = resources;
            this.name           = name;


            this.resources.TryGetValue <string>(ref this.name, "luni.Name");
            this.resources.TryGetValue <SectionType>(ref this.sectionType, "lsct.SectionType");

            if (SectionType == SectionType.Divider)
            {
                layerType = LayerType.Divider;
            }
            else if (SectionType == SectionType.Closed || SectionType == SectionType.Opend)
            {
                layerType = LayerType.Group;
            }
            else if (this.resources.Contains("SoLd.Idnt") == true)
            {
                this.placedID = this.resources.ToGuid("SoLd.Idnt");
                layerType     = LayerType.Normal;
            }
            else if (this.resources.Contains("SoLE.Idnt") == true)
            {
                this.placedID = this.resources.ToGuid("SoLE.Idnt");
                throw new Exception("WaitDefine");
            }
            else if (this.resources.Contains("TySh.Idnt"))
            {
                Readers.LayerResources.Reader_TySh reader = resources["TySh"] as Readers.LayerResources.Reader_TySh;
                DescriptorStructure text = null;
                if (reader.TryGetValue <DescriptorStructure>(ref text, "Text"))
                {
                    textinfo = new TextInfo(text);
                }

                layerType = LayerType.Text;
            }
            else
            {
                layerType = LayerType.SolidImage;
            }

            foreach (var item in this.channels)
            {
                switch (item.Type)
                {
                case ChannelType.Mask:
                {
                    if (this.layerMask != null)
                    {
                        item.Width  = this.layerMask.Width;
                        item.Height = this.layerMask.Height;
                    }
                }
                break;

                case ChannelType.Alpha:
                {
                    if (this.resources.Contains("iOpa") == true)
                    {
                        byte opa = this.resources.ToByte("iOpa", "Opacity");
                        item.Opacity = opa / 255.0f;
                    }
                }
                break;
                }
            }
        }