Paint Editor Applicationからリソース プロジェクトをダウンロードします。ただし、このアプリケーションのズームイン/アウト機能には問題があります。実行時に Zoom-In ボタンをクリックすると、drawArea も機能しているようです。画像が拡大され、スクロールバーが変更されました。画像サイズ: 1366x768
しかし、この画像をビットマップファイルに保存しようとすると. このビットマップのサイズは、最初のイメージよりも大きくなるようにサイズ変更されます。
/// <summary>
/// Draw graphic objects and group selection rectangle (optionally)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DrawArea_Paint(object sender, PaintEventArgs e)
{
Matrix mx = new Matrix();
mx.Translate(-ClientSize.Width / 2f, -ClientSize.Height / 2f, MatrixOrder.Append);
mx.Rotate(_rotation, MatrixOrder.Append);
mx.Translate(ClientSize.Width / 2f + _panX, ClientSize.Height / 2f + _panY, MatrixOrder.Append);
mx.Scale(_zoom, _zoom, MatrixOrder.Append);
e.Graphics.Transform = mx;
////Draw image here
}
画像にエクスポートするためのこれらのコード
public void ExportToFile(string filePath, ImageFormat imageFormat)
{
using (Bitmap b = new Bitmap(_drawArea.Width, _drawArea.Height))
{
using (Graphics g = Graphics.FromImage(b))
{
g.Clear(Color.White);
_drawArea.DeselectAll();
_drawArea.TheLayers.Draw(g);
b.Save(filePath, imageFormat);
}
}
}