Excel+powerpoint 如何决定重新缩放粘贴为图像的范围?
我注意到,当您复制 Excel 中的范围(复制为图片 - 如屏幕所示)并将其粘贴到 PowerPoint 中时,生成的图像不会 100% 缩放为原始图像(右键单击图像,转到格式设置并转到尺寸以查看比例信息)。
此外,这种缩放比例在不同的计算机上有所不同(可能与显卡有关)。如果您有不同版本的 Office,每台计算机的缩放比例也会有所不同(即,在 Office 03 中,缩放比例为原始比例的 100%,在 Office 07 中,高度和宽度的缩放比例约为原始比例的 75% <---这些值可能会在您自己的计算机上有所不同)。
Office 如何在内部确定这些缩放比例是否有一些规律和推理?我问这个问题是因为我正在通过 c# 自动执行此复制+粘贴功能(使用互操作性内容)。我使用 CopyAsPicture 方法获取所选范围的高度 x 宽度,并将图像保存为 .emf 文件。然后,我使用之前存储的尺寸作为形状的尺寸,将图像加载到 PowerPoint 形状中。它粘贴它没有错误,但是当我将它与 excel 粘贴为图片的本机 ctrl+c 和 ctrl+v 进行比较时,大小不同。我得出的结论是,这是因为这个奇怪的缩放问题。
顺便说一句,在 C# 中,如果您告诉某个形状的大小为 100x100,然后插入它(使用形状的 AddPicture 方法),它在 PowerPoint 中实际上不会是 100x100。如果您随后将该图像复制并粘贴到 Paint 中以查看尺寸,则结果将完全不同(对于我的机器,它会将其放大 135%)。
有人知道发生了什么事吗?或者办公室如何决定这些扩展问题?
谢谢, 鲨鱼
I've noticed that when you copy a range in excel (copy as a picture - as shown on screen) and paste it into PowerPoint, the resulting image is not scaled 100% to the original image (right click on image, go to format settings and go to size to see scale info).
In addition, this scaling differs on different computers (might be related to graphics card). If you have different versions of Office the scaling also differs per computer (i.e. in Office 03, scaling is 100% of original, in Office 07, Scaling is ~75% of original for both height and width <---these values may differ on your own computer).
Is there some rhyme and reasoning to how these scalings are determined internally by Office? I ask because I am automating this copy+paste feature through c# (using the interop stuff). I use the CopyAsPicture method to get the height x width of the range selected and save the image as an .emf file. I then load the image into a PowerPoint shape using the dimensions I stored earlier as the dimensions of the shape. It pastes it in without an error, but when I compare it to a native ctrl+c and ctrl+v of excel's paste as picture, the size is different. I've concluded it is because of this weird scaling issue.
As an aside, in c#, if you tell some shape to be 100x100 in size, and insert it (using AddPicture method of shapes), it won't actually be 100x100 in PowerPoint. If you then copy and paste that image into paint to see the dimensions, it'll be something entirely different (for my machine, it upscales it by 135%).
Anyone got any idea what is going on? Or how office decides these scaling issues?
Thanks,
Shark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了我的逻辑中的一个缺陷:我不应该考虑缩放,而应该考虑绝对大小。我注意到的一件事是,无论缩放如何,通过本机复制和粘贴粘贴的图像的大小在所有计算机上的所有 Office 版本中都是一致的。经过进一步分析,我发现尺寸是通过两种方式确定的:
1)如果您选择“复制为图像”并设置“如屏幕上所示”,我将图像的高度和宽度(以像素为单位)除以96( dpi) 获取图像的尺寸(以英寸为单位)。我相信这个 DPI 是 Office 使用的默认值。然后为了将其转换为点,我需要将该图像乘以 72,因为我需要将其转换为 PowerPoint 在插入操作时期望的单位。完成此操作后,通过我的代码生成的图像与本机程序的图像相匹配。
2)如果您选择了“打印时所示”选项,我原来的方法将按照我们上面讨论的那样使用图元文件分辨率来帮助获取大小。
摘要:
如屏幕所示
如打印时所示
I figured out a flaw in my logic: instead of looking at scaling, I should've looked at absolute size. One one of the things I noticed was that regardless of the scaling, the size of the pasted image through the native copy and paste was consistent throughout all the versions of office on all machines. With further analysis, I discovered that the size was determined in two ways:
1) If you selected "copy as image" with the setting for "as shown on screen", I divided the image's height and width (in pixels) by 96 (dpi) to get the size of the image in inches. I believe this DPI is the default value the Office uses. Then to get it into dots, I needed to multiply this image by 72, since I needed to convert it into the unit that PowerPoint expects on the insert operation. After doing this, the image through my code matched that of the native procedure.
2) If you had selected "as shown when printed" option, my original method worked as we discussed above using the metafiles resolution's to help get the size.
Summary:
For As Shown On Screen
For As Shown When Printed