标签: bitmapimage

SVG是否支持嵌入位图图像?

SVG图像是纯矢量的还是我们可以将位图图像组合成SVG图像?如何在位图图像上应用变换(透视,映射等)?

编辑:图像可以通过链接参考包含在SVG中.请参见http://www.w3.org/TR/SVG/struct.html#ImageElement.我的问题实际上是,如果位图图像可以包含在svg中,那么svg图像将是自包含的.否则,每当显示svg图像时,必须遵循链接并下载图像.显然.svg文件只是xml文件.

svg image bitmapimage

140
推荐指数
3
解决办法
10万
查看次数

如何在android中存储(位图图像​​)并从sqlite数据库中检索图像?

在我的项目中,我需要将图像存储到sqlite数据库中,还需要检索它以在我的android模拟器中显示.当我在解码编码字符串后直接显示它,我使用套接字从Java类中获取,图像显示在那里.但是,当我使用数据类型blob将字符串的字节数组代码存储到sqlite数据库中,然后使用该getblob()函数再次检索它时,它包含不同的值,并发生以下错误:

JAVA.lang.NULLPointerException: Factory returns null.
Run Code Online (Sandbox Code Playgroud)

我需要一个建议,将位图图像存储到sqlite数据库中,并从sqlite数据库中检索它.

sqlite android image bitmapimage

59
推荐指数
2
解决办法
14万
查看次数

BitmapImage到byte []

我有一个BitmapImage我在WPF应用程序中使用的,后来我想将它作为字节数组保存到数据库中(我猜这是最好的方法),我该如何执行这种转换?

或者,是否有更好的方法将BitmapImage(或其任何基类,BitmapSourceImageSource)保存到数据存储库?

.net c# wpf bitmapimage imagesource

35
推荐指数
2
解决办法
5万
查看次数

如何从资源中获取BitmapImage?

我的程序集包含一个BuildAction == Resource的图像.我想从这个嵌入式资源中获取BitmapImage.

我可以从这样的文件加载BitmapImage:

var bitmap = new BitmapImage(new Uri(path));
Run Code Online (Sandbox Code Playgroud)

但是如何创建一个将引用嵌入式资源图像的Uri呢?

