Hello,
I'm trying to build a plug-in that will delete (turn alpha to 0) Any Similarity/Differences between two images.
At the moment the problem I'm having is an error in the bitmap loading.
Hidden Content:
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using PaintDotNet.Effects;
using PaintDotNet;
using System.IO;
namespace EffectsPluginTemplate1
{
public class EffectPluginConfigDialog : PaintDotNet.Effects.EffectConfigDialog
{
private Button buttonOK;
private OpenFileDialog openFileDialog1;
private ComboBox comboBox1;
private Button ButtonBrowse;
private Button buttonCancel;
public EffectPluginConfigDialog()
{
InitializeComponent();
}
protected override void InitialInitToken()
{
theEffectToken = new EffectPluginConfigToken();
}
protected override void InitTokenFromDialog()
{
// ((EffectPluginConfigToken)EffectToken).variable = dialogVariable;
}
protected override void InitDialogFromToken(EffectConfigToken effectToken)
{
// EffectPluginConfigToken token = (EffectPluginConfigToken)effectToken;
// dialogVariable = token.variable;
}
private void InitializeComponent()
{
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.ButtonBrowse = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.Location = new System.Drawing.Point(324, 249);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 1;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.Location = new System.Drawing.Point(243, 249);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 2;
this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
this.openFileDialog1.FileOk += new System.ComponentModel.CancelEventHandler(this.openFileDialog1_FileOk);
//
// comboBox1
//
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(12, 12);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(306, 21);
this.comboBox1.TabIndex = 3;
//
// ButtonBrowse
//
this.ButtonBrowse.Location = new System.Drawing.Point(324, 12);
this.ButtonBrowse.Name = "ButtonBrowse";
this.ButtonBrowse.Size = new System.Drawing.Size(75, 21);
this.ButtonBrowse.TabIndex = 4;
this.ButtonBrowse.Text = "Browse";
this.ButtonBrowse.UseVisualStyleBackColor = true;
this.ButtonBrowse.Click += new System.EventHandler(this.button1_Click);
//
// EffectPluginConfigDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.ClientSize = new System.Drawing.Size(411, 284);
this.Controls.Add(this.ButtonBrowse);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.Location = new System.Drawing.Point(0, 0);
this.Name = "EffectPluginConfigDialog";
this.Controls.SetChildIndex(this.buttonCancel, 0);
this.Controls.SetChildIndex(this.buttonOK, 0);
this.Controls.SetChildIndex(this.comboBox1, 0);
this.Controls.SetChildIndex(this.ButtonBrowse, 0);
this.ResumeLayout(false);
}
private void buttonOK_Click(object sender, EventArgs e)
{
FinishTokenUpdate();
DialogResult = DialogResult.OK;
this.Close();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
using (myStream)
{
Bitmap loadedBmp = new Bitmap(Image.FromFile(myStream));
Surface imgSurface = Surface.FromBitmap(loadedBmp);
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
}
}
}
Here are the errors:
"Error 1 The best overloaded method match for 'System.Drawing.Image.FromFile(string)' has some invalid arguments."
"Error 2 Argument '1': cannot convert from 'System.IO.Stream' to 'string'"
"Error 3 'PaintDotNet.Surface' does not contain a definition for 'FromBitmap'"
BTW I'm a noob to Plug-in coding but I've had a fair amount of experience in coding using a language which syntax highly similar to C#'s syntax (Yes i learned GML ).
If anyone has a plug-in coding guide for Microsoft Visual C# 2008 express edition please don't hesitate to tell me .