コード例 #1
0
ファイル: Mask.cs プロジェクト: AOx0/unity-EstoNoEsHillClimb
        public MaskInfo(PsdBinaryReader reader, Layer layer)
        {
            Util.DebugMessage(reader.BaseStream, "Load, Begin, MaskInfo");

            var maskLength = reader.ReadUInt32();

            if (maskLength <= 0)
            {
                return;
            }

            var startPosition = reader.BaseStream.Position;
            var endPosition   = startPosition + maskLength;

            // Read layer mask
            var rectangle       = reader.ReadRectangle();
            var backgroundColor = reader.ReadByte();
            var flagsByte       = reader.ReadByte();

            LayerMask = new Mask(layer, rectangle, backgroundColor, new BitVector32(flagsByte));

            // User mask is supplied separately when there is also a vector mask.
            if (maskLength == 36)
            {
                var userFlagsByte       = reader.ReadByte();
                var userBackgroundColor = reader.ReadByte();
                var userRectangle       = reader.ReadRectangle();
                UserMask = new Mask(layer, userRectangle, userBackgroundColor, new BitVector32(userFlagsByte));
            }

            // 20-byte mask data will end with padding.
            reader.BaseStream.Position = endPosition;

            Util.DebugMessage(reader.BaseStream, "Load, End, MaskInfo");
        }
コード例 #2
0
        public BevelEffect(PsdBinaryReader r, string key)
        {
            m_key = key;

            uint version = r.ReadUInt32();

            this.Angle    = r.ReadUInt32();
            this.Strength = r.ReadUInt32();
            this.Blur     = r.ReadUInt32();

            this.BlendModeKey       = this.ReadBlendKey(r);
            this.ShadowBlendModeKey = this.ReadBlendKey(r);

            this.Color       = r.ReadPSDColor(16, true);
            this.ShadowColor = r.ReadPSDColor(16, true);

            this.BevelStyle    = r.ReadByte();
            this.Opacity       = r.ReadByte();
            this.ShadowOpacity = r.ReadByte();

            this.Enabled        = r.ReadBoolean();
            this.UseGlobalAngle = r.ReadBoolean();
            this.Inverted       = r.ReadBoolean();

            switch (version)
            {
            case 0:
                break;

            case 2:
                Color someColor  = r.ReadPSDColor(16, true);
                Color someColor2 = r.ReadPSDColor(16, true);
                break;
            }
        }
コード例 #3
0
        public MaskInfo(PsdBinaryReader reader, Layer layer)
        {
            Debug.WriteLine("MaskInfo started at " + reader.BaseStream.Position.ToString(CultureInfo.InvariantCulture));

            var maskLength = reader.ReadUInt32();

            if (maskLength <= 0)
            {
                return;
            }

            var startPosition = reader.BaseStream.Position;
            var endPosition   = startPosition + maskLength;

            // Read layer mask
            var rectangle       = reader.ReadRectangle();
            var backgroundColor = reader.ReadByte();
            var flagsByte       = reader.ReadByte();

            LayerMask = new Mask(layer, rectangle, backgroundColor, new BitVector32(flagsByte));

            // User mask is supplied separately when there is also a vector mask.
            if (maskLength == 36)
            {
                var userFlagsByte       = reader.ReadByte();
                var userBackgroundColor = reader.ReadByte();
                var userRectangle       = reader.ReadRectangle();
                UserMask = new Mask(layer, userRectangle, userBackgroundColor,
                                    new BitVector32(userFlagsByte));
            }

            // 20-byte mask data will end with padding.
            reader.BaseStream.Position = endPosition;
        }
コード例 #4
0
        public GlowEffect(PsdBinaryReader r, string key)
        {
            m_key = key;
            uint version = r.ReadUInt32(); //two version

            this.Blur      = r.ReadUInt32();
            this.Intensity = r.ReadUInt32();
            Color golwColor = readColor(r);

            this.BlendModeKey = this.ReadBlendKey(r);
            this.Enabled      = r.ReadBoolean();
            this.Opacity      = r.ReadByte();
            this.Color        = Util.FromArgb(Opacity, golwColor);

            switch (version)
            {
            case 0:

                break;

            case 2:
                //TODO!
                if (this.Inner)
                {
                    this.Unknown = r.ReadByte();
                }
                this.UnknownColor = r.ReadPSDColor(16, true);     //unknown color
//                    byte[] Data = r.ReadBytes((int)r.BytesToEnd);
                break;
            }
        }
