using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using AGVNavigationCore.Utils; using Newtonsoft.Json; using System; namespace AGVNavigationCore.Models { public class MapImage : NodeBase { [Category("기본 정보")] [Description("이미지의 이름입니다.")] public string Name { get; set; } = "Image"; [Category("이미지 설정")] [Description("이미지 파일 경로입니다 (편집기용).")] public string ImagePath { get; set; } = string.Empty; [ReadOnly(false)] public string ImageBase64 { get; set; } = string.Empty; [Category("이미지 설정")] [Description("이미지 크기 배율입니다.")] public SizeF Scale { get; set; } = new SizeF(1.0f, 1.0f); [Category("이미지 설정")] [Description("이미지 투명도입니다 (0.0 ~ 1.0).")] public float Opacity { get; set; } = 1.0f; [Category("이미지 설정")] [Description("이미지 회전 각도입니다.")] public float Rotation { get; set; } = 0.0f; [JsonIgnore] [Browsable(false)] public Image LoadedImage { get; set; } public MapImage() { Type = NodeType.Image; } public bool LoadImage() { try { Image originalImage = null; if (!string.IsNullOrEmpty(ImageBase64)) { originalImage = ImageConverterUtil.Base64ToImage(ImageBase64); } else if (!string.IsNullOrEmpty(ImagePath) && System.IO.File.Exists(ImagePath)) { originalImage = Image.FromFile(ImagePath); } if (originalImage != null) { LoadedImage?.Dispose(); LoadedImage = originalImage; // 리사이즈 필요시 추가 구현 return true; } } catch { // 무시 } return false; } public Size GetDisplaySize() { if (LoadedImage == null) return Size.Empty; return new Size( (int)(LoadedImage.Width * Scale.Width), (int)(LoadedImage.Height * Scale.Height) ); } public void Dispose() { LoadedImage?.Dispose(); LoadedImage = null; } } }