Tag: 图像

阅读Windows Live照片库插入的“人物标签”

照片库使您能够标记一个人的脸并为其应用标签。 我知道它会将标签直接插入到文件中,而不是将其存储在数据库或随附的元文件中。 所以如果这是真的,它插入了什么数据以及它是如何格式化的?

如何将生成的位图加载到PictureBox中?

似乎有很多图片框问题,但我没有找到任何处理将图片框的内容更改为不是简单地从文件加载的位图。 我的应用程序采用一个字节数组并从中生成一个位图。 我真的想避免写入文件作为中间处理步骤。 因为它是一个字节数组,而不是2字节字,我需要使用灰度调色板制作索引位图。 然后我将索引位图转换为普通位图(24位rgb)。 这是导致我出错的代码: pictureBox1.Image = (System.Drawing.Image)bmp2; 当我查看表单(图片框试图绘制)时,线程将简单地停止执行一条消息:“System.Drawing.Image.get_RawFormat()中的无效参数” 我究竟做错了什么? 如何为图片框创建安全位图? 这就是创建“bmp2”的原因: //creating the bitmap from the array System.Drawing.Bitmap bmp1 = new System.Drawing.Bitmap(100, 100, 100, System.Drawing.Imaging.PixelFormat.Format8bppIndexed, MyIntPtr); //creating a proper indexed palette System.Drawing.Imaging.ColorPalette GrayPalette = bmp1.Palette; for (int i = 0; i < GrayPalette.Entries.Length; i++) { GrayPalette.Entries[i] = Color.FromArgb(i, i, i); } bmp1.Palette = […]

帮助Bitmap解码器

我一直在研究位图解码器,但我处理像素数据的算法似乎不太合适: public IntPtr ReadPixels(Stream fs, int offset, int width, int height, int bpp) { IntPtr bBits; int pixelCount = bpp * width * height; int Row = 0; decimal value = ((bpp*width)/32)/4; int RowSize = (int)Math.Ceiling(value); int ArraySize = RowSize * Math.Abs(height); int Col = 0; Byte[] BMPData = new Byte[ArraySize]; BinaryReader r = new […]

为什么图像的流媒体源不起作用?

我使用以下代码来流式传输图像源: BitmapImage Art3 = new BitmapImage(); using (FileStream stream = File.OpenRead(“c:\\temp\\Album.jpg”)) { Art3.BeginInit(); Art3.StreamSource = stream; Art3.EndInit(); } artwork.Source = Art3; “artwork”是应该显示图像的XAML对象。 该代码不应该锁定图像,它不会将其锁定好,但也不显示它,默认图像变为“无”…我的猜测是我没有正确使用流,并且我的图像变为空。 救命? 更新: 我现在使用以下代码,朋友向我建议: BitmapImage Art3 = new BitmapImage(); FileStream f = File.OpenRead(“c:\\temp\\Album.jpg”); MemoryStream ms = new MemoryStream(); f.CopyTo(ms); f.Close(); Art3.BeginInit(); Art3.StreamSource = ms; Art3.EndInit(); artwork.Source = Art3; 出于某些奇怪的原因,此代码返回以下错误: 图像无法解码。 图像标头可能已损坏。 我究竟做错了什么? 我确定我试图加载的图像没有损坏。

如何识别/检查模糊图像?

我们如何识别给定图像模糊或C#中模糊的百分比? 有没有可用的API? 或者任何有用的算法? 谢谢!

如何在Microsoft报表中显示来自字节数组的图像

我正在使用Report文件和ReportViewer控件来显示在运行时从对象动态加载数据的报表。 我需要显示一个图像,该图像作为字节数组存储在对象中。 PictureBox的值当前设置为: =First(Fields!ImageData.Value, “dtstItemImage”) 我使用以下方法设置DataSource: ImageBindingSource.DataSource = this.item.Image.ImageData; 代码编译并运行,但图像不会显示在报告中 。 这是因为PictureBox需要绑定到Image对象(而不是字节数组)吗? 或者我可能需要设置PictureBox的一些属性? 更新1 我已经为PictureBox添加了一个边框,只是为了确保它是可见的,它确实显示在报告中。 它只是不包含图像。 更新2 我在我的代码中修正了一个错误。 我改变了: ImageBindingSource.DataSource = this.item.Image.ImageData; 至: ImageBindingSource.DataSource = this.item.Image; 因为PictureBox绑定到ImageData字段但是DataSource是Image对象。 现在我得到一个小十字图标而不是什么(至少对我来说)表示一些进展,但我不知道字节[] – 位图转换代码需要在哪里。

C#:将图像保存到DB中

有人可以给我一些关于如何在C#中将图像文件保存到DB的建议吗? 我会保存很多图像,那么减少所需空间的最佳方法是什么? 我目前在DB中使用varbinary(max)字段。 谢谢!

使用graphics.DrawImage进行非平滑的Upscaling

我正在网格中绘制一些图像。 图像保存为16x16px pngs。 但是,我后来决定将网格的大小增加到32x32px。 当我使用以下代码时: graphics.DrawImage(image, Xdraw, Ydraw, 32, 32); 其中image是从png加载的Image,而Xdraw和Ydraw是在上面某处决定的左上角。 图像稍微模糊,因为.DrawImage使用双三次(或其他平滑函数)来放大图像。 我希望它关闭平滑,所以我可以保留硬边。 这可能吗?

从sql数据库中检索图像

以前我有插入图像到SQL数据库的问题。 现在我已经解决了这个问题,并能够在sqldatabase中插入图像。 现在我遇到从数据库表中检索图像的问题。 这是我的检索代码: showimage.ashx: using System; using System.Web; using System.IO; using System.Configuration; using System.Data.SqlClient; using System.Data; public class ShowImage : IHttpHandler { public void ProcessRequest (HttpContext context) { int empno; if (context.Request.QueryString[“empid”] != null) empno = Convert.ToInt32(context.Request.QueryString[“id”]); else throw new ArgumentException(“No parameter specified”); context.Response.ContentType = “image/jpeg”; //context.Response.Write(“Hello World”); Stream strm = ShowEmpImage(empno); byte[] buffer […]

返回由Image.FromStream(Stream stream)方法创建的图像

我有这个函数在函数中返回一个Image,使用Image.FromStream方法创建图像根据MSDN : 您必须在图像的生命周期内保持流打开 所以我没有关闭流(如果我关闭了蒸汽,则从返回的图像对象中抛出GDI +exception)。 我的问题是当在返回的Image上的其他地方调用Image.Dispose()时是否关闭/处理流 public static Image GetImage(byte[] buffer, int offset, int count) { var memoryStream = new MemoryStream(buffer, offset, count); return Image.FromStream(memoryStream); } 正如其中一个答案中所建议的那样, 使用不是可行的方法,因为它会引发exception: public static Image GetImage(byte[] buffer, int offset, int count) { using(var memoryStream = new MemoryStream(buffer, offset, count)) { return Image.FromStream(memoryStream); } } public static void Main() { […]