コード例 #5
0
ファイル: TextLayerInfo.cs プロジェクト: koppepan/PsdPlugin
        private Color ReadColor(PsdBinaryReader reader)
        {
            var color = new Color();

            color.a = reader.ReadFloat();
            reader.ReadByte();
            color.r = reader.ReadFloat();
            reader.ReadByte();
            color.g = reader.ReadFloat();
            reader.ReadByte();
            color.b = reader.ReadFloat();

            return(color);
        }
コード例 #6
0
ファイル: TextLayerInfo.cs プロジェクト: koppepan/PsdPlugin
        public TextLayerInfo(PsdBinaryReader reader)
        {
            reader.Seek("TEXT");
            Text = reader.ReadUnicodeString();

            reader.Seek("/Justification ");
            int alignment = reader.ReadByte() - 48;

            Alignment = TextAnchor.MiddleLeft;
            if (alignment == 1)
            {
                Alignment = TextAnchor.MiddleRight;
            }
            else if (alignment == 2)
            {
                Alignment = TextAnchor.MiddleCenter;
            }

            reader.Seek("/FontSize ");
            FontSize = reader.ReadFloat();

            reader.Seek("/FillColor");
            reader.Seek("/Values [ ");
            FillColor = ReadColor(reader);
        }
コード例 #7
0
        public ShadowEffect(PsdBinaryReader r, string key)
        {
            m_key = key;
            int version = r.ReadInt32();

            this.Blur      = r.ReadUInt32();
            this.Intensity = r.ReadUInt32();
            this.Angle     = r.ReadUInt32();
            this.Distance  = r.ReadUInt32();
            Color shadowColor = r.ReadPSDColor(16, true);

            this.BlendModeKey   = this.ReadBlendKey(r);
            this.Enabled        = r.ReadBoolean();
            this.UseGlobalAngle = r.ReadBoolean();
            this.Opacity        = r.ReadByte();
            NativeColor         = r.ReadPSDColor(16, true);

            this.Color = Util.FromArgb(Opacity, shadowColor);
        }
コード例 #8
0
ファイル: Mask.cs プロジェクト: hgrandry/Mgx
        public MaskInfo(PsdBinaryReader reader, Layer layer)
        {
            Debug.WriteLine("MaskInfo started at " + reader.BaseStream.Position.ToString(CultureInfo.InvariantCulture));

            var maskLength = reader.ReadUInt32();
            if (maskLength <= 0)
                return;

            var startPosition = reader.BaseStream.Position;
            var endPosition = startPosition + maskLength;

            // Read layer mask
            var rectangle = reader.ReadRectangle();
            var backgroundColor = reader.ReadByte();
            var flagsByte = reader.ReadByte();
            LayerMask = new Mask(layer, rectangle, backgroundColor, new BitVector32(flagsByte));

            // User mask is supplied separately when there is also a vector mask.
            if (maskLength == 36)
            {
                var userFlagsByte = reader.ReadByte();
                var userBackgroundColor = reader.ReadByte();
                var userRectangle = reader.ReadRectangle();
                UserMask = new Mask(layer, userRectangle, userBackgroundColor,
                  new BitVector32(userFlagsByte));
            }

            // 20-byte mask data will end with padding.
            reader.BaseStream.Position = endPosition;
        }
コード例 #9
0
        public Layer(PsdBinaryReader reader, PsdFile psdFile)
            : this(psdFile)
        {
            Util.DebugMessage(reader.BaseStream, "Load, Begin, Layer");

            Rect = reader.ReadRectangle();

            //-----------------------------------------------------------------------
            // Read channel headers.  Image data comes later, after the layer header.

            int numberOfChannels = reader.ReadUInt16();
            for (int channel = 0; channel < numberOfChannels; channel++)
            {
                var ch = new Channel(reader, this);
                Channels.Add(ch);
            }

            //-----------------------------------------------------------------------
            //

            var signature = reader.ReadAsciiChars(4);
            if (signature != "8BIM")
            {
                throw (new PsdInvalidException("Invalid signature in layer header."));
            }

            BlendModeKey = reader.ReadAsciiChars(4);
            Opacity      = reader.ReadByte();
            Clipping     = reader.ReadBoolean();

            var flagsByte = reader.ReadByte();
            flags = new BitVector32(flagsByte);
            reader.ReadByte(); //padding

            //-----------------------------------------------------------------------

            // This is the total size of the MaskData, the BlendingRangesData, the
            // Name and the AdjustmentLayerInfo.
            var extraDataSize          = reader.ReadUInt32();
            var extraDataStartPosition = reader.BaseStream.Position;

            Masks = new MaskInfo(reader, this);
            BlendingRangesData = new BlendingRanges(reader, this);
            Name = reader.ReadPascalString(4);

            //-----------------------------------------------------------------------
            // Process Additional Layer Information

            long adjustmentLayerEndPos = extraDataStartPosition + extraDataSize;
            while (reader.BaseStream.Position < adjustmentLayerEndPos)
            {
                var layerInfo = LayerInfoFactory.Load(reader,
                                                      psdFile: this.PsdFile,
                                                      globalLayerInfo: false);
                AdditionalInfo.Add(layerInfo);
            }

            foreach (var adjustmentInfo in AdditionalInfo)
            {
                switch (adjustmentInfo.Key)
                {
                case "luni":
                    Name = ((LayerUnicodeName)adjustmentInfo).Name;
                    break;
                }
            }

            Util.DebugMessage(reader.BaseStream, "Load, End, Layer, {0}", Name);

            PsdFile.LoadContext.OnLoadLayerHeader(this);
        }
コード例 #10
0
ファイル: LayerTextType.cs プロジェクト: lwx1010/2D_XProject
        public LayerTextType(PsdBinaryReader reader)
        {
            version   = reader.ReadUInt16();           // 1 = Photoshop 5.0
            transform = new Matrix2D(reader);

            //Font info:
            // fontVersion
            reader.ReadUInt16();             // 6 = Photoshop 5.0
            ushort faceCount = reader.ReadUInt16();

            fontInfos = new List <FontInfo>();
            for (int i = 0; i < faceCount; i++)
            {
                fontInfos.Add(new FontInfo(reader));
            }

            //TODO: make classes of styles as well...
            ushort styleCount = reader.ReadUInt16();

            for (int i = 0; i < styleCount; i++)
            {
                // mark
                reader.ReadUInt16();
                // faceMark
                reader.ReadUInt16();
                // size
                reader.ReadUInt32();
                // tracking
                reader.ReadUInt32();
                // kerning
                reader.ReadUInt32();
                // leading
                reader.ReadUInt32();
                // baseShift
                reader.ReadUInt32();

                // autoKern
                reader.ReadByte();

                if (version <= 5)
                {
                    // extra
                    reader.ReadByte();
                }

                // rotate
                reader.ReadByte();
            }

            //Text information
            // type
            reader.ReadUInt16();
            // scalingFactor
            reader.ReadUInt32();
            // characterCount
            reader.ReadUInt32();
            // horizontalPlacement
            reader.ReadUInt32();
            // verticalPlacement
            reader.ReadUInt32();
            // selectStart
            reader.ReadUInt32();
            // selectEnd
            reader.ReadUInt32();

            ushort lineCount = reader.ReadUInt16();

            for (int i = 0; i < lineCount; i++)
            {
                // characterCountLine
                reader.ReadUInt32();
                // orientation
                reader.ReadUInt16();
                // alignment
                reader.ReadUInt16();
                // doubleByteChar
                reader.ReadUInt16();
                // style
                reader.ReadUInt16();
            }

            // colorSpace
            reader.ReadUInt16();
            for (int i = 0; i < 4; i++)
            {
                reader.ReadUInt16();                 //Color compensation
            }
            // antiAlias
            reader.ReadByte();
        }
