Example #1
0
        public void AddImage(byte[] imgBuf, float height, float width, RPLFormat.Sizings sizing)
        {
            if (imgBuf == null || imgBuf.Length == 0)
            {
                sizing = RPLFormat.Sizings.Clip;
                imgBuf = PictureDescriptor.INVALIDIMAGEDATA;
            }
            OfficeImageHasher officeImageHasher = new OfficeImageHasher(imgBuf);

            byte[]    hash = officeImageHasher.Hash;
            int       num  = Word97Writer.ToTwips(height);
            int       num2 = Word97Writer.ToTwips(width);
            int       num3 = (int)this.m_dataStream.Position;
            ImageHash key  = new ImageHash(hash, sizing, num2, num);

            if (this.m_images.ContainsKey(key))
            {
                num3 = this.m_images[key];
            }
            else
            {
                PictureDescriptor pictureDescriptor = new PictureDescriptor(imgBuf, hash, num2, num, sizing, this.m_imgIndex);
                pictureDescriptor.Serialize(this.m_dataStream);
                this.m_imgIndex++;
                this.m_images.Add(key, num3);
            }
            this.m_charFormat.SetIsInlineImage(num3);
            this.WriteSpecialText("\u0001");
        }
        public override bool Equals(object obj)
        {
            ImageHash imageHash = (ImageHash)obj;

            if (this.m_sizing == imageHash.m_sizing && this.m_width == imageHash.m_width && this.m_height == imageHash.m_height && this.m_md4.Length == imageHash.m_md4.Length)
            {
                for (int i = 0; i < this.m_md4.Length; i++)
                {
                    if (this.m_md4[i] != imageHash.m_md4[i])
                    {
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }