Table of Contents

Class OdfMediaManager

Namespace
OdfKit.Core
Assembly
OdfKit.dll

Provides the OdfMediaManager API. 管理 ODF 封裝中的媒體專案(如圖片),提供重複資料刪除與格式偵測功能。

public class OdfMediaManager
Inheritance
OdfMediaManager
Inherited Members

Constructors

OdfMediaManager(OdfPackage)

Performs odf media manager. 初始化 OdfMediaManager 類別的新執行個體。

public OdfMediaManager(OdfPackage package)

Parameters

package OdfPackage

ODF 封裝執行個體

Fields

PicturesEntryPrefix

The canonical package entry path prefix used for embedded media (e.g. images). 內嵌媒體(如圖片)於封裝中使用的規範項目路徑前綴。

public const string PicturesEntryPrefix = "Pictures/"

Field Value

string

Methods

AddImage(byte[])

Short overload of AddImage that accepts imageBytes; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 imageBytes;其餘可選參數使用預設值並轉呼叫最長 AddImage 多載。

public string AddImage(byte[] imageBytes)

Parameters

imageBytes byte[]

Returns

string

AddImage(byte[], string?)

Adds image. 插入圖片二進位資料。若圖片內容已存在,則會自動重用現有路徑,實現自動重複資料刪除。

public string AddImage(byte[] imageBytes, string? preferredName)

Parameters

imageBytes byte[]

圖片的二進位內容

preferredName string

偏好的檔名(若重複資料刪除未命中且未給定時會自動產生)

Returns

string

傳回該圖片在 ODF 封裝中的相對路徑(例如 "Pictures/image_hash.png" )

DetectImageFormat(byte[], out string, out string)

Detects image format. 根據檔案的幻數(Magic Bytes)偵測圖片格式。

public static void DetectImageFormat(byte[] bytes, out string mimeType, out string extension)

Parameters

bytes byte[]

圖片的二進位內容

mimeType string

輸出的 MIME 類型

extension string

輸出的副檔名,包含前導句點