wpf 带图像的文本框

Is that enough TLAs (Three Letter Acronyms) in the title there? I continue to mentally deny the existence of DPI (dots per inch) as a concept. It's my own fault. I have been living on PCs at 96dpi for so many years, I just stopped caring. This problem we ran into is SO obvious after the fact, but it flummoxed us for a half-hour.

标题中是否有足够的TLA(三个字母缩写)? 我继续在精神上否认存在DPI(每英寸点数)这一概念。 是我自己的错我一直以96dpi的分辨率生活在PC上很多年了,我才停止关心它。 事实之后,我们遇到的这个问题非常明显,但却使我们困惑了半个小时。

I've been helping a buddy on a super-cool super secret WPF application and the window has multiple states - regular, compact, and minimized. We've got three transparent PNGs for these three buttons. The designer created them and sent them along.

我一直在帮助一个超级酷的超级秘密WPF应用程序的伙伴,并且该窗口具有多种状态-常规,紧凑和最小化。 对于这三个按钮,我们有三个透明的PNG。 设计师创建了它们并将其发送。

However, with one of them, it kept showing up at the wrong size, and was blurry. Even if we set the width and height ourselves, it looked totally wrong.

但是,在其中之一的情况下,它始终以错误的尺寸显示,并且模糊。 即使我们自己设置宽度和高度,也看起来完全错误。

Here's wrong:

这是错的:

Unrelated to the scaling issue, I saw that the file was 3099 bytes, which I thought was a little large. I opened it up in the Visual Studio binary hex editor and noticed that I could see strings like "Photoshop ICC profile" in the header. PNGs are lossless (they are like Bitmaps, not JPEGs) and while they compress, there are may ways they can compress, like removing crap from headers.

与缩放问题无关,我看到文件为3099字节,我认为这有点大。 我在Visual Studio二进制十六进制编辑器中将其打开,并注意到在标题中可以看到诸如“ Photoshop ICC配置文件”之类的字符串。 PNG是无损的(它们就像位图,而不是JPEG),并且在压缩时,可能有一些压缩方式,例如从标头中删除废话。

I like to run PNGOUT on all my PNGs as it'll try different techniques to make the PNG as small as possible without losing any data (without changing the way the PNG looks). I ran PNGOUT on the wrong file and it went from 3099 bytes to 292 bytes. It also just happened it look right afterwards.

我喜欢在所有PNG上运行PNGOUT,因为它会尝试不同的技术以使PNG尽可能小而不丢失任何数据(而不更改PNG的外观)。 我在错误的文件上运行了PNGOUT ,它从3099字节变为292字节。 它也恰好发生在之后。

Here's right:

没错:

So why did it look right suddenly? Turns out that PNGOUT also changes the DPI, without asking, to 96dpi. Here's a little C# program I wrote to test:

那么,为什么突然看起来正确呢? 事实证明,PNGOUT还将DPI(无需询问)更改为96dpi。 这是我编写的一个用于测试的C#程序:

static void Main(string[] args){    Image i = Image.FromFile(@"c:\users\scott\desktop\collapse-wrong.png");    Console.WriteLine(i.HorizontalResolution + " " + i.VerticalResolution);    Console.WriteLine(i.Width + " " + i.Height);

    Image i2 = Image.FromFile(@"c:\users\scott\desktop\collapse.png");    Console.WriteLine(i2.HorizontalResolution + " " + i2.VerticalResolution);    Console.WriteLine(i2.Width + " " + i2.Height);}

The output of this is:

输出为:

72.009 72.009
56 10
96 96
56 10

72.009 72.009 56 10 96 96 56 10

Both files are 56x10 in dimension, but the first is 72.009 dpi and the second is 96 dpi. WPF defaults to 96 dpi so when it encounters the 72 dpi image it scales it up. If you can't change the image, there are funky ways around it. Personally, I believe if you are running into this because of a designer/developer mismatch, then just coordinate between each other and decide on a DPI, probably 96. In our case, DPI didn't really matter as the designer was developing pixel-accurate images, so we just run PNGOUT on all the images.

两个文件的尺寸均为56x10,但第一个为72.009 dpi,第二个为96 dpi。 WPF默认为96 dpi,因此当遇到72 dpi图像时,它将放大。 如果您无法更改图像,则可以使用一些时髦的方法。 就个人而言,我认为如果您是由于设计者/开发者不匹配而遇到这种情况,那么就可以相互协调并决定一个DPI,大概是96。在我们的案例中,DPI并不重要,因为设计者正在开发像素-准确的图像,因此我们只对所有图像运行PNGOUT。

I usually run PNGOUT from Powershell, but there is a nice free .NET app called PNGGaunlet from Ben Hollis that provides a nice GUI frontend.

我通常从Powershell运行PNGOUT,但是Ben Hollis有一个不错的免费.NET应用程序,名为PNGGaunlet ,它提供了不错的GUI前端。

翻译自: https://www.hanselman.com/blog/be-aware-of-dpi-with-image-pngs-in-wpf-images-scale-weird-or-are-blurry

wpf 带图像的文本框

