實作 IWICDevelopRaw

IWICDevelopRaw

IWICDevelopRaw介面會公開原始影像處理特有的處理選項。 所有原始編解碼器都必須支援 IWICDevelopRaw 介面。 某些原始編解碼器可能無法支援此介面公開的每個設定,但您應該支援編解碼器能夠執行的所有設定。 每個原始編解碼器至少都必須實作 SetRotationSetRenderMode 方法。

此外,對於其他編解碼器而言是選擇性的方法和介面,強烈建議用於原始編解碼器。 其中包括容器層級解碼器類別上的 GetPreviewGetThumbnail 方法,以及框架層級解碼類別上的 IWICBitmapSourceTransform 介面。

使用 IWICDevelopRaw 方法所設定的設定,應該以與其他中繼資料保存方式一致的方式保存編解碼器,但您不應該覆寫原始的「快照」設定。 藉由保存中繼資料並實作 LoadParameterSetGetCurrentParameterSet,您可以啟用原始處理應用程式,以跨會話擷取和套用處理設定。

IWICDevelopRaw介面的主要用途是讓應用程式開發人員建置使用者介面,以調整原始參數,以便盡可能在不同編解碼器之間以一致的方式運作。 假設終端使用者會使用滑杆控制項來調整參數,其最小值和最大值會對應至參數的最小值和最大值。 若要支援這項作業,您應該努力將所有參數範圍視為線性。 若要確保滑杆控制項不過度敏感,您也應該盡可能支援每個參數的範圍,涵蓋最多 50% 的可能範圍。 例如,如果最大可能的對比範圍是從純灰色到純黑色和白色,且預設值對應至 0.0,則編解碼器所支援的最低範圍至少介於預設值與低端灰色 (–1.0) 之間,至少介於預設值與純黑色與白色之間的一半 (+1.0) 。

interface IWICDevelopRaw : IWICBitmapFrameDecode
{
   HRESULT QueryRawCapabilitiesInfo ( WICRawCapabilitiesInfo *pInfo );
   HRESULT LoadParameterSet ( WICRawParameterSet ParameterSet );
   HRESULT GetCurrentParameterSet ( IPropertyBag2 **ppCurrentParameterSet );
   HRESULT SetExposureCompensation ( double ev );
   HRESULT GetExposureCompensation ( double *pEV );
   HRESULT SetWhitePointRGB ( UINT Red, UINT Green, UINT Blue );
   HRESULT GetWhitePointRGB ( UINT *pRed, UINT *pGreen, UINT *pBlue );
   HRESULT SetNamedWhitePoint ( WICNamedWhitePoint WhitePoint );
   HRESULT GetNamedWhitePoint ( WICNamedWhitePoint *pWhitePoint );
   HRESULT SetWhitePointKelvin ( UINT WhitePointKelvin );
   HRESULT GetWhitePointKelvin ( UINT *pWhitePointKelvin );
   HRESULT GetKelvinRangeInfo ( UINT *pMinKelvinTemp,
               UINT *pMaxKelvinTemp,
               UINT *pKelvinTempStepValue );
   HRESULT SetContrast ( double Contrast );
   HRESULT GetContrast ( double *pContrast );
   HRESULT SetGamma ( double Gamma );
   HRESULT GetGamma ( double *pGamma );
   HRESULT SetSharpness ( double Sharpness );
   HRESULT GetSharpness ( double *pSharpness );
   HRESULT SetSaturation ( double Saturation );
   HRESULT GetSaturation ( double *pSaturation );
   HRESULT SetTint ( double Tint );
   HRESULT GetTint ( double *pTint );
   HRESULT SetNoiseReduction ( double NoiseReduction );
   HRESULT GetNoiseReduction ( double *pNoiseReduction );
   HRESULT SetDestinationColorContext (const IWICColorContext *pColorContext );
   HRESULT SetToneCurve ( UINT cbToneCurveSize,
               const WICRawToneCurve *pToneCurve );
   HRESULT GetToneCurve ( UINT cbToneCurveBufferSize,
               WICRawToneCurve *pToneCurve,
               UINT *pcbActualToneCurveBufferSize );
   HRESULT SetRotation ( double Rotation );
   HRESULT GetRotation ( double *pRotation );
   HRESULT SetRenderMode ( WICRawRenderMode RenderMode );
   HRESULT GetRenderMode ( WICRawRenderMode *pRenderMode ); 
   HRESULT SetNotificationCallback ( IWICDevelopRawNotificationCallback 
               *pCallback );
}

