1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using FastReport.Dialog;
- using System.Drawing;
- using System.IO;
- namespace FastReport.Web
- {
- public partial class Dialog
- {
- private string GetPictureBoxHtml(PictureBoxControl control)
- {
- return $"<div style=\"{GetPictureBoxStyle(control)}\"></div>";
- }
- private string GetPictureBoxStyle(PictureBoxControl control)
- {
- return $"{GetControlPosition(control)} {GetControlAlign(control)} {GetPictureBoxURL(control.Image)} padding:0;margin:0;";
- }
- private string GetPictureBoxURL(Image image)
- {
- #if !WASM
- int hash = image.GetHashCode();
- if (!_webReport.PictureCache.ContainsKey(hash.ToString()))
- {
- using (MemoryStream picStream = new MemoryStream())
- {
- image.Save(picStream, image.RawFormat);
- byte[] imageArray = new byte[picStream.Length];
- picStream.Position = 0;
- picStream.Read(imageArray, 0, (int)picStream.Length);
- _webReport.PictureCache.Add(hash.ToString(), imageArray);
- }
- }
- string url = WebUtils.ToUrl(_webReport.template_ROUTE_BASE_PATH, $"preview.getPicture?");
- return $"background: url('{url}reportId={_webReport.ID}&pictureId={hash}') no-repeat !important;-webkit-print-color-adjust:exact;";
- #else
- return "";
- #endif
- }
- }
- }
|