wpf 带图像的文本框_注意WPF中带有图像PNG的DPI-图像比例奇怪或模糊相关推荐

  1. 表单如何添加大的文本框_在 Flutter 中进行文本框的创建和设定

    文本框作为一个接收用户输入的组件,被广泛应用于表单构建.即时通讯.搜索等场景中. Flutter 提供了两个开箱即用的文本框组件:TextField 和 TextFormField. 1. 文本框 T ...

  2. python 文本框_重置Python中的文本框

    几个星期前,我在制作重置按钮时要求一些帮助,我是python的新手,还有一个Noob,主要是我在c& c#也是SQL反正我正在为游戏制作一个重置按钮,我无法让它工作.这是代码.问题似乎是它在发 ...

  3. html带滚动条的文本框自动滚,Powerpoint中实现带滚动条文本框的技巧

    在使用PowerPoint制作幻灯片时,会遇到这样的问题:一个图文并茂的幻灯片,左面是图,右面是说明文字,文字内容过多,不能全部展示:又如,产品演示,分成若干页,上翻下翻十分不便,放在一页又受版面限制 ...

  4. java 对齐文本框_如何对齐文本框和旁边的图像按钮

    一个文本框旁边一个按钮是很经常用到的网页内容,比如搜索框等等,而如果旁边的按钮使用图像的话,他们竖直方向就很不容易对齐,即使使用 vertical-align.padding和margin等都不行(特 ...

  5. C#带按钮的文本框TextBoxContainButton

    经常需要用到各种组合控件,每次组合太麻烦,通过打包成自定义控件,方便调用. 带按钮的文本框,如下图: 文本框内可以输入文本,响应文本框内容变化事件,按钮可以设置点击事件,图标 通过3个组合控件实现. ...

  6. python 获取excel文本框_简单使用python做excel多文件批量搜索(带图形界面)(已更新)...

    [Python] 纯文本查看 复制代码import xlwings as xw #引入xlwings处理excel from tkinter import * #引入tkinter处理界面 impor ...

  7. 在html中怎么在按回车的时候换到下一个文本框_史上最全的HTML、CSS知识点总结,浅显易懂。适合入门新手...

    一,html+css基础 1-1 Html和CSS的关系 学习web前端开发基础技术需要掌握:HTML.CSS.JavaScript语言.下面我们就来了解下这三门技术都是用来实现什么的: 1. HTM ...

  8. uniapp光标自动定义到文本框_特检自动化行吊静力检测方案

    主要测量功能使用徕卡测量开发的Windows版数据传输软件,通过蓝牙连接徕卡DISTO,经过简单的测量周期设置,即可实现自动化的距离检测.测量数据还可以输出Excel,甚至可以实时发送至PC运行的第三 ...

  9. uniapp光标自动定义到文本框_如何在Mac上的照片应用中创建自定义日历

    我花了很多时间为我最好的朋友考虑一份甜蜜的礼物.当我陷入沉思时,我想到了在Mac上使用"照片"应用制作自定义日历的想法.告诉你什么:我的朋友真的很喜欢个性化的日历,上面装饰着令人难 ...

最新文章

  1. JSP显示页面和数据库乱码
  2. 我要是长得和姚明一样高,是不是也能打进NBA?
  3. 西安交通大学计算机科学与技术学科评估,西安交通大学学科评估排名!附西安交大a类学科名单...
  4. linux安装vi 插件,Ubuntu上Vim安装NERDTree插件的详细操作步骤
  5. Blend Tree Type
  6. SAP TABLECONTROL 搜索帮助相关设置
  7. Java的运行机制分析!
  8. 论云计算机下的中小企业会计信息化建设,中小企业云会计信息化的建议论文
  9. tebluea 仪表板如何联动_报告厅音响设备和辅助设备.doc
  10. ARM嵌入式系统malloc的实现(C源码)
  11. nlp自然语言处理_不要被NLP Research淹没
  12. 梦笔记20211017
  13. 用文本挖掘剖析近5万首《全唐诗》
  14. 新浪微博下拉菜单制作(DOM小练习)
  15. CentOS7 ftp服务离线安装
  16. 圣诞节蓝牙耳机选哪款作为礼物比较好?耐用的蓝牙耳机推荐
  17. 【字体在哪个文件夹】Win7怎么安装字体
  18. 计算机二级选择题记忆知识点
  19. java list 子集_一个List的全部子集
  20. 点亮LED灯(STC89C52RC芯片)

热门文章

  1. 区块链技术性感依旧:咔咔房链想吃REITs这个大蛋糕
  2. 打印机错误0x00000bc4,Win11系统找不到打印机怎么办
  3. python制作字符画视频来啦~
  4. js 二叉树图形_JS实现二叉树 - 山海散客 - OSCHINA - 中文开源技术交流社区
  5. 最全整理!37 个 Python Web 开发框架总结
  6. 关于Python3的学习相关教程
  7. Python 数据采集、清洗、整理、分析以及可视化实战
  8. elasticsearch踩坑记录 no handler found for uri [http://localhost:9200/hyy/user/_search] and method [POST
  9. 如何不花money看到ieee的文章
  10. kafka启用Kerberos认证