QueryRawCapabilitiesInfo

QueryRawCapabilitiesInfo 會傳回此原始檔案支援的一組功能。 WICRawCapabilitiesInfo結構的定義如下:

struct WICRawCapabilitiesInfo
{
   UINT cbSize;
   UINT CodecMajorVersion;
   UINT CodecMinorVersion;
   WICRawCapabilities ExposureCompensationSupport;
   WICRawCapabilities ContrastSupport;
   WICRawCapabilities RGBWhitePointSupport;
   WICRawCapabilities NamedWhitePointSupport;
   UINT NamedWhitePointSupportMask;
   WICRawCapabilities KelvinWhitePointSupport;
   WICRawCapabilities GammaSupport;
   WICRawCapabilities TintSupport;
   WICRawCapabilities SaturationSupport;
   WICRawCapabilities SharpnessSupport;
   WICRawCapabilities NoiseReductionSupport;
   WICRawCapabilities DestinationColorProfileSupport;
   WICRawCapabilities ToneCurveSupport;
   WICRawRotationCapabilities RotationSupport;              
}

此結構中使用的 WICRawCapabilities 列舉定義為:

enum WICRawCapabilities 
{   
   WICRawCapabilityNotSupported,
   WICRawCapabilityGetSupported,
   WICRawCapabilityFullySupported
}

最後一個欄位是 WICRawRotationCapabilities 列舉,定義為:

enum WICRawRotationCapabilities                    
{
   WICRawRotationCapabilityNotSupported,
   WICRawRotationCapabilityGetSupported,
   WICRawRotationCapabilityNinetyDegreesSupported
   WICRawRotationCapabilityFullySupported
}

LoadParameterSet

LoadParameterSet 可讓使用者指定是否要使用 As Shot 設定、使用使用者調整的設定,或要求解碼器自動校正影像。

enum WICRawParameterSet
{
   WICAsShotParameterSet,
   WICUserAdjustedParameterSet,
   WICAutoAdjustedParameterSet
}

GetCurrentParameterSet

GetCurrentParameterSet 會傳回具有目前參數集的 IPropertyBag2 。 接著,呼叫端可以將此參數設定為編碼器,以作為編碼器選項使用。

Set/GetExposureCompensation

GetExposureCompensationSetExposureCompensation 表示要套用至最終輸出的曝光補償。 EV 的有效範圍是 –5.0 到 +5.0 停止。

Set/GetCurrentParameterRGB、Set/GetNamedWhitePoint、Set/GetwhitePointKelvin

這些函式全都提供取得和設定白點的方法,可以是 RGB 值、預設具名值,或做為 Kelvin 值。 Kelvin 可接受的範圍是 1,500 – 30,000。

Set/GetContrast

GetContrastSetContrast 表示要套用至輸出的對比量。 指定對比的有效範圍是 –1.0 到 +1.0,預設對比為 0.0。

Set/GetGamma

GetGammaSetGamma 表示要套用的 Gamma。 Gamma 的有效範圍是 0.2 到 5.0,預設值為 1.0。 Gamma 通常會使用傳統的 Gamma 電源函數來實作, (具有 unity 取得) 的線性電源函式。 亮度隨著增加 Gamma 而增加,並隨著 Gamma 接近零而減少。 (請注意,最小值為非零,因為零會導致傳統 Gamma 計算中的除以零誤差。邏輯最小限制為 1/max,這就是為什麼最小值為 0.2.)

Set/GetSharpness

GetSharpnessSetSharpness 表示要套用的尖角量。 有效範圍是 –1.0 到 +1.0,0.0 是預設的尖角,而 –1.0 表示完全沒有尖角。

Set/GetSaturation

