Ejemplo n.º 1
0
 public VersionInfo(PsdBinaryReader reader, string name) : base(name)
 {
     Version           = reader.ReadUInt32();
     HasRealMergedData = reader.ReadBoolean();
     ReaderName        = reader.ReadUnicodeString();
     WriterName        = reader.ReadUnicodeString();
     FileVersion       = reader.ReadUInt32();
 }
Ejemplo n.º 2
0
        public ResolutionInfo(PsdBinaryReader reader, string name)
            : base(name)
        {
            this.HDpi             = new UFixed16_16(reader.ReadUInt32());
            this.HResDisplayUnit  = (ResUnit)reader.ReadInt16();
            this.WidthDisplayUnit = (Unit)reader.ReadInt16();

            this.VDpi              = new UFixed16_16(reader.ReadUInt32());
            this.VResDisplayUnit   = (ResUnit)reader.ReadInt16();
            this.HeightDisplayUnit = (Unit)reader.ReadInt16();
        }
Ejemplo n.º 3
0
        public Thumbnail(PsdBinaryReader psdReader, ResourceID id, string name, int numBytes)
            : base(psdReader, "8BIM", id, name, numBytes)
        {
            using (var memoryStream = new MemoryStream(Data))
            {
                using (var reader = new PsdBinaryReader(memoryStream, psdReader))
                {
                    const int HEADER_LENGTH  = 28;
                    var       format         = reader.ReadUInt32();
                    var       width          = reader.ReadUInt32();
                    var       height         = reader.ReadUInt32();
                    var       widthBytes     = reader.ReadUInt32();
                    var       size           = reader.ReadUInt32();
                    var       compressedSize = reader.ReadUInt32();
                    var       bitPerPixel    = reader.ReadUInt16();
                    var       planes         = reader.ReadUInt16();

                    // Raw RGB bitmal
                    if (format == 0)
                    {
                        Image = new Bitmap((int)width, (int)height, PixelFormat.Format24bppRgb);
                    }
                    // JPEG bitmap
                    else if (format == 1)
                    {
                        byte[] imgData = reader.ReadBytes(numBytes - HEADER_LENGTH);
                        using (MemoryStream stream = new MemoryStream(imgData))
                        {
                            var bitmap = new Bitmap(stream);
                            Image = (Bitmap)bitmap.Clone();
                        }

                        // Reverse BGR pixels from old thumbnail format
                        if (id == ResourceID.ThumbnailBgr)
                        {
                            //for(int y=0;y<m_thumbnailImage.Height;y++)
                            //  for (int x = 0; x < m_thumbnailImage.Width; x++)
                            //  {
                            //    Color c=m_thumbnailImage.GetPixel(x,y);
                            //    Color c2=Color.FromArgb(c.B, c.G, c.R);
                            //    m_thumbnailImage.SetPixel(x, y, c);
                            //  }
                        }
                    }
                    else
                    {
                        throw new PsdInvalidException("Unknown thumbnail format.");
                    }
                }
            }
        }