Tag: image

如何将图像转换为xamarin.android中的base64?

我有这个代码,它在android studio中工作得很好,但在xamarin bitmap.Compress()在xamarin中有不同的参数 ,我很困惑如何在xamarin.android中将图像转换为base64或二进制? 我在第3行收到错误: (bitmap.Compress()有一些无效的参数)。 Bitmap bitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ace1); ByteArrayOutputStream bao = new ByteArrayOutputStream(); bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100,bao); byte[] ba = bao.ToByteArray(); string bal = Base64.EncodeToString(ba, Base64.Default);

Graphics.DrawString以printdocument宽度为中心

我试图将一个字符串放在printdocument上。 我用图像完成了以下操作并且它可以工作,但似乎对字符串不起作用。 这是我用来居中图像的代码 e.Graphics.DrawImage(logo, (e.MarginBounds.Width / 2) – (logo.Width / 2), height); 我试图居中的文本是从TabControl中的Tab提供的 using (var sf = new StringFormat()) { height = logo.Height + 15; sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; e.Graphics.DrawString(tabData.Text, new Font(this.Font.Name, 10), new SolidBrush(tabData.ForeColor), (e.MarginBounds.Width / 2) – (txtData.Width / 2), height, sf); } 我也在下面尝试过并使用string_size.Width / 2代替txtData.Width SizeF string_size = e.Graphics.MeasureString(tabData.Text, tabData.Font); […]

在WPF中将图像添加到FixedPage

我希望能够用其他UIElements打印图像。 我有一个FixedPage实例,并试图像这样添加图像 // Basic printing stuff var printDialog = new PrintDialog(); var fixedDocument = new FixedDocument(); fixedDocument.DocumentPaginator.PageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight); FixedPage page = new FixedPage(); page.Width = fixedDocument.DocumentPaginator.PageSize.Width; page.Height = fixedDocument.DocumentPaginator.PageSize.Height; Image img = new Image(); // PrintIt my project’s name, Img folder var uriImageSource = new Uri(@”/PrintIt;component/Img/Stuff.png”, UriKind.RelativeOrAbsolute); img.Source = new BitmapImage(uriImageSource); img.Width […]

system.data.oledb.oledbexception(0x80004005):找不到文件

有人可以帮我解决这个错误吗? 我无法弄明白。 我在Windows XP上有这个错误但在Windows 7上没有。我做的是我附上一张照片并将其保存到数据库(MS Access作为我的数据库)。 照片出现在图片框上,但之后就是一团糟。 我正在使用C#。

使用固定大小的可拖动图片框裁剪图像

我正在开展一个涉及裁剪图像的winforms项目。 我的目标是通过使用固定大小的可拖动图片框控件来完成此操作,允许用户选择他们想要保留的区域。 我的问题是当我裁剪图像时; 它“有效” ,但作物面积偏移了一点。 这是我得到的结果: 为了澄清,我不是在谈论缩放,这是每个设计。 请注意,橙色框主要关注风暴的眼睛,但裁剪的图像不是。 这是我的作物操作代码: private void tsbRecortar_Click(object sender, EventArgs e) { Rectangle recorte = new Rectangle(pbxSeleccion.Location.X, pbxSeleccion.Location.Y, pbxSeleccion.Width, pbxSeleccion.Height); foto = recortarImagen(foto, recorte); pbxImagen.Image = foto; } private Image recortarImagen(Image imagen, Rectangle recuadro) { try { Bitmap bitmap = new Bitmap(imagen); Bitmap cropedBitmap = bitmap.Clone(recuadro, bitmap.PixelFormat); return (Image)(cropedBitmap); } catch […]

如何在滚动较大的缩小图片时防止图形卡顿

我有一个很大的tiff图片(5.9 Mb,13k X 16k reolution),用户可以将其加载到一个可滚动的面板中,然后他可以放大/缩小,滚动和标记点,区域等。 对于可滚动的双缓冲面板我正在使用鲍勃鲍威尔的真棒ZoomPicBox的修改该面板仅显示当前视图中的部分图片。 缩小时滚动图像时出现断断续续的情况(即使interpolationMode设置为低) 有什么可以做的(最好没有硬件加速)? 面板的绘画事件: protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { if (_image == null) { base.OnPaintBackground(e); return; } //scale System.Drawing.Drawing2D.Matrix ScaleMat = new System.Drawing.Drawing2D.Matrix(_zoom, 0, 0, _zoom, 0, 0); //move to position of scrollbas ScaleMat.Translate(this.AutoScrollPosition.X / (_zoom), this.AutoScrollPosition.Y / (_zoom)); e.Graphics.Transform = ScaleMat; e.Graphics.InterpolationMode = _interpolationMode; e.Graphics.DrawImage(_image, new Rectangle(0, 0, […]

ListView Windows应用中的图像点按事件

我正在Windows 8中为WinRT开发我的第一个应用程序。 我的应用程序使用一个列表视图实现,列表视图包含两个图像控件我想在图像控制时添加点击事件,当图像点击时,图像的可见性变为折叠,另一个图像的可见性变得可见。 我的代码= 我已经使用过这段代码,但它适用于所有添加图像控件而不适用于特定项目。 我想只针对用户按下的特定项目进行此操作。 private void SearchVisualTree(DependencyObject targetElement) { var count = VisualTreeHelper.GetChildrenCount(targetElement); if (count == 0) return; for (int i = 0; i < count; i++) { var child = VisualTreeHelper.GetChild(targetElement, i); if (child is Image) { Image myItems = (Image)child; if (myItems.Name == "add") { myItems.Visibility = Visibility.Collapsed; return; } } […]

byte 到BitmapImage转换失败

我有个问题。 我想将BitmapImage转换为byte[]数组并返回。 我写了这些方法: public static byte[] ToByteArray(this BitmapImage bitmapImage) { byte[] bytes; using (MemoryStream ms = new MemoryStream()) { bitmapImage.BeginInit(); bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.StreamSource.CopyTo(ms); bitmapImage.EndInit(); bytes = ms.ToArray(); } return bytes; } public static BitmapImage ToBitmapImage(this byte[] bytes, int width, int height) { BitmapImage bitmapImage = new BitmapImage(); using (MemoryStream ms = new MemoryStream(bytes)) { […]

从常见图像格式中删除所有元数据?

我正在为一个将处理我们图像处理的项目编写服务。 一个这样的过程应该从提供的byte[]去除所有元数据,并将相同的图像作为byte[] 。 我目前正在处理的方法包括始终将图像转换为Bitmap ,然后将其转换回原始格式并从MemoryStream返回数据。 我还没能测试它,但有些东西告诉我,我将体验到一些质量损失。 如何使用通用格式从任何图像中删除所有元数据? (bmp, gif, png, jpg, icon, tiff) 我不确定如何进一步缩小范围。 如果我得到关于downvotes的一些反馈,那会很好。

使用c#在VisualBrush中设置图像运行时

实际上我将设置时从资源中获取的图像设置为xaml文件,如下所示: 并且工作正常。 但是(是登录按钮)我希望当用户登录时,按钮上的图像(矩形内)将被更改。 我能怎么做?