Exemplo n.º 1
0
        private void ProcessCompressedPart(MemoryStream stream)
        {
            BinaryReader reader = new BinaryReader(stream);

            try
            {
                byte[] rect;
                int    nbits, totalBits, totalBytes;
                nbits      = reader.ReadByte() >> 3;
                totalBits  = nbits * 4 + 5;
                totalBytes = totalBits / 8;
                if (totalBits % 8 != 0)
                {
                    totalBytes++;
                }
                reader.BaseStream.Seek(-1, SeekOrigin.Current);
                rect       = reader.ReadBytes(totalBytes);
                frameRate  = float.Parse(string.Format("{1}.{0}", reader.ReadByte(), reader.ReadByte()));
                frameCount = Convert.ToInt32(reader.ReadInt16());
                BitArray bits         = new BitArray(rect);
                bool[]   reversedBits = new bool[bits.Length];
                for (int i = 0; i < totalBytes; i++)
                {
                    int count = 7;
                    for (int j = 8 * i; j < 8 * (i + 1); j++)
                    {
                        reversedBits[j + count] = bits[j];
                        count -= 2;
                    }
                }
                bits = new BitArray(reversedBits);
                StringBuilder sbField = new StringBuilder(bits.Length);
                for (int i = 0; i < bits.Length; i++)
                {
                    sbField.Append(bits[i] ? "1" : "0");
                }
                string result       = sbField.ToString();
                string widthBinary  = result.Substring(nbits + 5, nbits);
                string heightBinary = result.Substring(3 * nbits + 5, nbits);
                width  = Convert.ToInt32(FlashInfo.BinaryToInt64(widthBinary) / 20);
                height = Convert.ToInt32(FlashInfo.BinaryToInt64(heightBinary) / 20);
            }
            finally
            {
                reader.Close();
            }
        }
Exemplo n.º 2
0
        public void SetFormedioPathChange(MediaFileType mediaType)
        {
            string resourceId = SiteResourceService.SelectResource(mediaType, this);

            if (resourceId != null)
            {
                SdsiteXmlDocument      doc     = Service.Sdsite.CurrentDocument;
                FileSimpleExXmlElement fileEle = doc.GetElementById(resourceId) as FileSimpleExXmlElement;
                pathTextBox.Text = fileEle.AbsoluteFilePath;
                try
                {
                    flashInfo = new FlashInfo(fileEle.AbsoluteFilePath);
                }
                catch
                { }
                if (flashInfo != null)
                {
                    widthNumUpDown.Value  = flashInfo.Width;
                    heightNumUpDown.Value = flashInfo.Height;
                    ratio = widthNumUpDown.Value / heightNumUpDown.Value;
                    limitScaleCheckBox.Visible = true;
                    limitScaleCheckBox.Enabled = true;
                }
                else
                {
                    widthNumUpDown.Value       = 100;
                    heightNumUpDown.Value      = 100;
                    limitScaleCheckBox.Visible = false;
                }
                widthUintComboBox.SelectedIndex = heightUintComboBox.SelectedIndex = 0;

                //设置窗体的一些默认值
                this.widthCheckBox.Checked    = true;
                this.heightCheckBox.Checked   = true;
                this.loopCheckBox.Checked     = true;
                this.autoPlayCheckBox.Checked = true;

                this.MediaID = resourceId;
            }
        }