如何在从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)
目前,我这样做了.它只会在完全加载后显示图像.我想逐步展示它.
我用:
Dim bmi As New BitmapImage(New Uri(fiInfo.FullName, UriKind.Absolute))
bmi.CacheOption = BitmapCacheOption.OnLoad
Run Code Online (Sandbox Code Playgroud)
这不使用OnLoad 并且文件仍被锁定以覆盖硬盘.知道怎么解锁?
问候
我正在使用Java中的Images,我设计了超过100种图像(.png)格式,它们都是Trasparent和Black Color Drawing.
问题是,现在我被要求改变绘图的颜色(黑色 - ).
我搜索了许多在谷歌剪辑的代码,它改变了图像的位图(像素),但我不是在猜测我必须做什么来匹配精确的像素,并在图像处于透明模式时特别替换.下面是.Net中的代码(C#)
Bitmap newBitmap = new Bitmap(scrBitmap.Width, scrBitmap.Height);
for (int i = 0; i < scrBitmap.Width; i++)
{
for (int j = 0; j < scrBitmap.Height; j++)
{
originalColor = scrBitmap.GetPixel(i, j);
if(originalColor = Color.Black)
newBitmap.SetPixel(i, j, Color.Red);
}
}
return newBitmap;
Run Code Online (Sandbox Code Playgroud)
但它根本没有匹配,我调试了它,在整个文件中,没有Color(originalColor)变量的Red,Green,Blue参数值.
有人可以帮忙吗?
我需要帮助,我有这个方法从Byte []获取BitmapImage
public BitmapSource ByteToBitmapSource(byte[] image)
{
BitmapImage imageSource = new BitmapImage();
using (MemoryStream stream = new MemoryStream(image))
{
stream.Seek(0, SeekOrigin.Begin);
imageSource.BeginInit();
imageSource.StreamSource = stream;
imageSource.CacheOption = BitmapCacheOption.OnLoad;
imageSource.EndInit();
}
return imageSource;
}
Run Code Online (Sandbox Code Playgroud)
imageSource.EndInit(); 抛出错误"我们发现没有适合完成此操作的成像组件."
我正在尝试编写一个实用程序类,允许自动调整tiletale图像的大小.假设有一个srcBitmap,我从中复制一个由Rectangle srcRegion给出的区域.然后我想在目标区域Rectangle destRegion中将该区域粘贴(明智的像素)到另一个名为Bitmap destBitmap的图像中.我知道如何从源中获取区域并将其放入Bitmap对象中,但我还没有找到如何将Bitmap对象实际粘贴到另一个更大的Bitmap对象中的某个区域中.
有快速的方法吗?(没有GDI而没有深入研究位图的字节数组).这是应该澄清我的目标的片段
private static void CopyRegionIntoImage(Bitmap srcBitmap, Rectangle srcRegion, Bitmap destBitmap, Rectangle destRegion)
{
// get the required region from the destination
Bitmap region = Copy(srcBitmap, srcRegion);
}
Run Code Online (Sandbox Code Playgroud) 我有一个字节数组,其中包含位图格式的图像二进制数据.如何在C#中使用PictureBox控件显示它?
我通过下面列出的几个帖子,但不确定我是否需要将字节数组转换为其他内容,然后再将其发送到图片框.我很感激你的帮助.谢谢!
我正在尝试更换安装程序起始页上的侧边栏图像.我一直收到错误'位图图片无效'.规格与默认的Inno Setup安装程序侧栏.bmp完全匹配.我试图使用的图像尺寸为164 x 314,位深度为8,这是文档推荐的.
有什么我想念的吗?任何提示表示赞赏!
这是图片的链接
我想将位图的大小精确地减少到200kb.我从SD卡中获取一张图像,将其压缩并再次使用不同的名称将其保存到另一个目录中的SD卡中.压缩工作正常(3 mb像图像被压缩到大约100 kb).我为此编写了以下代码行:
String imagefile ="/sdcard/DCIM/100ANDRO/DSC_0530.jpg";
Bitmap bm = ShrinkBitmap(imagefile, 300, 300);
//this method compresses the image and saves into a location in sdcard
Bitmap ShrinkBitmap(String file, int width, int height){
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(file, bmpFactoryOptions);
int heightRatio = (int)Math.ceil(bmpFactoryOptions.outHeight/(float)height);
int widthRatio = (int)Math.ceil(bmpFactoryOptions.outWidth/(float)width);
if (heightRatio > 1 || widthRatio > 1)
{
if (heightRatio > widthRatio)
{
bmpFactoryOptions.inSampleSize = heightRatio;
} else {
bmpFactoryOptions.inSampleSize = widthRatio;
}
}
bmpFactoryOptions.inJustDecodeBounds = false; …Run Code Online (Sandbox Code Playgroud) 我正在开发一个将过滤器应用于图像的Windows 8 Metro应用程序.我有一个网络版的应用程序,并希望移植它.但是我们都知道WinRT没有.NET提供的所有好东西:/
目前我在字节数组上应用过滤器,我想保持这种方式,因为它超快!因此,在过去的几天里,我一直在寻找将StorageFile转换为byte []然后将byte []转换为BitmapImage的方法.
到目前为止,我已经设法完成了第一个(StorageFile到byte []).我是这样做的:
public async Task<Byte[]> ImageFileToByteArray(StorageFile file)
{
IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);
PixelDataProvider pixelData = await decoder.GetPixelDataAsync();
return pixelData.DetachPixelData();
}
Run Code Online (Sandbox Code Playgroud)
这段代码返回byte[]包含像素数据的BGRA.
这是棘手的部分.我无法成功将字节数组转换为BitmapImage.我搜遍了所有的地方,很多人建议使用WriteableBitmap,但这对我没什么好处.我还发现了一些应该起作用的代码片段......但它们没有.
我尝试过的解决方案之一是使用InMemoryRandomAccessStream,如下所示:
public async Task<BitmapImage> ByteArrayToBitmapImage(Byte[] pixels)
{
var stream = new InMemoryRandomAccessStream();
await stream.WriteAsync(pixels.AsBuffer());
stream.Seek(0);
var image = new BitmapImage();
await image.SetSourceAsync(stream);
return image;
}
Run Code Online (Sandbox Code Playgroud)
这个抛出以下异常:
mscorlib.dll中出现"System.Exception"类型的异常,但未在用户代码中处理
附加信息:找不到该组件.(来自HRESULT的异常:0x88982F50)
我尝试使用这一行代替:
PixelDataProvider pixelData = await decoder.GetPixelDataAsync(
BitmapPixelFormat.Bgra8,
BitmapAlphaMode.Ignore,
new BitmapTransform(),
ExifOrientationMode.IgnoreExifOrientation,
ColorManagementMode.DoNotColorManage);
Run Code Online (Sandbox Code Playgroud)
但是,由于我一直得到这个例外,这对我没有好处.
我也试过这个:
var bitmapImage …Run Code Online (Sandbox Code Playgroud) 我试图从JPG中提取BitmapImage.这是我的代码:
FileStream fIn = new FileStream(sourceFileName, FileMode.Open); // source JPG
Bitmap dImg = new Bitmap(fIn);
MemoryStream ms = new MemoryStream();
dImg.Save(ms, ImageFormat.Jpeg);
image = new BitmapImage();
image.BeginInit();
image.StreamSource = new MemoryStream(ms.ToArray());
image.EndInit();
ms.Close();
Run Code Online (Sandbox Code Playgroud)
图像以0×0图像返回,这当然意味着它不起作用.我该怎么做呢?
bitmapimage ×10
c# ×6
.net ×3
bitmap ×3
wpf ×3
image ×2
android ×1
bytearray ×1
drawing ×1
inno-setup ×1
jpeg ×1
locked ×1
picturebox ×1
pixels ×1
vb.net ×1