Tag: 图像

使用C#中的TextureBrush在不同高度开始的平铺图像问题

我正在尝试使用TextureBrush在尺寸宽度= 1000,高度= 16的矩形区域上平铺图像(16×16)以获得像UI这样的条带。 Rectangle myIconDrawingRectangle = new Rectangle(x, y, 1000, 16); using (TextureBrush brush = new TextureBrush(myIcon, WrapMode.Tile)) { e.Graphics.FillRectangle(brush, myIconDrawingRectangle ); } 当我用x = 0绘制时,y = 0平铺从(0,0)开始按预期发生。 当我用x = 0绘制时,y = 50平铺从(0,50)开始,但绘制矩形不是从图像的开头开始。 它从图像的裁剪部分开始,然后重复。 怎么解决这个? PS:我不想在DrawImage上反复手动循环。

透视图像失真

我正在处理的应用程序目前需要Perspective Image Distortion的function。 基本上我想要做的是允许用户将图像加载到应用程序中,并根据他们可以指定的4个角点调整其透视图属性。 我看了一下ImageMagic。 它具有一些扭曲function,可以进行调整,但速度非常慢,某些输入会产生不正确的输出。 你们中的任何人都使用过任何其他库或算法。 我在C#中编码。 任何指针都将非常感激。 谢谢

如何使用哈希字节比较2个图像是否相同?

private void button1_Click(object sender, EventArgs e) { Bitmap im1 = new Bitmap(@”C:\Users\user\Downloads\CaptchaCollection\1.png”); Bitmap im2 = new Bitmap(@”C:\Users\user\Downloads\CaptchaCollection\2.png”); if (HashImage(im1) == HashImage(im2)) { MessageBox.Show(“Same Image”); } else { MessageBox.Show(“Different Image”); } } 如果单击该按钮,它将比较这两个图像。 以下是用于散列图像的代码。 public byte[] HashImage(Bitmap image) { var sha256 = SHA256.Create(); var rect = new Rectangle(0, 0, image.Width, image.Height); var data = image.LockBits(rect, ImageLockMode.ReadOnly, […]

如何转换像素格式? 从Cb的32bppRGB到16bpp灰度

我需要为我的图像做一些阈值处理。 阈值滤波器function只接受8-16bpp灰度 。 我的位图图片具有32bppRGB像素格式。 请为此建议一些代码。 (我也想知道是否有可能没有逐像素操作) ps我正在使用Aforge.NET进行阈值处理。 谢谢 -Sagar

检查图像的宽度和高度

我可以在图片框中显示图片,而无需通过以下代码检查文件大小: private void button3_Click_1(object sender, EventArgs e) { try { //Getting The Image From The System OpenFileDialog open = new OpenFileDialog(); open.Filter = “Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp”; if (open.ShowDialog() == DialogResult.OK) { Bitmap img = new Bitmap(open.FileName); pictureBox2.Image = img; } } catch (Exception) { throw new ApplicationException(“Failed loading image”); } […]

GridView中的ASP.Net显示图像跨越列和行? 使用C#

我有一些想要在Gridview中显示的缩略图。 我不熟悉所提供的所有定制。 基本上我想将图像存储在Gridview中,可能跨越5列宽……然后需要很多行才能完成剩下的工作。 我不想要任何列或行标题,并且真的不希望看到实际网格的证据。 我也想让图像可以点击。 我将从Asp.net中的Sql数据库中提取图像。 我不想将网格绑定到sqldatasource,而是将图像粘贴在网格中,在页面后面的代码中使用某种循环。 这让我感到困惑。 我知道你可以创建一个数据表并添加列和行。 但是,似乎行/列不会跨越。 你将如何存储图像,使其像网格一样工作。 我在下面提供了一些(非常)sudo代码,让你知道我想要做什么。 sudo代码: colcount = 0; rowcount = 0; imagecount = 0; while(images.length > imagecount){ if(colcount < 5){ grid[rowcount][colcount] = images[imagecount]; colcount++; imagecount++; } else{ rowcount++; colcount = 0; } }

图像属性的值(C#)

我正在尝试解决为Bitmap对象更改值ImageDescription的问题。 添加文件的描述。 搜索相关主题,我还没有找到解决方案。 我的代码: public Bitmap ImageWithComment(Bitmap image) { string filePath = @”C:\1.jpg”; var data = Encoding.UTF8.GetBytes(“my comment”); var propItem = image.PropertyItems.FirstOrDefault(); propItem.Type = 2; propItem.Id = 40092; propItem.Len = data.Length; propItem.Value = data; image.SetPropertyItem(propItem); image.Save(filePath); return image; } 但带有新评论的图片不保存在文件夹中((请帮帮我

将Graphics对象转换为Bitmap

我的图形对象确实存在以下问题。 编辑: 我有一个picturebox_image (imageRxTx) ,这是一个来自相机的实时流。 我在绘制事件中所做的是在图像imageRxTx上绘制一些线条(未在下面的代码中显示)。 到目前为止这没有问题。 现在我需要检查imageRxTx中的圆圈,因此我必须使用需要Bitmap作为参数的方法ProcessImage() 。 不幸的是我没有Bitmap图像,而是我的imageRxTx的句柄(hDC) 。 问题 :如何从我的图形对象中获取imageRxTx并将其“转换”为我需要在方法ProcessImage(位图位图)中使用的位图图像 ? 需要在paint-event中连续调用此方法,以便检查我的相机的实时流(imageRxTx)。 这是我的代码: private void imageRxTx_paint(object sender, PaintEventArgs e) { var settings = new Settings(); // Create a local version of the graphics object for the PictureBox. Graphics Draw = e.Graphics; IntPtr hDC = Draw.GetHdc(); // Get a handle to image_RxTx. Draw.ReleaseHdc(hDC); […]

在整个循环完成之前,标签文本不会更新

我有一个Winform程序,当用户点击一个按钮然后调用picturebox paint事件来根据计算结果绘制一个新的BMP时进行一些计算。 这很好用。 现在我想这样做100次,每次刷新图片框时,我希望通过更新标签上的文本来查看当前的迭代: private void button2_Click(object sender, EventArgs e) { for (int iterations = 1; iterations <= 100; iterations++) { // do some calculations to change the cellmap parameters cellMap.Calculate(); // Refresh picturebox1 pictureBox1.Invalidate(); pictureBox1.Update(); // Update label with the current iteration number label1.Text = iterations.ToString(); } } private void pictureBox1_Paint(object sender, PaintEventArgs e) […]

你可以在.NET中打开JPEG,添加文本和重新保存为JPEG吗?

我想在.NET 4.0中编写一个小程序,它将打开一个.jpg(或.jpeg)文件,在图像上添加一行文本,然后将图像重新保存为.jpg。 有谁知道最简单的方法吗? 谢谢你的帮助。