public static Image AnnotateImage(Image img, bool allowSave, string configPath, Action <Image> clipboardCopyRequested, Action <Image> imageUploadRequested) { if (!IniConfig.isInitialized) { IniConfig.AllowSave = allowSave; IniConfig.Init(configPath); } using (Image cloneImage = (Image)img.Clone()) using (ICapture capture = new Capture { Image = cloneImage }) using (Surface surface = new Surface(capture)) using (ImageEditorForm editor = new ImageEditorForm(surface, true)) { editor.ClipboardCopyRequested += clipboardCopyRequested; editor.ImageUploadRequested += imageUploadRequested; if (editor.ShowDialog() == DialogResult.OK) { using (img) { return(editor.GetImageForExport()); } } } return(img); }
private void ImageEditorAction(object sender, EventArgs e) { int ImageIndex = imagesCB.SelectedIndex; if (ImageIndex != -1) { var image = ActiveFile.FontSection.TextureGlyph.GetImageSheet(ImageIndex); bool IsBntx = ActiveFile.FontSection.TextureGlyph.BinaryTextureFile != null; ImageEditorForm form = new ImageEditorForm(true); form.editorBase.Text = Text; form.editorBase.Dock = DockStyle.Fill; if (ActiveFile.Platform >= FFNT.PlatformType.Cafe) { image.Parameters.FlipY = true; } if (IsBntx) { form.editorBase.LoadProperties(((TextureData)image).Texture); form.editorBase.LoadImage(image, ImageIndex); } else { form.editorBase.LoadProperties(image.GenericProperties); form.editorBase.LoadImage(image); } if (form.ShowDialog() == DialogResult.OK) { UpdateImagePanel(ImageIndex); } } }
/// <summary> /// Edit an address /// </summary> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { var converter = Default <ImageTypeConverter> .Instance; var image = (Image)converter.ConvertTo(value, typeof(Image)); using (var dialog = new ImageEditorForm(image)) { if (dialog.ShowDialog() != DialogResult.OK) { return(value); } return(converter.ConvertFrom(dialog.Image)); } }
public static Image AnnotateImage(Image img, string imgPath, bool allowSave, string configPath, Action <Image> clipboardCopyRequested, Action <Image> imageUploadRequested, Action <Image, string> imageSaveRequested, Func <Image, string, string> imageSaveAsRequested, Action <Image> printImageRequested) { if (!IniConfig.isInitialized) { IniConfig.AllowSave = allowSave; IniConfig.Init(configPath); } using (Image cloneImage = img != null ? (Image)img.Clone() : LoadImage(imgPath)) using (ICapture capture = new Capture { Image = cloneImage }) using (Surface surface = new Surface(capture)) using (ImageEditorForm editor = new ImageEditorForm(surface, true)) { editor.IsTaskWork = img != null; editor.SetImagePath(imgPath); editor.ClipboardCopyRequested += clipboardCopyRequested; editor.ImageUploadRequested += imageUploadRequested; editor.ImageSaveRequested += imageSaveRequested; editor.ImageSaveAsRequested += imageSaveAsRequested; editor.PrintImageRequested += printImageRequested; DialogResult result = editor.ShowDialog(); if (result == DialogResult.OK && editor.IsTaskWork) { using (img) { return(editor.GetImageForExport()); } } if (result == DialogResult.Abort) { return(null); } } return(img); }