当我尝试创建' pack URI '(例如pack://application:,,,/MyImage.pngpack://application:,,,/MyAssembly;component/MyImage.png)时,会抛出异常:

System.UriFormatException"无效的URI:由于存在冒号(':')而无法解析端口,因此需要端口."

我在这篇博客文章中找到了修复UriFormatException

但是,应用该修复程序后,我仍然会尝试从包URI加载BitmapImage.

使用pack://application:,,,/Image.png格式时,我得到一个NullReferenceException,当使用该pack://application:,,,/AssemblyName;component/Image.png格式时,我得到一个NotSupportedException"无法识别Uri前缀".


总结 我的问题是我在实例化任何WPF控件/窗口/等之前尝试在进程中使用'pack URI',因此'pack'URI方案尚未注册(其他WPF必需'stuff'也必须不要设置,因为手动注册包方案本身不能解决问题).解决方案是等到实例化我的WPF用户控件后才使用包URI.

wpf resources bitmapimage pack-uri

34
推荐指数
1
解决办法
5万
查看次数

XAML绑定BitmapImage ViewModel属性

我从视图模型类更新列表框有问题.我使用Caliburn Micro框架.我的情况在这里:

我在listbox上绑定了bindableCollection类型的属性:

视图模型中的代码:

private BindableCollection<UserInfo> _friends;

public BindableCollection<UserInfo> Friends
{
    get { return _friends; }
    set
    {
        _friends= value;
        NotifyOfPropertyChange(()=>Friends);
    }
}
Run Code Online (Sandbox Code Playgroud)

在视图模型中,我创建假的服务方法,将新的新数据作为List返回,并使用此数据更新属性Friends,它们在listbox上绑定.

我每隔3秒就在调度员计时器滴答事件中调用假服务方法.

 private static UserInfo FakeUser()
        {
            var user = new UserInfo
            {
                Age = "16",
                Emphasis = true,
                IdUser = "11542",
                IsBlocked = false,
                IsFriend = true,
                LocationInfo = new Location
                {
                    CityName = "TN",
                    IdCity = 123456,
                    IdRegion = 1246,
                    RegionName = "TN",
                },
                StatusInfo = new Status
                {
                    IdChat = 12,
                    IsLogged = true, …
Run Code Online (Sandbox Code Playgroud)

wpf multithreading dispatcher bitmapimage

30
推荐指数
1
解决办法
1万
查看次数

将字节数组转换为bitmapimage

我要将字节数组转换为System.Windows.Media.Imaging.BitmapImageBitmapImage在图像控件中显示.

当我使用第一个代码时,注意到了!没有错误,也没有显示图像.但是当我使用第二个时,它工作正常!任何人都可以说发生了什么事吗?

第一个代码在这里:

public BitmapImage ToImage(byte[] array)
{
   using (System.IO.MemoryStream ms = new System.IO.MemoryStream(array))
   {
       BitmapImage image = new BitmapImage();
       image.BeginInit();
       image.StreamSource = ms;
       image.EndInit();
       return image;
   }
}
Run Code Online (Sandbox Code Playgroud)

第二个代码在这里:

public BitmapImage ToImage(byte[] array)
{
   BitmapImage image = new BitmapImage();
   image.BeginInit();
   image.StreamSource = new System.IO.MemoryStream(array);
   image.EndInit();
   return image;
 }
Run Code Online (Sandbox Code Playgroud)

c# wpf bytearray bitmapimage

30
推荐指数
1
解决办法
4万
查看次数

从MemoryStream png,gif创建WPF BitmapImage

我在创建一个BitmapImage来自MemoryStreamweb请求的png和gif字节时遇到了一些麻烦.这些字节似乎可以很好地下载,并且BitmapImage创建的对象没有问题,但是图像实际上并没有在我的UI上呈现.仅当下载的图像是png或gif类型时才会出现此问题(适用于jpeg).

以下是演示此问题的代码:

var webResponse = webRequest.GetResponse();
var stream = webResponse.GetResponseStream();
if (stream.CanRead)
{
    Byte[] buffer = new Byte[webResponse.ContentLength];
    stream.Read(buffer, 0, buffer.Length);

    var byteStream = new System.IO.MemoryStream(buffer);

    BitmapImage bi = new BitmapImage();
    bi.BeginInit();
    bi.DecodePixelWidth = 30;
    bi.StreamSource = byteStream;
    bi.EndInit();

    byteStream.Close();
    stream.Close();

    return bi;
}
Run Code Online (Sandbox Code Playgroud)

为了测试Web请求是否正确获取字节,我尝试了以下操作,将字节保存到磁盘上的文件,然后使用a UriSource而不是a 加载图像StreamSource,它适用于所有图像类型:

var webResponse = webRequest.GetResponse();
var stream = webResponse.GetResponseStream();
if (stream.CanRead)
{
    Byte[] buffer = new Byte[webResponse.ContentLength];
    stream.Read(buffer, 0, buffer.Length);

    string fName = "c:\\" + …
Run Code Online (Sandbox Code Playgroud)

wpf memorystream image webrequest bitmapimage

28
推荐指数
2
解决办法
6万
查看次数

将BitmapImage保存到文件

我正在开发一个程序,将URL中的图像下载到bitmapimage并显示它.接下来我尝试使用jpegbitmapencoder将bitmapimage保存到硬盘驱动器.文件已成功创建,但实际的jpeg图像为空或1个黑色像素.

public Guid SavePhoto(string istrImagePath)
{
    ImagePath = istrImagePath;

    BitmapImage objImage = new BitmapImage(
        new Uri(istrImagePath, UriKind.RelativeOrAbsolute));
    PictureDisplayed.Source = objImage;
    savedCreationObject = objImage;

    Guid photoID = System.Guid.NewGuid();
    string photolocation = photoID.ToString() + ".jpg";  //file name

    JpegBitmapEncoder encoder = new JpegBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(objImage));

    using (FileStream filestream = new FileStream(photolocation, FileMode.Create))
    {
        encoder.Save(filestream);
    }

    return photoID;
}
Run Code Online (Sandbox Code Playgroud)

这是保存和显示照片的功能.照片显示正确,但保存时再次显示我得到一个空的jpeg或1个黑色像素.

c# save bitmapimage

22
推荐指数
2
解决办法
7万
查看次数

将位图文件读入结构

我想将一个位图文件读入一个结构和manuplate它就像制作一个镜像效果等但我无法理解我应该创建哪种结构以便读入它.

谢谢您的帮助

c structure bitmap bitmapimage

22
推荐指数
2
解决办法
7万
查看次数

如何在WPF中显示渐进式JPEG?

如何在从Web URL加载时显示渐进式JPEG?我试图在WPF中的图像控件中显示Google地图图像,但我希望保持图像的优势是渐进式JPG.

如何在WPF中加载渐进式JPG?

Image imgMap;
BitmapImage mapLoader = new BitmapImage();

mapLoader.BeginInit();
mapLoader.UriSource = new Uri(URL);
mapLoader.EndInit();

imgMap.Source = mapLoader;
Run Code Online (Sandbox Code Playgroud)

目前,我这样做了.它只会在完全加载后显示图像.我想逐步展示它.

wpf image bitmapimage

18
推荐指数
1
解决办法
2868
查看次数