using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Vanara.PInvoke;
public static partial class Shell32
{
/// Indicates the format of the resulting image.
[PInvokeData("imagetranscode.h", MSDNShortId = "NN:imagetranscode.ITranscodeImage")]
public enum TI_FLAGS
{
/// Convert the image to BMP format.
TI_BITMAP = 1,
/// Convert the image to JPEG format.
TI_JPEG = 2
}
/// Exposes a method that allows conversion to JPEG or bitmap (BMP) image formats from any image type supported by Windows.
// https://docs.microsoft.com/en-us/windows/win32/api/imagetranscode/nn-imagetranscode-itranscodeimage
[PInvokeData("imagetranscode.h", MSDNShortId = "NN:imagetranscode.ITranscodeImage")]
[ComImport, Guid("BAE86DDD-DC11-421c-B7AB-CC55D1D65C44"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(ImageTranscode))]
public interface ITranscodeImage
{
/// Converts an image to JPEG or bitmap (BMP) image format.
///
/// Type: IShellItem*
/// The Shell Item for the image to convert.
///
///
/// Type: UINT
/// The requested height in pixels. Should be less than or equal to the actual height of the original image. See Remarks.
///
///
/// Type: UINT
/// The requested width in pixels. Should be less than or equal to the actual width of the original image. See Remarks.
///
///
/// Type: TI_FLAGS
/// One of the following flags.
/// TI_BITMAP
/// Convert the image to BMP format.
/// TI_JPEG
/// Convert the image to JPEG format.
///
///
/// Type: IStream*
/// A stream to receive the converted image. The stream must be created by the calling code prior to calling TranscodeImage.
///
///
/// Type: UINT*
/// The actual width of the converted image.
///
///
/// Type: UINT*
/// The actual height of the converted image.
///
///
///
/// The aspect ratio of the original image is preserved. The new image is resized so that it will fit into a box of width
/// uiMaxWidth and height uiMaxHeight.
///
/// The image size will not be changed if the original image already fits in this bounding box.
/// If both uiMaxWidth and uiMaxHeight are zero, the returned image will be the same size as the original.
///
// https://docs.microsoft.com/en-us/windows/win32/api/imagetranscode/nf-imagetranscode-itranscodeimage-transcodeimage HRESULT
// TranscodeImage( [in] IShellItem *pShellItem, UINT uiMaxWidth, UINT uiMaxHeight, DWORD flags, IStream *pvImage, [out, optional]
// UINT *puiWidth, [out, optional] UINT *puiHeight );
void TranscodeImage([In] IShellItem pShellItem, uint uiMaxWidth, uint uiMaxHeight, TI_FLAGS flags, [In, Out] IStream pvImage, out uint puiWidth, out uint puiHeight);
}
/// CLSID_ImageTranscode
[ComImport, Guid("17B75166-928F-417d-9685-64AA135565C1"), ClassInterface(ClassInterfaceType.None)]
public class ImageTranscode { }
}