Пример #1
0
        public Thumbnail(ImageResource imgRes)
            : base(imgRes)
        {
            BinaryPSDReader reader = imgRes.GetDataReader();

            //m_bThumbnailFilled = true;

            this.Format         = reader.ReadInt32();
            this.Width          = reader.ReadInt32();
            this.Height         = reader.ReadInt32();
            this.WidthBytes     = reader.ReadInt32(); //padded row bytes (
            this.Size           = reader.ReadInt32(); //Total size widthbytes * height * planes
            this.CompressedSize = reader.ReadInt32(); //used for consistancy check
            this.BitPerPixel    = reader.ReadInt16();
            this.Planes         = reader.ReadInt16();

            int numBytes = (int)reader.BytesToEnd;

            byte[] buffer = reader.ReadBytes(numBytes);

            if (this.ID == 1033)
            {
                // BGR
                for (int n = 0; n < numBytes - 2; n += 3)
                {
                    byte tmp = buffer[n + 2];
                    buffer[n + 2] = buffer[n];
                    buffer[n]     = tmp;
                }
            }
            System.IO.MemoryStream stream = new System.IO.MemoryStream(buffer);
            this.Bitmap = new System.Drawing.Bitmap(stream);

            reader.Close();
        }
Пример #2
0
 public CorrectionRecord(BinaryPSDReader r)
 {
     this.Cyan = r.ReadInt16();
     this.Magenta = r.ReadInt16();
     this.Yellow = r.ReadInt16();
     this.Black = r.ReadInt16();
 }
Пример #3
0
            public MixerRecord(BinaryPSDReader r, int numChannels)
            {
                this.Channels = new List<short>();
                for (int i = 0; i < numChannels; i++)
                    this.Channels.Add(r.ReadInt16());

                this.Unknown = r.ReadInt16();
                this.Constant = r.ReadInt16();
            }
Пример #4
0
        public BrightnessContrast(BinaryPSDReader reader)
            : base(reader)
        {
            BinaryPSDReader r = this.GetDataReader();

            this.Brightness = r.ReadInt16();
            this.Contrast = r.ReadInt16();

            this.Data = null;
        }
Пример #5
0
        public ResolutionInfo(ImageResource imgRes) : base(imgRes)
        {
            //m_bResolutionInfoFilled = true;
            BinaryPSDReader reader = imgRes.GetDataReader();

            this.hRes      = reader.ReadInt16();
            this.hResUnit  = reader.ReadInt32();
            this.widthUnit = reader.ReadInt16();

            this.vRes       = reader.ReadInt16();
            this.vResUnit   = reader.ReadInt32();
            this.heightUnit = reader.ReadInt16();

            reader.Close();
        }
Пример #6
0
        public DisplayInfo(ImageResource imgRes)
            : base(imgRes)
        {
            BinaryPSDReader reader = imgRes.GetDataReader();

            this.ColorSpace = (ColorModes)reader.ReadInt16();
            for (int i = 0; i < 4; i++)
            {
                this.Color[i] = reader.ReadInt16();
            }

            this.Opacity = (short)Math.Max(0, Math.Min(100, (int)reader.ReadInt16()));
            this.kind    = reader.ReadByte() == 0?false:true;

            reader.Close();
        }
Пример #7
0
 public RangeSettings(BinaryPSDReader r)
 {
     this.Values = new List <short>();
     for (int i = 0; i < 3; i++)
     {
         this.Values.Add(r.ReadInt16());
     }
 }
Пример #8
0
 public Screen(BinaryPSDReader reader)
 {
     this.FrequenceValue         = reader.ReadSingle(); //TODO: fixed single
     this.FrequenceScale         = reader.ReadUInt16();
     this.Angle                  = reader.ReadSingle(); //TODO: fixed single
     this.ShapeCode              = reader.ReadInt16();
     reader.BaseStream.Position += 4;
     this.AccurateScreens        = reader.ReadBoolean();
     this.DefaultScreens         = reader.ReadBoolean();
 }
Пример #9
0
        public GradientMap(BinaryPSDReader reader)
            : base(reader)
        {
            BinaryPSDReader r = this.GetDataReader();

            ushort version = r.ReadUInt16();

            this.Reverse = r.ReadBoolean();
            this.Dither  = r.ReadBoolean();
            this.Name    = r.ReadPSDUnicodeString();
            r.JumpToEvenNthByte(2);

            ushort cnt = r.ReadUInt16();

            this.ColorStops = new List <ColorStop>();
            for (int i = 0; i < cnt; i++)
            {
                this.ColorStops.Add(new ColorStop(r));
            }

            cnt = r.ReadUInt16();
            this.TransparencyStops = new List <TransparencyStop>();
            for (int i = 0; i < cnt; i++)
            {
                this.TransparencyStops.Add(new TransparencyStop(r));
            }

            ushort expansionCount = r.ReadUInt16();

            if (expansionCount > 0)
            {
                this.Interpolation = r.ReadInt16();
            }

            ushort length = r.ReadUInt16();

            this.Mode       = r.ReadUInt16();
            this.RandomSeed = r.ReadUInt32();

            r.BaseStream.Position += 1;
            this.ShowTransparency  = r.ReadBoolean();

            r.BaseStream.Position += 1;
            this.UseVectorColor    = r.ReadBoolean();

            this.Roughness = r.ReadUInt32();

            this.ColorModel = r.ReadUInt16(); //ColorMode?!

            this.MinChannelValues = r.ReadPSDChannelValues(4);
            this.MaxChannelValues = r.ReadPSDChannelValues(4);

            this.Data = r.ReadBytes((int)r.BytesToEnd);
        }
Пример #10
0
        public HueSaturation(BinaryPSDReader reader)
            : base(reader)
        {
            BinaryPSDReader r = this.GetDataReader();

            ushort version = r.ReadUInt16();

            this.ColorizeMode      = r.ReadBoolean();
            r.BaseStream.Position += 1; //padding

            this.Settings = new List <HSLModifier>();
            if (version == 1)
            {
                this.Colorize            = new HSLModifier();
                this.Colorize.Hue        = (short)((int)r.ReadInt16() * 180 / 100);
                this.Colorize.Saturation = r.ReadInt16();
                this.Colorize.Lightness  = r.ReadInt16();

                for (int i = 0; i < 7; i++)
                {
                    HSLModifier hsl = new HSLModifier();
                    this.Settings.Add(hsl);
                    hsl.Hue = r.ReadInt16();
                }
                for (int i = 0; i < 7; i++)
                {
                    this.Settings[i].Saturation = r.ReadInt16();
                }
                for (int i = 0; i < 7; i++)
                {
                    this.Settings[i].Lightness = r.ReadInt16();
                }
            }
            else if (version == 2)
            {
                this.Colorize = new HSLModifier(r);

                HSLModifier hsl = new HSLModifier(r); //master
                this.Settings.Add(hsl);

                for (int i = 0; i < 6; i++)
                {
                    List <short> ranges = new List <short>();
                    for (int j = 0; j < 4; j++)
                    {
                        ranges.Add(r.ReadInt16());
                    }
                    hsl = new HSLModifier(r);
                    this.Settings.Add(hsl);
                    hsl.Ranges = ranges;
                }
            }

            this.Data = null;
        }
Пример #11
0
 public ColorTransferFunction(BinaryPSDReader reader)
 {
     this.Curve = new List <short>();
     for (int i = 0; i < 13; i++)
     {
         this.Curve.Add(reader.ReadInt16());
     }
     if (this.Curve[0] == -1 || this.Curve[12] == -1)
     {
         throw new Exception("Error");
     }
     this.Override = reader.ReadUInt16() > 0 ? true : false;
 }
Пример #12
0
 public HSLModifier(BinaryPSDReader r)
 {
     this.Hue = r.ReadInt16();
     this.Saturation = r.ReadInt16();
     this.Lightness = r.ReadInt16();
 }
 public ColorTransferFunction(BinaryPSDReader reader)
 {
     this.Curve = new List<short>();
     for (int i = 0; i < 13; i++)
     {
         this.Curve.Add(reader.ReadInt16());
     }
     if (this.Curve[0] == -1 || this.Curve[12] == -1)
         throw new Exception("Error");
     this.Override = reader.ReadUInt16() > 0 ? true : false;
 }
Пример #14
0
 public Screen(BinaryPSDReader reader)
 {
     this.FrequenceValue = reader.ReadSingle(); //TODO: fixed single
     this.FrequenceScale = reader.ReadUInt16();
     this.Angle = reader.ReadSingle(); //TODO: fixed single
     this.ShapeCode = reader.ReadInt16();
     reader.BaseStream.Position += 4;
     this.AccurateScreens = reader.ReadBoolean();
     this.DefaultScreens = reader.ReadBoolean();
 }