イメージから削除する必要がある矩形のディメンションを持つイメージがあります。イメージ処理ライブラリを使用してイメージを削除する方法はありますかC#で利用可能な、またはこの要件の参照の任意の種類が私に知らせると助けてください 私は問題文の画像を添付しています。 イメージの一部を削除してCの部分の上に移動する方法
私は画像を持っており、処理後にB画像が必要なのですが、どうすればいいのですか。 ありがとうございました
イメージから削除する必要がある矩形のディメンションを持つイメージがあります。イメージ処理ライブラリを使用してイメージを削除する方法はありますかC#で利用可能な、またはこの要件の参照の任意の種類が私に知らせると助けてください 私は問題文の画像を添付しています。 イメージの一部を削除してCの部分の上に移動する方法
私は画像を持っており、処理後にB画像が必要なのですが、どうすればいいのですか。 ありがとうございました
グラフィックオブジェクトとビットマップクラスを使用することをお勧めします。
このApprochの重要な設定はGraphics.ComposingModeです。デスティネーションとソースビットマップへの最初の描画では、SourceCopyに設定する必要があります。宛先への2回目の描画では、SourceOverに設定する必要があります。 https://msdn.microsoft.com/de-de/library/system.drawing.drawing2d.compositingmode(v=vs.110).aspx
さらに、両方のビットマップにはアルファチャンネルのpixelFormatが必要です。 Format32bppArgb https://msdn.microsoft.com/de-de/library/system.drawing.imaging.pixelformat(v=vs.110).aspx
は、だから私は何をやっている:
イム小さなものに大きな絵を描きます。底部が切り取られます。
上の部分を透明にして、負のy座標で画像を描画します。これにより、画像の下部が最初の描画から残りの可視部分に貼り付けられます。
この紹介に問題がある場合は、お気軽にお問い合わせください。
EDIT:私は自分自身を試しているように感じました...ここでは作業コードだ:
int cropFromY = 240;
int cropToY = 334;
// Change location if required...
using (FileStream fs = new FileStream(@"D:\Test\pic.png", FileMode.Open, FileAccess.Read))
{
// Step 1
// load Bitmap from File
var loadedBitmap = new Bitmap(fs);
// Step 1 (extended)
// As the loadedBitmap might have a wrong PixelFormat, we convert it to have an Alpha channel
var source = new Bitmap(loadedBitmap.Width, loadedBitmap.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (Graphics gSource = Graphics.FromImage(source))
{
gSource.DrawImageUnscaled(loadedBitmap, 0, 0);
}
// Step 2
// Create destination Picture
var destination = new Bitmap(source.Width, source.Height - (cropToY - cropFromY), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
// Step 3
// Create the two graphics objects
using (Graphics gSource = Graphics.FromImage(source))
{
using (Graphics gDestination = Graphics.FromImage(destination))
{
// Step 4
// Copy picture source to destination => Crop Bottom
gDestination.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
gDestination.DrawImageUnscaled(source, 0, 0);
// Step 5
// Make the top part (which is already drawn to the destination) transparent
gSource.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
gSource.FillRectangle(Brushes.Transparent, new Rectangle(0, 0, source.Width, cropToY));
// Step 6
// Draw the source bitmap to the destination picture again, but this time you locate it at 0/-(y3-y1)
gDestination.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
gDestination.DrawImageUnscaled(source, 0, -(cropToY - cropFromY));
// Step 7
// Save new picture. Change location if required...
destination.Save(@"D:\Test\pic2.png");
}
}
}
オリジナル:
結果の画像:
乾杯トーマスこれらの素晴らしい手順について
おかげでトーマス。 私は確かにステップを踏んで行くでしょう、もしこれが答えられたら –