コード例 #11
0
    public Layer(PsdBinaryReader reader, PsdFile psdFile)
      : this(psdFile)
    {
      Rect = reader.ReadRectangle();

      //-----------------------------------------------------------------------
      // Read channel headers.  Image data comes later, after the layer header.

      int numberOfChannels = reader.ReadUInt16();
      for (int channel = 0; channel < numberOfChannels; channel++)
      {
        var ch = new Channel(reader, this);
        Channels.Add(ch);
      }

      //-----------------------------------------------------------------------
      // 

      var signature = reader.ReadAsciiChars(4);
      if (signature != "8BIM")
        throw (new PsdInvalidException("Invalid signature in layer header."));

      BlendModeKey = reader.ReadAsciiChars(4);
      Opacity = reader.ReadByte();
      Clipping = reader.ReadBoolean();

      var flagsByte = reader.ReadByte();
      flags = new BitVector32(flagsByte);
      reader.ReadByte(); //padding

      //-----------------------------------------------------------------------

      // This is the total size of the MaskData, the BlendingRangesData, the 
      // Name and the AdjustmentLayerInfo.
      var extraDataSize = reader.ReadUInt32();
      var extraDataStartPosition = reader.BaseStream.Position;

      Masks = new MaskInfo(reader, this);
      BlendingRangesData = new BlendingRanges(reader, this);
      Name = reader.ReadPascalString(4);

      //-----------------------------------------------------------------------
      // Process Additional Layer Information

      long adjustmentLayerEndPos = extraDataStartPosition + extraDataSize;
      while (reader.BaseStream.Position < adjustmentLayerEndPos)
      {
        var layerInfo = LayerInfoFactory.Load(reader);
        AdditionalInfo.Add(layerInfo);
      }

      foreach (var adjustmentInfo in AdditionalInfo)
      {
        switch (adjustmentInfo.Key)
        {
          case "luni":
            Name = ((LayerUnicodeName)adjustmentInfo).Name;
            break;
        }
      }

    }
コード例 #12
0
        public Layer(PsdBinaryReader reader, PsdFile psdFile)
            : this(psdFile)
        {
            IsText = false;
            Rect   = reader.ReadRectangle();

            //-----------------------------------------------------------------------
            // Read channel headers.  Image data comes later, after the layer header.

            int numberOfChannels = reader.ReadUInt16();
            for (int channel = 0; channel < numberOfChannels; channel++)
            {
                var ch = new Channel(reader, this);
                Channels.Add(ch);
            }

            //-----------------------------------------------------------------------
            //

            var signature = reader.ReadAsciiChars(4);
            if (signature != "8BIM")
            {
                throw (new PsdInvalidException("Invalid signature in layer header."));
            }

            BlendModeKey = reader.ReadAsciiChars(4);
            Opacity      = reader.ReadByte();
            Clipping     = reader.ReadBoolean();

            var flagsByte = reader.ReadByte();
            flags = new BitVector32(flagsByte);
            reader.ReadByte();             //padding

            //-----------------------------------------------------------------------

            // This is the total size of the MaskData, the BlendingRangesData, the
            // Name and the AdjustmentLayerInfo.
            var extraDataSize          = reader.ReadUInt32();
            var extraDataStartPosition = reader.BaseStream.Position;

            Masks = new MaskInfo(reader, this);
            BlendingRangesData = new BlendingRanges(reader, this);
            Name = reader.ReadPascalString(4);

            //-----------------------------------------------------------------------
            // Process Additional Layer Information

            long adjustmentLayerEndPos = extraDataStartPosition + extraDataSize;
            while (reader.BaseStream.Position < adjustmentLayerEndPos)
            {
                var layerInfo = LayerInfoFactory.Load(reader);
                AdditionalInfo.Add(layerInfo);
            }

            foreach (var adjustmentInfo in AdditionalInfo)
            {
                switch (adjustmentInfo.Key)
                {
                case "luni":
                    Name = ((LayerUnicodeName)adjustmentInfo).Name;
                    break;

                case "TySh":
                    IsText    = true;
                    LayerText = (LayerText)adjustmentInfo;
                    break;

                case "lrFX":
                    Effects = (EffectsLayer)adjustmentInfo;
                    break;

                case "lfx2":
                    BaseEffect = (ObjectBasedEffect)adjustmentInfo;
                    break;
                }
            }
        }