Exemplo n.º 1
0
        private RasterImage AddTextFooter(RasterImage image, string tag, int footerMaxHeight)
        {
            LeadRect bounds = LeadRect.Create(0, 0, image.Width, image.Height);

            using (var imageTag = CreateTextFooter(LeadSize.Create(bounds.Width, footerMaxHeight), tag))
            {
                bounds.Height += imageTag.Height;

                var bpp             = 24;
                var byteOrder       = RasterByteOrder.Bgr;
                var viewPerspective = RasterViewPerspective.TopLeft;

                if (image.ViewPerspective != viewPerspective)
                {
                    image.ChangeViewPerspective(viewPerspective);
                }

                if (image.BitsPerPixel != bpp || image.Order != byteOrder)
                {
                    var colorResCommand = new ColorResolutionCommand(
                        ColorResolutionCommandMode.InPlace,
                        bpp,
                        byteOrder,
                        RasterDitheringMethod.None,
                        ColorResolutionCommandPaletteFlags.Optimized,
                        null);
                    colorResCommand.Run(image);
                }

                RasterImage imageResult = new RasterImage(RasterMemoryFlags.Conventional, bounds.Width, bounds.Height, bpp, byteOrder, viewPerspective, null, null, 0);

                {
                    var combine = new CombineFastCommand(imageResult, bounds, LeadPoint.Create(0, 0), CombineFastCommandFlags.SourceCopy);
                    combine.Run(image);
                }

                {
                    var combine = new CombineFastCommand(imageResult, LeadRect.Create(bounds.X, image.Height, bounds.Width, bounds.Height - image.Height), LeadPoint.Create(0, 0), CombineFastCommandFlags.SourceCopy);
                    combine.Run(imageTag);
                }
                return(imageResult);
            }
        }
        public override void SetImageData(AnnContainer container, LeadRectD bounds, byte[] data)
        {
            if (_image == null)
            {
                return;
            }

            using (var ms = new MemoryStream(data))
            {
                using (var codecs = new RasterCodecs())
                {
                    using (var image = codecs.Load(ms))
                    {
                        if (image.ViewPerspective != _image.ViewPerspective)
                        {
                            image.ChangeViewPerspective(_image.ViewPerspective);
                        }

                        if (image.BitsPerPixel != _image.BitsPerPixel || image.Order != _image.Order)
                        {
                            var palette      = _image.GetPalette();
                            var paletteFlags = palette != null ? ColorResolutionCommandPaletteFlags.UsePalette : ColorResolutionCommandPaletteFlags.Optimized;

                            var colorResCommand = new ColorResolutionCommand(
                                ColorResolutionCommandMode.InPlace,
                                _image.BitsPerPixel,
                                _image.Order,
                                RasterDitheringMethod.None,
                                paletteFlags,
                                palette);
                            colorResCommand.Run(image);
                        }

                        var combine = new CombineFastCommand(_image, bounds.ToLeadRect(), LeadPoint.Create(0, 0), CombineFastCommandFlags.SourceCopy);
                        combine.Run(image);
                    }
                }
            }
        }