Tag: image

如何在将图片插入word文档后更改图片的大小

我正在将图片添加到某个书签的word文档中。 但是,图片太大并且正在强制文本离开页面,所以我需要能够在word文档中更改图片的大小。

Windows Phone 8里面的LongListSelector内存泄漏图片

我有一个LongListSelector,它包含一个从Web加载大量图像的图像控件,这个工作正常一段时间,但是在我加载了一些图像后,我得到了内存exception。 我读过其他人对于内存不足以及大量图片有相同问题,但仍然没有找到解决方案。 我已经读过它与image / BitmapImage缓存有关。 这是我的LongListSelector,它包含图像控件: 在我的MainPage.xaml.cs中,我设置了LongListSelector的DataContext: llsGameList.DataContext = gd.GetGamesListItems; 这是我用来存储我的图像的类: public class GetGamesList { public Uri BoxArtFrontThumb { get; set; } } 这是包含所有图像的ObservableCollection: private ObservableCollection _GetGamesListItems = new ObservableCollection(); public ObservableCollection GetGamesListItems { get { return this._GetGamesListItems; } } 我希望我能清楚地解释清楚。 我真的希望有人可以帮助我解决这个记忆问题。 谢谢。

C#简单图像resize:文件大小不缩小

我对以下代码有疑问。 我下面的代码成功运行一个目录,并将图片的resoultion设置为较小的大小。 但是,文件大小不会更改。 例如,尺寸为2400×1800且文件大小为1.5MB的图像将缩放为800×600,但800×600图片仍为1.5MB文件大小。 我想我可能要明确压缩图片,但我不确定。 有任何想法吗? private void Form1_Load(object sender, EventArgs e) { string[] files = null; int count = 0; files = System.IO.Directory.GetFiles(@”C:\Users\..\..\ChristmasPicsResized”); foreach (string file in files) { System.Drawing.Bitmap bmp = System.Drawing.Bipmap.FromFile(file); ResizeBitmap(bmp, 807, 605).Save( @”C:\users\..\..\TempPicHold\Pic” + count.ToString() + “.jpg”); count++; } } public Bitmap ResizeBitmap(Bitmap b, int nWidth, int nHeight) { Bitmap […]

如何使用saveFileDialog在C#中保存图像?

可能重复: 使用savefiledialog保存图像时出现问题 我在C#中使用Windows窗体。 我该如何使用saveFileDialog? 我有图片框,在图片框上有一个图像,我想保存它。 加载的图像是bmp。 我想将它保存为4种格式之一:bmp,jpeg,png,tiff。 我读了一些关于MDSN的一些注意事项并尝试过但我可能做错了。 所以我最好问一下应该怎么写? 应该如何编写方法private void saveFileDialog1_FileOk(object sender,CancelEventArgs e)以及应该如何看待属性saveFileDialog.Filter ? 谢谢 编辑: 我尝试过的: 使用savefiledialog保存图像时出现问题 EDIT2: 我试过这个filter Filter = bmp (*.bmp)|*.bmp|jpeg (*.jpeg)|*.jpeg|png (*.png)|*.png|tiff (*.tiff)|*.tiff

如何使用Ghostscript将PDF转换为图像

我发现Ghostscript能够将PDF转换为图像格式。 我尝试使用PDF到图像转换器,但无法清楚地理解它。 我已经安装了gs905w64.exe ,但当我尝试add reference对我的Web应用程序的add reference ,我收到此错误。 A reference to gsdll32.dll could not be added. No type libraries were found in the component.

将图像添加到ASP.net核心

我想添加一个图像作为模型类的一部分,并将其显示在索引视图上。 我有问题要么将图像分类为byte []或iFormFile。 这就是我想要实现的目标 创建一个页面以插入员工列表 在索引页面中,能够列出员工并查看他们的图像。 这是模型。 Employee.cs using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; namespace MvcMovie.Models { public class Employee { public int ID { get; set; } [Required] public string FirstName { get; set; } [Required] public string LastName { get; set; } [Required] public string Nationality { […]

C# – Base64字节数组到Image FAILS无论我尝试什么

我在从base64编码的字节数组中用C#创建一个Image / Bitmap对象时遇到了麻烦。 这是我正在处理的事情: 我有一个前端,用户可以裁剪图像。 当用户通过input[type=file]选择图像时,我的javascript代码使用HTML5的FileReader将DataUrl (base64字符串)保存到hidden field ,该hidden field与裁剪坐标和尺寸以及其中的所有其他内容一起发布。 form 。 精华: base64数据,如果你想测试自己: http://kristianbak.com/test_image.txt base64字符串发布到操作,并作为参数imageData接收 该操作将字符串转换为base64字节数组,如下所示: byte[] imageBytes = Convert.FromBase64String(imageData.EncodeTo64()); EncodeTo64扩展方法: public static string EncodeTo64(this String toEncode) { var toEncodeAsBytes = Encoding.ASCII.GetBytes(toEncode); var returnValue = Convert.ToBase64String(toEncodeAsBytes); return returnValue; } 将base64字符串转换为字节数组后,我使用MemoryStream将字节读入内存: using (var imageStream = new MemoryStream(imageBytes, false)) { Image image = Image.FromStream(imageStream); //ArgumentException: Parameter […]

将图像切成9块C#

可能重复: 图像分为9个部分 虽然我用Google搜索足够,但遗憾的是没有找到帮助。 此代码项目教程也无法满足我的实际需要。 我在WinForm中有一个Image和9 PictureBox。 Image img = Image.FromFile(“media\\a.png”); // a.png has 312X312 width and height // some code help, to get // img1, img2, img3, img4, img5, img6, img7, img8, img9 // having equal width and height // then… pictureBox1.Image = img1; pictureBox2.Image = img2; pictureBox3.Image = img3; pictureBox4.Image = img4; pictureBox5.Image = […]

如何获得图像的分辨率? (JPEG,GIF,PNG,JPG)

我找到了这个方法: Graphics g = e.Graphics; Bitmap bmp = new Bitmap(“winter.jpg”); g.DrawImage(bmp, 0, 0); Console.WriteLine(“Screen resolution: ” + g.DpiX + “DPI”); Console.WriteLine(“Image resolution: ” + bmp.HorizontalResolution + “DPI”); Console.WriteLine(“Image Width: ” + bmp.Width); Console.WriteLine(“Image Height: ” + bmp.Height); SizeF s = new SizeF(bmp.Width * (g.DpiX / bmp.HorizontalResolution), bmp.Height * (g.DpiY / bmp.VerticalResolution)); Console.WriteLine(“Display size of image: […]

在生成条形码时修复“GDI +中发生了一般错误”

我在C#中编写条形码生成器我可以生成条形码作为位图,并可以在Picturebox(WindowsForms)中显示它们。 另一方面,我无法将条形码保存为gif或jpeg文件。 我的条形码是位图文件,这是我的代码 Bitmap barCode = CreateBarCode(“*”+txtBarCodeStr.Text+”*”); barCode.Save(@”C:\barcode.gif”, ImageFormat.gif); picBox.Image = barCode; MessageBox.Show(“Created”); 我得到以下exception; GDI +中发生了一般错误。