WPF JpegBitmapDecoder 创建不同的高度和宽度
我正在尝试读取 Jpeg 图像并使用以下代码将其绑定到矩形的 fill 属性:
Dim filePath as string = "PathToJpeg.jpg"
Dim imageStreamSource As New FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim decoder As New JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default)
Dim bitmapSource As BitmapSource = decoder.Frames(0)
当我用较小的图像读取此图像时,这可以正常工作。但是当我将其指向 3840 x 3024 的图形时,bitmmapSource.Height
读取 924,bitmapSource.Width
读取 1174
据我所知,几乎就像 1024x768 是上限
我在这里遗漏了一些明显的东西吗?
I'm attempting to read in a Jpeg image and bind it to a rectangle's fill property with the following code:
Dim filePath as string = "PathToJpeg.jpg"
Dim imageStreamSource As New FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim decoder As New JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default)
Dim bitmapSource As BitmapSource = decoder.Frames(0)
When I read this in with smaller images, this works ok. But when I point it to a graphic that's 3840 by 3024, bitmmapSource.Height
reads 924 and bitmapSource.Width
reads 1174
From what I can tell, it's almost like 1024x768 is the upper limit
Am I missing something obvious here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我真的不知道你为什么显式使用 JpegBitmapDecoder。我的 C# 代码非常简单:
BitmapSource 类提供两个宽度和高度属性:
宽度:以与设备无关的单位获取位图的宽度(每单位 1/96 英寸)。 (来自 MSDN)
PixelWidth:获取位图的宽度(以像素为单位)。(来自 MSDN)
我用 111 MPixel 图像对此进行了测试,效果很好。
I do not really know why you are using a JpegBitmapDecoder explicitly. My C# code for this is pretty simple:
The BitmapSource class offers two width and height properties:
Width: Gets the width of the bitmap in device-independent units (1/96th inch per unit). (From MSDN)
PixelWidth: Gets the width of the bitmap in pixels.(From MSDN)
I tested this with a 111 MPixel image and it works fine.