Пример #1
0
        private void write(ImageObject obj)
        {
            // Get image details
            UInt16ArrayTag rect     = (UInt16ArrayTag)obj.FindFirstTag(TagId.ImageRect);
            UInt16ArrayTag size     = (UInt16ArrayTag)obj.FindFirstTag(TagId.ImageSize);
            UInt32Tag      streamId = (UInt32Tag)obj.FindFirstTag(TagId.ImageStream);
            int            x        = rect.Value[0];
            int            y        = rect.Value[1];
            int            w        = rect.Value[2];
            int            h        = rect.Value[3];

            ushort            imageId  = (ushort)streamId.Value;
            ImageStreamObject imageObj = (ImageStreamObject)book.FindObject(imageId);

            string type = ImageObject.getImageTypeAsString(imageObj.Contents);

            MemoryStream memStream = new MemoryStream(imageObj.Data);
            Bitmap       image     = new Bitmap(memStream);

            ImageInfo info = new ImageInfo();

            info.image    = image;
            info.position = new Rectangle(x, y, w, h);

            // @@IMAGENAME@@ will be replaced during save with the name of the file
            info.name = "@@IMAGENAME@@_" + (images.Count + 1);
            info.type = type;
            images.Add(info);

            handleImage(info);
        }