/// <summary> /// Sets the color-space of the output image. /// </summary> /// <param name="colorSpace">The target color-space.</param> /// <exception cref="ArgumentException"><paramref name="colorSpace"/> is invalid.</exception> /// <exception cref="NotSupportedException"><paramref name="colorSpace"/> is not supported by the encoder.</exception> /// <seealso cref="ImageUtil.GetSupportedColorSpaces(ImageFormat)"/> /// <since_tizen> 4 </since_tizen> public void SetColorSpace(ColorSpace colorSpace) { ValidationUtil.ValidateEnum(typeof(ColorSpace), colorSpace, nameof(colorSpace)); if (ImageUtil.GetSupportedColorSpaces(OutputFormat).Contains(colorSpace) == false) { throw new NotSupportedException($"{colorSpace.ToString()} is not supported for {OutputFormat}."); } NativeEncoder.SetColorspace(Handle, colorSpace.ToImageColorSpace()). ThrowIfFailed("Failed to set the color space"); }
public static int CalculateBufferSize(Size resolution, ColorSpace colorSpace) { if (resolution.Width <= 0) { throw new ArgumentOutOfRangeException(nameof(resolution), resolution.Width, "width can't be less than or equal to zero."); } if (resolution.Height <= 0) { throw new ArgumentOutOfRangeException(nameof(resolution), resolution.Height, "height can't be less than or equal to zero."); } ValidationUtil.ValidateEnum(typeof(ColorSpace), colorSpace, nameof(colorSpace)); uint bufferSize; global::Interop.ImageUtil.CalculateBufferSize(resolution.Width, resolution.Height, colorSpace.ToImageColorSpace(), out bufferSize) .ThrowIfFailed("Failed to calculate buffer size for given parameter"); return((int)bufferSize); }