/// <summary> /// Setups the encoder and other properties before encoding each frame /// </summary> internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions) { PROPBAG2 propBag = new PROPBAG2(); PROPVARIANT propValue = new PROPVARIANT(); // There is only one encoder option supported here: if (_compressionMethod != c_defaultCompressionMethod) { try { propBag.Init("TiffCompressionMethod"); propValue.Init((byte)_compressionMethod); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize( frameEncodeHandle, encoderOptions )); }
internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions) { PROPBAG2 propBag = new PROPBAG2(); PROPVARIANT propValue = new PROPVARIANT(); // There are only two encoder options supported here: if (_transformation != c_defaultTransformation) { try { propBag.Init("BitmapTransform"); propValue.Init((byte)_transformation); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_qualityLevel != c_defaultQualityLevel) { try { propBag.Init("ImageQuality"); propValue.Init(((float)_qualityLevel) / 100.0f); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize( frameEncodeHandle, encoderOptions )); }
// End WMPhoto-Specific Encoder Parameter Properties /// <summary> /// Setups the encoder and other properties before encoding each frame /// </summary> internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions) { PROPBAG2 propBag = new PROPBAG2(); PROPVARIANT propValue = new PROPVARIANT(); if (_imagequalitylevel != c_defaultImageQualityLevel) { try { propBag.Init("ImageQuality"); propValue.Init((float)_imagequalitylevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_transformation != c_defaultTransformation) { try { propBag.Init("BitmapTransform"); propValue.Init((byte)_transformation); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_lossless != c_defaultLossless) { try { propBag.Init("Lossless"); propValue.Init((bool)_lossless); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_usecodecoptions != c_defaultUseCodecOptions) { try { propBag.Init("UseCodecOptions"); propValue.Init((bool)_usecodecoptions); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_qualitylevel != c_defaultQualityLevel) { try { propBag.Init("Quality"); propValue.Init((byte)_qualitylevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_subsamplinglevel != c_defaultSubsamplingLevel) { try { propBag.Init("Subsampling"); propValue.Init((byte)_subsamplinglevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_overlaplevel != c_defaultOverlapLevel) { try { propBag.Init("Overlap"); propValue.Init((byte)_overlaplevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_horizontaltileslices != c_defaultHorizontalTileSlices) { try { propBag.Init("HorizontalTileSlices"); propValue.Init((ushort)_horizontaltileslices); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_verticaltileslices != c_defaultVerticalTileSlices) { try { propBag.Init("VerticalTileSlices"); propValue.Init((ushort)_verticaltileslices); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_frequencyorder != c_defaultFrequencyOrder) { try { propBag.Init("FrequencyOrder"); propValue.Init((bool)_frequencyorder); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_interleavedalpha != c_defaultInterleavedAlpha) { try { propBag.Init("InterleavedAlpha"); propValue.Init((bool)_interleavedalpha); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_alphaqualitylevel != c_defaultAlphaQualityLevel) { try { propBag.Init("AlphaQuality"); propValue.Init((byte)_alphaqualitylevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_compresseddomaintranscode != c_defaultCompressedDomainTranscode) { try { propBag.Init("CompressedDomainTranscode"); propValue.Init((bool)_compresseddomaintranscode); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_imagedatadiscardlevel != c_defaultImageDataDiscardLevel) { try { propBag.Init("ImageDataDiscard"); propValue.Init((byte)_imagedatadiscardlevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_alphadatadiscardlevel != c_defaultAlphaDataDiscardLevel) { try { propBag.Init("AlphaDataDiscard"); propValue.Init((byte)_alphadatadiscardlevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_ignoreoverlap != c_defaultIgnoreOverlap) { try { propBag.Init("IgnoreOverlap"); propValue.Init((bool)_ignoreoverlap); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize( frameEncodeHandle, encoderOptions )); }
internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions) { PROPBAG2 propBag = new PROPBAG2(); PROPVARIANT propValue = new PROPVARIANT(); if (_imagequalitylevel != c_defaultImageQualityLevel) { try { propBag.Init("ImageQuality"); propValue.Init((float)_imagequalitylevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_transformation != c_defaultTransformation) { try { propBag.Init("BitmapTransform"); propValue.Init((byte) _transformation); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_lossless != c_defaultLossless) { try { propBag.Init("Lossless"); propValue.Init((bool)_lossless); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_usecodecoptions != c_defaultUseCodecOptions) { try { propBag.Init("UseCodecOptions"); propValue.Init((bool)_usecodecoptions); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_qualitylevel != c_defaultQualityLevel) { try { propBag.Init("Quality"); propValue.Init((byte)_qualitylevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_subsamplinglevel != c_defaultSubsamplingLevel) { try { propBag.Init("Subsampling"); propValue.Init((byte)_subsamplinglevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_overlaplevel != c_defaultOverlapLevel) { try { propBag.Init("Overlap"); propValue.Init((byte)_overlaplevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_horizontaltileslices != c_defaultHorizontalTileSlices) { try { propBag.Init("HorizontalTileSlices"); propValue.Init((ushort)_horizontaltileslices ); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_verticaltileslices != c_defaultVerticalTileSlices) { try { propBag.Init("VerticalTileSlices"); propValue.Init((ushort)_verticaltileslices ); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_frequencyorder != c_defaultFrequencyOrder) { try { propBag.Init("FrequencyOrder"); propValue.Init((bool)_frequencyorder); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_interleavedalpha != c_defaultInterleavedAlpha) { try { propBag.Init("InterleavedAlpha"); propValue.Init((bool)_interleavedalpha); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_alphaqualitylevel != c_defaultAlphaQualityLevel) { try { propBag.Init("AlphaQuality"); propValue.Init((byte)_alphaqualitylevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_compresseddomaintranscode != c_defaultCompressedDomainTranscode) { try { propBag.Init("CompressedDomainTranscode"); propValue.Init((bool)_compresseddomaintranscode); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_imagedatadiscardlevel != c_defaultImageDataDiscardLevel) { try { propBag.Init("ImageDataDiscard"); propValue.Init((byte)_imagedatadiscardlevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_alphadatadiscardlevel != c_defaultAlphaDataDiscardLevel) { try { propBag.Init("AlphaDataDiscard"); propValue.Init((byte)_alphadatadiscardlevel); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_ignoreoverlap != c_defaultIgnoreOverlap) { try { propBag.Init("IgnoreOverlap"); propValue.Init((bool)_ignoreoverlap); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize( frameEncodeHandle, encoderOptions )); }
internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions) { PROPBAG2 propBag = new PROPBAG2(); PROPVARIANT propValue = new PROPVARIANT(); // There is only one encoder option supported here: if (_interlaceOption != c_defaultInterlaceOption) { try { propBag.Init("InterlaceOption"); propValue.Init(_interlaceOption == PngInterlaceOption.On); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize( frameEncodeHandle, encoderOptions )); }
internal override void SetupFrame(SafeMILHandle frameEncodeHandle, SafeMILHandle encoderOptions) { PROPBAG2 propBag = new PROPBAG2(); PROPVARIANT propValue = new PROPVARIANT(); // There are only two encoder options supported here: if (_transformation != c_defaultTransformation) { try { propBag.Init("BitmapTransform"); propValue.Init((byte) _transformation); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } if (_qualityLevel != c_defaultQualityLevel) { try { propBag.Init("ImageQuality"); propValue.Init( ((float)_qualityLevel) / 100.0f); HRESULT.Check(UnsafeNativeMethods.IPropertyBag2.Write( encoderOptions, 1, ref propBag, ref propValue)); } finally { propBag.Clear(); propValue.Clear(); } } HRESULT.Check(UnsafeNativeMethods.WICBitmapFrameEncode.Initialize( frameEncodeHandle, encoderOptions )); }