private void ApplyEncryptDecrypt(ScrambleCommandFlags flags, LeadRectD bounds, int key) { LeadRect rect = bounds.ToLeadRect(); LeadRect imageRect = LeadRect.Create(0, 0, _image.ImageWidth, _image.ImageHeight); flags |= ScrambleCommandFlags.Intersect; ScrambleCommand scrambleCommand = new ScrambleCommand(rect, key, flags); if (imageRect.Contains(rect)) { scrambleCommand.Run(_image); } }
private LeadRect BoundsFromAnnotations(AnnRectangleObject rectObject, AnnContainer container) { // Convert a rectangle from annotation object to logical coordinates (top-left) LeadRectD temp = container.Mapper.RectFromContainerCoordinates(rectObject.Rect, AnnFixedStateOperations.None); if (temp.IsEmpty) { return(LeadRect.Empty); } temp = _rasterImageViewer.ConvertRect(null, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, temp); LeadRect rect = temp.ToLeadRect(); return(rect); }
public override void Fill(AnnContainer container, LeadRectD bounds, string color) { if (_image == null) { return; } try { var fill = new FillCommand(RasterColor.Black); _image.AddRectangleToRegion(null, bounds.ToLeadRect(), RasterRegionCombineMode.Set); fill.Run(_image); } finally { _image.MakeRegionEmpty(); } }
public override byte[] GetImageData(AnnContainer container, LeadRectD bounds) { if (_image == null) { return(null); } using (var image = _image.Clone(bounds.ToLeadRect())) { using (var codecs = new RasterCodecs()) { using (var ms = new MemoryStream()) { codecs.Save(image, ms, RasterImageFormat.Png, Image.BitsPerPixel); return(ms.ToArray()); } } } }
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); } } } }
public override byte[] GetImageData(AnnContainer container, LeadRectD bounds) { if (_image == null) { return(null); } LeadRect rect = bounds.ToLeadRect(); rect = _image.RectangleToImage(RasterViewPerspective.TopLeft, rect); using (var image = _image.Clone(rect)) { using (var codecs = new RasterCodecs()) { using (var ms = new MemoryStream()) { codecs.Save(image, ms, RasterImageFormat.Png, Image.BitsPerPixel); return(ms.ToArray()); } } } }
private void ApplyEncryptDecrypt(ScrambleCommandFlags flags, LeadRectD bounds, int key) { LeadRect boundsInImage = _image.RectangleToImage(RasterViewPerspective.TopLeft, bounds.ToLeadRect()); LeadRect imageRect = LeadRect.Create(0, 0, _image.ImageWidth, _image.ImageHeight); flags |= ScrambleCommandFlags.Intersect; ScrambleCommand scrambleCommand = new ScrambleCommand(boundsInImage, key, flags); if (imageRect.Contains(boundsInImage)) { scrambleCommand.Run(_image); } }