コード例 #1
0
        public byte[] ToBytes()
        {
            long qntBytesImagem = this.Altura * this.Largura;

            qntBytesImagem = (qntBytesImagem / 8) + (qntBytesImagem % 8 == 0 ? 0 : 1);

            unsafe
            {
                Byte[] resultado = new Byte[sizeof(FormatoVideo02) + qntBytesImagem - sizeof(uint)];

                fixed(byte *pSrc = resultado)
                {
                    FormatoVideo02 *video = (FormatoVideo02 *)pSrc;

                    video->versao = Convert.ToByte(this.versao);
                    for (int i = 0; i < 3; i++)
                    {
                        video->formato[i] = this.Formato[i];
                    }
                    video->animacao          = Convert.ToByte(this.animacao);
                    video->alinhamento       = Convert.ToByte(this.alinhamento);
                    video->largura           = this.Largura;
                    video->altura            = this.Altura;
                    video->intervaloAnimacao = (UInt16)this.tempoRolagem;
                    video->tempoApresentacao = (UInt16)this.tempoApresentacao;

                    //código original. todo: a testar.
                    //video->Tamanho = (uint)(resultado.Length + this.pixelBytes.Length);
                    video->Tamanho = (uint)(resultado.Length);

                    byte *temp = (byte *)&video->pixelBytes;

                    for (int i = 0; i < this.pixelBytes.Length; i++)
                    {
                        temp[i] = (byte)this.pixelBytes[i];
                    }
                }

                return(resultado);
            }
        }
コード例 #2
0
        public void LoadFromBytes(byte[] dados)
        {
            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    tamanho = (UInt32)dados.Length;
                    FormatoVideo02 *vid = (FormatoVideo02 *)pSrc;

                    this.versao = vid->versao;

                    this.Formato = new byte[3];

                    for (int i = 0; i < 3; i++)
                    {
                        Formato[i] = vid->formato[i];
                    }


                    this.animacao          = vid->animacao;
                    this.alinhamento       = vid->alinhamento;
                    this.tempoRolagem      = vid->intervaloAnimacao;
                    this.tempoApresentacao = vid->tempoApresentacao;
                    this.Largura           = vid->largura;
                    this.Altura            = vid->altura;
                    this.pixelBytes        = new byte[dados.Length - sizeof(FormatoVideo02) + sizeof(UInt32)];

                    byte *temp = (byte *)&vid->pixelBytes;

                    for (int i = 0; i < this.pixelBytes.Length; i++)
                    {
                        this.pixelBytes[i] = temp[i];
                    }
                }
            }
        }