smourier / DirectN

Direct interop Code for .NET Framework, .NET Core and .NET 5+ : DXGI, WIC, DirectX 9 to 12, Direct2D, Direct Write, Direct Composition, Media Foundation, WASAPI, CodecAPI, GDI, Spatial Audio, DVD, Windows Media Player, UWP DXInterop, WinUI3, etc.
MIT License
311 stars 28 forks source link

where is the Guid pixelFormat paramater define ? #49

Closed sgf closed 9 months ago

sgf commented 9 months ago
   public static IComObject<IWICBitmap> CreateBitmap(this IComObject<IWICImagingFactory> factory, int width, int height, Guid pixelFormat, WICBitmapCreateCacheOption option = WICBitmapCreateCacheOption.WICBitmapNoCache)
    {
        return (factory?.Object).CreateBitmap(width, height, pixelFormat, option);
    }

    public static IComObject<IWICBitmap> CreateBitmap(this IWICImagingFactory factory, int width, int height, Guid pixelFormat, WICBitmapCreateCacheOption option = WICBitmapCreateCacheOption.WICBitmapNoCache)
    {
        if (factory == null)
        {
            throw new ArgumentNullException("factory");
        }

        Guid pixelFormat2 = pixelFormat;
        factory.CreateBitmap((uint)width, (uint)height, ref pixelFormat2, option, out var ppIBitmap).ThrowOnError();
        return new ComObject<IWICBitmap>(ppIBitmap);
    }

i cant find the pixelFormat

smourier commented 9 months ago

DirectN has no intelligence, it exposes bindings for exising COM objects, here IWICImagingFactory::CreateBitmap method, so you need to go to official documentation to learn how it works.

Native Pixel Formats Overview

Note in this case, DirectN also defines the pixel formats usable from .NET https://github.com/smourier/DirectN/blob/master/DirectN/DirectN/Extensions/WICConstants.cs

If you're interested by WIC interop, this project goes further in that direction: https://github.com/smourier/WicNet/ (and it's based on DirectN too)

sgf commented 9 months ago

thank you very much