本文整理汇总了C#中Image.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Image.Clone方法的具体用法?C# Image.Clone怎么用?C# Image.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image.Clone方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MDIForm
public MDIForm(ref Image Img,MainForm Parent)
{
InitializeComponent();
img = Img.Clone();
//this.Dock = DockStyle.Fill;
this.WindowState = FormWindowState.Maximized;
MDIPicture.Width = (int)img.Width;
MDIPicture.Height = (int)img.Height;
Parent.IsMdiContainer = true;
this.MdiParent = Parent;
MDIPicture.Image = img.bitmap;
this.Show();
}
示例2: Add
public static Image Add(Image img1, Image img2, double fraction)
{
uint s1 = img1.Height * img1.Width;
uint s2 = img2.Height * img2.Width;
if (s1 > s2)
{
//resize
img2 = TransformImage(img2, 0, 0, 0, (float)img1.Width / (float)img2.Width,
(float)img1.Height / (float)img2.Height);
}
else if (s1 < s2)
{
//resize
img1 = TransformImage(img1, 0, 0, 0, (float)img2.Width / (float)img1.Width,
(float)img2.Height / (float)img1.Height);
}
Image result = img1.Clone();
for (uint i = 0; i < img1.Height; i++)
{
for (uint j = 0; j < img1.Width; j++)
{
Pixel p1 = img1.getPixel(j, i);
Pixel p2 = img2.getPixel(j, i);
Pixel res = new Pixel();
res.R = (byte)(p1.R * fraction + p2.R * (1 - fraction));
res.G = (byte)(p1.G * fraction + p2.G * (1 - fraction));
res.B = (byte)(p1.B * fraction + p2.B * (1 - fraction));
result.setPixel(j, i, res);
}
}
return result;
}
示例3: AnalyseFrame
private void AnalyseFrame()
{
if(frame!=null)
frame.Dispose();
frame = capture.QueryFrame();
if (frame != null)
{
GameObject.Destroy(cameraTex);
cameraTex = TextureConvert.ImageToTexture2D<Bgr, byte>(frame, true);
Sprite.DestroyImmediate(CameraImageUI.GetComponent<UnityEngine.UI.Image>().sprite);
CameraImageUI.sprite = Sprite.Create(cameraTex, new Rect(0, 0, cameraTex.width, cameraTex.height), new Vector2(0.5f, 0.5f));
}
if (true)
//if (!processingFrame)
{
processingFrame = true;
board = ImageTools.ReadFromFrame(frame.Clone(),filteringParameters);
if (lookupImage != null)
lookupImage.Dispose();
if (board != null)
lookupImage = ImageTools.DrawRooms(320, 240, board.Grid);
else
lookupImage = new Image<Bgr, byte>(320, 240, new Bgr(0, 0, 0));
if (lookupImage != null)
{
GameObject.Destroy(lookupTex);
lookupTex = TextureConvert.ImageToTexture2D<Bgr, byte>(lookupImage, true);
Sprite.DestroyImmediate(LookupUI.GetComponent<UnityEngine.UI.Image>().sprite);
LookupUI.sprite = Sprite.Create(lookupTex, new Rect(0, 0, lookupTex.width, lookupTex.height), new Vector2(0.5f, 0.5f));
}
processingFrame = false;
}
}
示例4: Subtract
public static Image Subtract(Image img1, Image img2)
{
uint s1 = img1.Height * img1.Width;
uint s2 = img2.Height * img2.Width;
if (s1 > s2)
{
//resize
img2 = TransformImage(img2, 0, 0, 0, (float)img1.Width / (float)img2.Width,
(float)img1.Height / (float)img2.Height);
}
else if (s1 < s2)
{
//resize
img1 = TransformImage(img1, 0, 0, 0, (float)img2.Width / (float)img1.Width,
(float)img2.Height / (float)img1.Height);
}
Image result = img1.Clone();
for (uint i = 0; i < img1.Height; i++)
{
for (uint j = 0; j < img1.Width; j++)
{
Pixel p1 = img1.getPixel(j, i);
Pixel p2 = img2.getPixel(j, i);
//double p1_r, p2_r, p1_g, p2_g, p1_b, p2_b;
/* p1_r = p1.R / 255.0f;
p1_g = p1.G / 255.0f;
p1_b = p1.B / 255.0f;
p2_r = p2.R / 255.0f;
p2_g = p2.G / 255.0f;
p2_b = p2.B / 255.0f;
*/
double rr, rg, rb;
rr = (p1.R - p2.R + 255.0) / 510.0;
rg = (p1.G - p2.G + 255.0) / 510.0;
rb = (p1.B - p2.B + 255.0) / 510.0;
Pixel res = new Pixel();
res.R = (byte)(rr * 255.0);
res.G = (byte)(rg * 255.0);
res.B = (byte)(rb * 255.0);
result.setPixel(j, i, res);
}
}
return result;
}
示例5: LinearFilter
public static Image LinearFilter(Image img, double[,] values, int OriginX, int OriginY, PostProcessing op)
{
Image nimage = img.Clone();
int top = values.GetLength(0) - OriginY;
int down = values.GetLength(0) - top;
int left = values.GetLength(1) - OriginX;
int right = values.GetLength(1) - left;
for (uint i = 0; i < img.Height; ++i)
{
for (uint j = 0; j < img.Width; ++j)
{
uint nx = 0;
uint ny = 0;
double rr = 0;
double gg = 0;
double bb = 0;
for (int x = (int)(i - top); x < (int)(i + down); ++x, nx++)
{
for (int y = (int)(j - left); y < (int)(j + right); ++y, ny++)
{
Pixel p;
if (x < 0 || x >= img.Height || y < 0 || y >= img.Width)
p = new Pixel(0, 0, 0, 0);
else
{
p = img.getPixel((uint)y, (uint)x);
}
rr += p.R * values[nx, ny];
gg += p.G * values[nx, ny];
bb += p.B * values[nx, ny];
}
ny = 0;
}
Pixel np = new Pixel();
if (op == PostProcessing.NO)
{
np = new Pixel((byte)rr, (byte)gg, (byte)bb, 0);
}
else if (op == PostProcessing.ABSOLUTE)
{
}
else if (op == PostProcessing.CUTOFF)
{
rr = Clamp(0, 255, rr);
gg = Clamp(0, 255, gg);
bb = Clamp(0, 255, bb);
np = new Pixel((byte)rr, (byte)gg, (byte)bb, 0);
}
else if (op == PostProcessing.NORMALIZATION)
{
rr = rr / (/*values.GetLength(0) * values.GetLength(1) */ 255.0);
gg = gg / (/*values.GetLength(0) * values.GetLength(1) */ 255.0);
bb = bb / (/*values.GetLength(0) * values.GetLength(1) */ 255.0);
np = new Pixel((byte)(rr * 255), (byte)(gg * 255), (byte)(bb * 255), 0);
}
nimage.setPixel(j, i, np);
}
}
return nimage;
}
示例6: SimpleImageData
public SimpleImageData(IImageSource<IImageData> source, Image<Bgr, byte> image)
{
Source = source;
OriginalImage = image.Clone();
Image = image;
}
示例7: KeepCapturing
public void KeepCapturing()
{
while (true)
{
Console.WriteLine("DEBUG: Server--> Entra nel While");
ScreenCapture sc = new ScreenCapture(); // capture entire screen
img = sc.CaptureScreen();
img1 = (Image)img.Clone();
padre.setImage(img1);
//if (img != null) //If you choosed an image
//{
//videoServer.SendImage(img); //Send the image
this.SendImage(img);
//}
}
}
示例8: SensorColorFrameReady
private void SensorColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
// Copy the pixel data from the image to a temporary array
colorFrame.CopyPixelDataTo(this.colorPixels);
// Write the pixel data into our bitmap
this.colorBitmap.WritePixels(
new System.Windows.Int32Rect(0, 0, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight),
this.colorPixels,
this.colorBitmap.PixelWidth * sizeof(int),
0);
BitmapEncoder encoder = new BmpBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(colorBitmap));
MemoryStream ms = new MemoryStream();
encoder.Save(ms);
Bitmap b = new Bitmap(ms);
currentFrame = new Image<Bgr, Byte>(b);
if (currentFrame != null)
{
//handDec = new HandDetector("C:/Users/L33549.CITI/Desktop/AbuseAnalysis/BodyDetectionAnalysis1/BodyDetectionAnalysis1/gloveHSV.txt", WIDTH, HEIGHT);
//handDec.update(currentFrame);
//Draw the image, the detected hand and finger info, and the average ms snap time at the bottom left of the panel.
//Graphics g = Graphics.FromImage(currentFrame.ToBitmap());
//handDec.draw(g);
Image<Gray, Byte> grayFrame = currentFrame.Convert<Gray, Byte>();
Rectangle[] handDetected = hand.DetectMultiScale(grayFrame, 1.1, 10, Size.Empty, Size.Empty);
foreach (Rectangle hands in handDetected)
{
currentFrame.Draw(hands, new Bgr(System.Drawing.Color.Yellow), 2);
imgs.Add(currentFrame.Clone());
}
capturedImageBox.Image = currentFrame.Clone();
}
}
}
}