InlineShape的图像大小 [英] Image sizes for InlineShape

查看:149
本文介绍了InlineShape的图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在处理Word 2010中的图像,并且在尝试获取图像的原始大小(作为InlineShape)时发现这些数字具有误导性或错误。例如。当使用1024x768,96dpi图像(默认情况下在My Pictures中包含Windows
的图像之一)时,我可能会将图像调整大小(锁定宽高比)到Word报告的大小为281x210.75(有趣的是由于没有部分像素,我认为它实际上是向上舍入到211而且ScaleHeight和ScaleWidth
为37.0。

I've been working with images in Word 2010 lately, and have noticed when trying to get the original size of the image, as an InlineShape, that the numbers are misleading or wrong. E.g. when using a 1024x768, 96dpi image (one of those included with Windows by default in My Pictures), I might have the image resized (with the aspect ratio locked) to where Word reports the size as 281x210.75 (interesting as there are no partial pixels, I assume it is rounding up to 211 in reality) and a ScaleHeight and ScaleWidth of 37.0.

281不是1024的37%,并且210.75不是768的37%。此分辨率的比例在高度和宽度上均为27.44%。然而,当我在Word的布局对话框中查看大小时,它列出了2.93"x3.9"的高度和宽度,它们是原始8"x10.67"的
的36.64%。图片。因此属性不匹配。高度和宽度以像素为单位,ScaleHeight和ScaleWidth用于打印图像的大小。

281 is not 37% of 1024, and 210.75 is not 37% of 768. The scale at this resolution would be 27.44% for both height and width. However when I look at the size in Word's Layout dialog, it lists a height and width of 2.93"x3.9", which are 36.64% of the original 8"x10.67" image. So the properties are mismatched. Height and Width are in pixels, and ScaleHeight and ScaleWidth are for the size of the image as printed.

此外,如果我将ScaleHeight更改为100.0(这似乎相当于调用InlineShape.Reset ()),图像确实在文档中返回到完整大小(其中一部分在页面边缘被截断),但报告的大小现在为768x576。如果您
将此宽度视为打印时在页面上显示的宽度,因为部分被切除,768px对于宽度是正确的,但576对于高度不正确,因为图像的整个高度是可见。如果整个图像的768宽度为
,则高度为576。它不是,因此我希望大小为1024x768或768x768。为了记录,如果你想复制它,你应该知道我使用半英寸的边距。

Further, if I change the ScaleHeight to 100.0 (this seems equivalent to calling InlineShape.Reset()), the image does return to full size in the document (with part of it being cut off at the edge of the page), but the reported size is now 768x576. If you take this width as what will be displayed on the page as printed, since a portion is cut off, 768px is correct for the width, but 576 is not correct for the height as the entire height of the image is visible. The height would be 576 if the width of 768 was for the entire image. It is not, therefore I would expect a size of either 1024x768 or 768x768. For the record, if you want to replicate this, you should know I am using half-inch margins.

https:// social.msdn.microsoft.com/Forums/office/en-US/047c4ad4-d151-4dc8-af14-e934e651c6c6/how-to-get-the-original-image-information-form-a-inlineshape-object?forum= worddev

https://social.msdn.microsoft.com/Forums/office/en-US/047c4ad4-d151-4dc8-af14-e934e651c6c6/how-to-get-the-original-image-information-form-a-inlineshape-object?forum=worddev

这个问题的答案包含这些信息(Word的版本不清楚):"InlineShape类提供了Reset方法,允许删除对内联形状所做的任何更改(在你的情况下的图像)。然后,您可以阅读原始的
属性。"不幸的是,它与我所看到的不符。

This question's answer contains this information (which version of Word it's for is unclear): "The InlineShape class provides the Reset method which allows to remove any changes made to an inline shape (image in your case). Then you can read original properties." Unfortunately it doesn't match up with what I'm seeing.

除了将其保存到图像文件然后检查之外,有没有办法真正获得原始尺寸?或正确的当前大小?

Is there any way to actually get the original size except saving it off into an image file and then checking? Or the correct current size?

推荐答案

你好克里斯托弗

Hi Christopher

因为这不是真正的开发人员/编程问题 - "如何  Word管理大小信息" -  我认为您将有更好的机会接触到更广泛的公众,他们可能在最终用户论坛中拥有一些经验。可能是TechNet上的

As this is not really a Developer/Programming question - "how does Word manage size information" - I think you'll have a better chance of reaching a wider public that might have some experience with it in an end-user forum. Possibly on TechNet.

FWIW我怀疑涉及多种因素。 Word的版本肯定会发挥作用。某些功能可能来自较早的时间,这可能会影响测量尺寸(像素与英寸)。它还可能
有一些东西与Word如何插入图形文件有关。它可能会调整dpi,这会影响大小。并且我知道它调整尺寸以适合"容器"。 (例如,页边距或表格单元格)。所有这些都可能影响Word认为的初始
大小。

FWIW I suspect a number of factors are involved. The version of Word will certainly play a role. Some of the functionality probably comes from an earlier time, which might affect how size is being measured (pixels vs. inches). It may also have something to do with how Word inserts a graphics file. It may adjust dpi, which will affect size. And I know it adjusts size to fit the "container" (page margins or table cell, for example). All these could affect what Word considers the initial size.

您可以尝试检查文档底层的WordOpenXML。这可能会缓存一些UI中不可用的信息(这是反映给对象模型的信息)。如果是,您可以通过对象模型访问它。

You can try checking the WordOpenXML underlying the document. That might be caching some information that's not available in the UI (which is what reflects to the object model). If yes, you can access that via the object model.


这篇关于InlineShape的图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