如何从图标中提取特定尺寸的图像? [英] How can I extract an image of a specific size from an icon?

查看:177
本文介绍了如何从图标中提取特定尺寸的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从多个图像的图标中提取特定大小或所有图像的图像?

How can I extract an image of a specific size or all images from an icon with multiple images?

推荐答案

不要说这个目的是什么,根据目的,有很多获取图标的方法可能会比另一种更好。

You don't say what the purpose of this is, and there are a number of ways of getting icons and one method may be better than another depending on the purpose.

但是,从任意文件中提取任意数量的大(32x32)和/或小(16x16)图标*,请使用 ExtractIconEx 功能。这可以让您从图标文件(.ico),EXE或DLL中提取这两种标准大小的一个或多个图标。一个图标文件可以包含多个图像,此功能将让您获得所有图像。

However, to extract any number of "large" (32x32) and/or "small" (16x16) icons* from an arbitrary file, use the ExtractIconEx function. This lets you extract one or more icons of either of these two standard sizes from an icon file (.ico), EXE, or DLL. An icon file can contain multiple images and this function will let you get all of them.

该函数将写入一个句柄数组,每个句柄可以分配给处理属性 TIcon 实例。然后,您可以使用 TIcon 方法如您以任何其他方式加载TIcon,通常情况。请注意,Delphi XE的新功能可以轻松地将其复制到位图中通过指定方法该文还显示了如何访问所有库存(内置/标准)Windows图标,如果这恰好是你之后。

The function will write to an array of handles, each of which you can assign to the Handle property of a TIcon instance. Then you can use the TIcon methods as you normally would if you'd loaded the TIcon any other way. Note that new to Delphi XE is the ability to copy it easily to a bitmap via the Assign method. That article also shows how to access all of the stock (inbuilt / standard) Windows icons, if that happens to be what you're after.

(旁注:我认为 TIcon 类可让您从文件加载 LoadFromFile 方法 - 这似乎从文档中缺少,但我确定它存在,从内存,只加载一个图标。)

(Side note: I think the TIcon class lets you load from a file via its LoadFromFile method - this seems to be missing from the documentation, but I'm pretty certain it exists. From memory, that only loads a single icon.)


(*)实际上,大和小可以
与32x32和16x16不同:使用

GetSystemMetrics
函数与 SM_CXICON
SM_CYICON SM_CXSMICON
SM_CYSMICON fl可以找出每种类型的
维度。

(*) Actually, "large" and "small" can be different to 32x32 and 16x16: use the GetSystemMetrics function with the SM_CXICON, SM_CYICON, SM_CXSMICON, and SM_CYSMICON flags to find out the dimensions of each type.

这篇关于如何从图标中提取特定尺寸的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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