GetSaturationSetSaturation 表示要套用的飽和度量。 指定飽和度的有效範圍是 –1.0 到 +1.0,0.0 為正常飽和度,–1.0 代表完整還原,而 +1.0 代表完整飽和度。

Set/GetTint

GetTintSetTint 表示要套用的色調,位於綠色/紅色偏差上。 有效範圍是 –1.0 到 +1.0,綠色位於正數尺規的負端和放大鏡。 色調刻度定義為色彩溫度的正交。

Set/GetNoiseReduction

GetNoiseReductionSetNoiseReduction 表示要套用的雜訊減少量。 的有效範圍是 –1.0 到 +1.0,0.0 表示降低雜訊的預設量,–1.0 表示無雜訊降低,而 +1.0 表示最大雜訊降低。

SetDestinationColorCoNtext

SetDestinationColorCoNtext 指定要套用至影像的色彩設定檔。 您可以呼叫 GetColorCoNtexts 來擷取目前的色彩設定檔。

Set/GetToneCurve

GetToneCurveSetToneCurve 指定要套用的音調曲線。 假設點之間的線性插補。 pToneCurveWICRawToneCurve結構,其中包含WICRawToneCurvePoint結構的陣列,以及陣列中點數的計數。

struct WICRawToneCurve 
{
   UINT cPoints;
   WICRawToneCurvePoint aPoints[];
}

WICRawToneCurvePoint包含輸入值和輸出值。

struct WICRawToneCurvePoint 
{
   double Input;
   double Output;
}

當呼叫端在pToneCurve參數中傳遞Null時,您應該將WICRawToneCurve的必要大小傳回于azureActualToneCurveBufferSize參數中。

Set/GetRotation

GetRotationSetRotation 表示要套用的旋轉程度。 旋轉 90.0 會指定順時針旋轉 90 度。 (使用 SetRotation 和使用 CopyPixels 方法設定旋轉之間的差異在於,使用 SetRotation 設定的旋轉角度應該由編解碼器保存,而透過 CopyPixels 設定旋轉只會在記憶體中旋轉影像。

Set/GetRenderMode

GetRenderModeSetRenderMode 表示呼叫端所需的輸出品質等級。 當使用者調整參數時,如果套用變更,應用程式應該會顯示實際影像外觀非常快速的近似值。 為了達到此目的,影像通常會以螢幕解析度或更少顯示,而不是實際影像解析度,以提供立即的意見反應給使用者。 這是應用程式要求草稿模式品質的時機,因此這應該非常快速。 當使用者進行所有變更時,以草稿模式預覽這些變更,並決定使用目前的設定來解碼完整影像,應用程式會要求 Best Quality 解碼。 這通常也會要求列印。 當需要品質的速度之間合理的取捨時,應用程式會要求一般品質。

enum WICRawRenderMode
{
   WICRawRenderModeDraftMode,
   WICRawRenderModeNormalQuality ,
   WICRawRenderModeBestQuality
}

SetNotificationCallback

SetNotificationCallback 會在任何原始處理參數變更時,為解碼器註冊要呼叫的回呼函式。 IWICDevelopRawNotificationCallback的簽章只有一個稱為Notify的方法。 Notify 具有單一參數,這是一個遮罩,指出哪些原始處理參數已變更。

HRESULT Notify ( UINT NotificationMask );

OR 作業會在下列 NotificationMask 值上執行。

WICRawChangeNotification_ExposureCompensation
WICRawChangeNotification_NamedWhitePoint
WICRawChangeNotification_KelvinWhitePoint
WICRawChangeNotification_RGBWhitePoint
WICRawChangeNotification_Contrast
WICRawChangeNotification_Gamma
WICRawChangeNotification_Sharpness
WICRawChangeNotification_Saturation
WICRawChangeNotification_Tint
WICRawChangeNotification_NoiseReduction
WICRawChangeNotification_DestinationColorContext
WICRawChangeNotification_ToneCurve
WICRawChangeNotification_Rotation
WICRawChangeNotification_RenderMode

參考

IWICDevelopRaw

概念

實作 IWICBitmapSourceTransform

實作WIC-Enabled編碼器

如何撰寫WIC-Enabled CODEC

Windows 映像元件概觀