Imaging.cs
using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace CSharp_Imaging_Moire_Fringe
{
public sealed class Imaging
{
private static BitmapData _BitmapData = new BitmapData();
![]()

public static void Moire_Fringe( Bitmap ObjectBitmap )
{
try
{
if( ObjectBitmap == null )
{
return;
}

_BitmapData = ObjectBitmap.LockBits( new Rectangle( 0 , 0 , ObjectBitmap.Width , ObjectBitmap.Height ) , ImageLockMode.ReadWrite , PixelFormat.Format24bppRgb );
unsafe
{
byte* P = (byte *)_BitmapData.Scan0;

for( int i = 0 ; i < _BitmapData.Height / 2 ; i++ )
{
for( int j = 0 ; j < _BitmapData.Width / 2 ; j++ )
{
P += 3;
P[2] = P[1] = P[0] = 0;
P += 3;
}

for( int k = 0 ; k < _BitmapData.Width / 2 ; k++ )
{
P[2] = P[1] = P[0] = 0;
P += 6;
}
}
}
}
catch( Exception E )
{
System.Windows.Forms.MessageBox.Show( E.ToString() );
}
finally
{
ObjectBitmap.UnlockBits( _BitmapData );
}
}
#endregion
}
}
Form1.cs
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;

namespace CSharp_Imaging_Moire_Fringe
{
public class Form1 : System.Windows.Forms.Form
{
![]()
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.ComponentModel.IContainer components = null;

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

![]()
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(44, 38);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(256, 256);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// pictureBox2
//
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(332, 38);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(256, 256);
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox2.TabIndex = 1;
this.pictureBox2.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(632, 333);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "C# - Imaging - Moire Fringe";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}

[STAThread]
private static void Main()
{
Application.Run( new Form1() );
}

#endregion

private void Form1_Load( object sender, System.EventArgs e )
{
Imaging.Moire_Fringe( (Bitmap)pictureBox2.Image );
}
}
}
相关文章:
-
2022-12-23
-
2021-12-24
-
2021-08-16
-
2021-06-23
-
2021-07-16
-
2021-11-10
-
2021-12-14
-
2021-10-25
猜你喜欢
-
2021-04-13
-
2022-01-27
-
2021-06-20
-
2021-04-07
-
2022-12-23
-
2021-10-23
-
2021-10-08
相关资源
-
下载
2022-12-05
-
下载
2023-02-05
-
下载
2023-02-02
-
下载
2023-02-23