fico

package module
v0.0.0-...-733f980 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 29 Imported by: 1

README

🔬 FileICOn @orcastor-previewer

支持文件

  • 图片(bmp、gif、jpg、jpeg、jp2、jpeg2000、png、tiff)
  • 图标( ico、 icns)
  • Windows可执行文件(exe、dll)、资源文件(mui、mun)
  • Linux可执行文件(*.desktop【*.AppImage、*.run】)
  • 📱 手机应用安装包( apk包、 ipa包)
  • 文件夹图标(autorun.inf、desktop.ini)
  • MacOSX程序(*.app)

特性列表

  • 特性:获取信息和图标方法剥离
    • 支持desktop.ini中IconResource的配置
  • 特性:支持获取png格式的图标
  • 特性:PE文件无图标的默认图标逻辑
  • 特性:PE文件获取图标的index逻辑
    • 支持index为负数是资源id的逻辑
  • 特性:支持icns转换ico逻辑
  • 特性:指定尺寸缩放逻辑
  • 特性:指定尺寸图标匹配逻辑
  • 特性:支持应用图标获取(参考:fabu-dev/fabu
    • 混淆后的apk获取图标
    • ipa获取图标逻辑
  • 修复:dll加载不到图标问题

    答: 在早期的 Windows 版本中,图标资源文件嵌入到目录中的某些 DLL 中C:\Windows\System32。自 Windows 10 版本 1903 起,它们已重新定位到: C:\Windows\SystemResources. 现在这些文件有一个新的扩展名,.mun而不是.mui (仍然存在于system32和syswow64子文件夹中。

    • 目前需要手动转成指定mun、mui资源文件获取图标
  • 修复:低于256宽度图标格式转换为PNG的支持(先转换为32位位图)(参考:获取exe *.ico文件中所有size的图片
  • 修复:获取准确的高度(BITMAPINFOHEADER中2倍高度掩码数据)
  • 修复:裁剪掉透明边缘(48x48的位图,实际只有32x32是不透明的)
  • 修复:默认图标获取其中的一个尺寸
  • 修复:RGBQUAD的Alpha通道为保留数据

如果要更新assets下的默认图标

安装 go-bindata 工具:

go install -u github.com/go-bindata/go-bindata/...

使用 go-bindata 将资源文件转换为 Go 代码:

go-bindata -o assets.go -pkg fico assets/...

Documentation

Overview

Code generated for package f2ico by go-bindata DO NOT EDIT. (@generated) sources: assets/CUI.ico assets/DLL.ico assets/GUI.ico

Index

Constants

View Source
const (
	SECTION_RESOURCES = ".rsrc"
	RT_ICON           = "3/"
	RT_GROUP_ICON     = "14/"
)

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func F2ICO

func F2ICO(w io.Writer, path string, cfg ...Config) error

func IMG2ICO

func IMG2ICO(w io.Writer, r io.Reader, cfg ...Config) error

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func PE2ICO

func PE2ICO(w io.Writer, path string, cfg ...Config) error

在 Windows 中,当匹配一个 EXE 文件的图标时,通常会选择其中的一个资源, 这个资源通常是包含在 PE 文件中的一组图标资源中的一个。 选择的资源不一定是具有最小 ID 的资源,而是根据一些规则进行选择。 Choosing an Icon: https://learn.microsoft.com/en-us/previous-versions/ms997538(v=msdn.10)?redirectedfrom=MSDN#choosing-an-icon

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Config

type Config struct {
	Format string // png or ico(default)
	Width  int    // 0 for all
	Height int    // 0 for all
	Index  *int   // 0 default, nil for all,enabled for PE only
}

type GRPICONDIR

type GRPICONDIR struct {
	ICONDIR
	Entries []RESDIR
}

type ICONDIR

type ICONDIR struct {
	Reserved uint16 // 保留字段,必须为0
	Type     uint16 // 图标类型,必须为1
	Count    uint16 // 图标数量
}

https://www.cnblogs.com/cswuyg/p/3603707.html https://www.cnblogs.com/cswuyg/p/3619687.html https://en.wikipedia.org/wiki/ICO_(file_format)#Header

type ICONDIRENTRY

type ICONDIRENTRY struct {
	IconCommon
	Offset uint32 // 图像数据的偏移量
}

type IconCommon

type IconCommon struct {
	Width      uint8  // 图标的宽度,以像素为单位
	Height     uint8  // 图标的高度,以像素为单位
	Color      uint8  // 色深,例如 16、256(0如果是256色)
	Reserved   uint8  // 保留字段
	Planes     uint16 // 颜色平面数
	BitCount   uint16 // 每个像素的位数
	BytesInRes uint32 // 图像数据的大小
}

type Info

type Info struct {
	IconFile  string
	FilePath  string
	IconIndex *int
}

func GetInfo

func GetInfo(path string) (info Info, err error)

type RESDIR

type RESDIR struct {
	IconCommon
	ID uint16 // 图像数据的ID
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL