私はさまざまな方法で画像を編集するプログラムを持っている...私はthis.Invalidate()を実行するたびに呼び出されたPaintイベントを持っている...Paintイベント団体/設計上の問題
私のpaintメソッドのルックスこのように:
private void EditImage_Paint(object sender, PaintEventArgs e)
{
if (isLOaded == true)
{
Graphics graphicsWindow; // reference to the graphic surface of this window
Graphics graphicsImage; // reference to in-memory surface
theImage = new Bitmap(Width, Height); // bitmap for window surface copy
graphicsWindow = e.Graphics; // get our current window's surface
graphicsImage = Graphics.FromImage(theImage); // create surfaces from the bitmaps
graphicsImage.DrawImage(firstLoaded, 0, 0, Width, Height);
if (isInvert == true)
{
theImage = InvertBitmap(theImage);
}
else if (isGrayscale == true)
{
theImage = GrayscaleBitmap(theImage);
}
else if (isThreshold == true)
{
theImage = ThresholdBitmap(theImage);
}
else if (isResize == true)
{
theImage = resizeImage(theImage, 10, 100);
}
else if (isFilterRed == true)
{
theImage = FilterRedBitmap(theImage);
}
else if (isFilterGreen == true)
{
theImage = FilterGreenBitmap(theImage);
}
else if (isFilterBlue == true)
{
theImage = FilterBlueBitmap(theImage);
}
graphicsWindow.DrawImage(theImage, 0, 0);
}
}
(私のプログラムは、リサイズを使用して)私は.... Clickイベント内trueまたはfalseにいくつかのブール値を設定し、自分のコード内の別の領域を持っているので、私のプログラムが呼び出すためにどの方法を知っています。しかし、私はこれらのすべてをペイントの中に入れているのはちょっとしたデザインだと思う。私の問題は、ビットマップイメージをClickイベントに渡す方法がわからないことです。それは可能ですか?私はむしろ、ペイントメソッド内ではなくClickイベントで何が起こるかを扱うことになります。どのように私はこれをより良い設計することができますか?
しかし、私はこの行で使用するPaintEventArgsの必要性をどうやって解決しますか:graphicsWindow = e.Graphics?あなたは例を投稿できますか? – BigBug
最終的な画像をウィンドウに描画する場合を除いて、これを使用することは決してありません。すべてを取り除く。次に、イメージを事前に作成し、それをPictureBoxに配置します。 – SLaks