【问题标题】:create wic bitmap render target for a IWicBitmap为 IWicBitmap 创建 wic 位图渲染目标
【发布时间】:2022-03-18 21:24:37
【问题描述】:

我使用内存中的数据创建了一个 IWicBitmap 使用

hr=pFactory->CreateBitmapFromMemory(512,512,GUID_WICPixelFormat8bppGray,512,512*512,ptr,&Bitmap1)

现在我想在位图上绘图,所以我正在创建 bitmaprendertarget

hr= m_pDirect2dFactory->CreateWicBitmapRenderTarget(Bitmap1,props,&target);

但它没有形成目标 - 它返回错误:

-2003292288

我不明白如何解决它 我也设置了属性

D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties();
props.minLevel = D2D1_FEATURE_LEVEL_DEFAULT;
D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN,D2D1_ALPHA_MODE_IGNORE);
props.pixelFormat=pixelFormat;

【问题讨论】:

    标签: render wic


    【解决方案1】:

    我自己也遇到了这个错误。错误代码-2003292288 实际上是WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT (0x88982F80)。 CreateWicBitmapRenderTarget 方法不接受所有 WIC 的像素格式。

    我在 Windows 7 到 11 机器上的实验表明,该方法似乎接受以下 WIC 像素格式,用于您想要在其上创建渲染目标的原始位图(无论您在 D2D1_RENDER_TARGET_PROPERTIES 结构中指定什么格式)。如您所见,没有灰色格式:

    8bpp Alpha (GUID_WICPixelFormat8bppAlpha)
     Guid: e6cd0116-eeba-4161-aa85-27dd9fb3a895
     Bits Per Pixel: 8
     Supports Transparency: True
     Numeric Representation: UnsignedInteger
     Channel Count: 1
    
    32bpp BGR (GUID_WICPixelFormat32bppBGR)
     Guid: 6fddc324-4e03-4bfe-b185-3d77768dc90e
     Bits Per Pixel: 32
     Supports Transparency: False
     Numeric Representation: UnsignedInteger
     Channel Count: 3
    
    32bpp RGB (GUID_WICPixelFormat32bppRGB)
     (Requires Windows 8 or Windows 7 with Platform Update)
     Guid: d98c6b95-3efe-47d6-bb25-eb1748ab0cf1
     Bits Per Pixel: 32
     Supports Transparency: False
     Numeric Representation: UnsignedInteger
     Channel Count: 3
    
    32bpp pBGRA (GUID_WICPixelFormat32bppPBGRA)
     Guid: 6fddc324-4e03-4bfe-b185-3d77768dc910
     Bits Per Pixel: 32
     Supports Transparency: True
     Numeric Representation: UnsignedInteger
     Channel Count: 4
    
    32bpp pRGBA (GUID_WICPixelFormat32bppPRGBA)
     Guid: 3cc4a650-a527-4d37-a916-3142c7ebedba
     Bits Per Pixel: 32
     Supports Transparency: True
     Numeric Representation: UnsignedInteger
     Channel Count: 4
    
    64bpp RGB (GUID_WICPixelFormat64bppRGB)
     Guid: a1182111-186d-4d42-bc6a-9c8303a8dff9
     Bits Per Pixel: 64
     Supports Transparency: False
     Numeric Representation: UnsignedInteger
     Channel Count: 3
    
    64bpp pRGBA (GUID_WICPixelFormat64bppPRGBA)
     Guid: 6fddc324-4e03-4bfe-b185-3d77768dc917
     Bits Per Pixel: 64
     Supports Transparency: True
     Numeric Representation: UnsignedInteger
     Channel Count: 4
    
    64bpp pRGBA half (GUID_WICPixelFormat64bppPRGBAHalf)
     Guid: 58ad26c2-c623-4d9d-b320-387e49f8c442
     Bits Per Pixel: 64
     Supports Transparency: True
     Numeric Representation: Float
     Channel Count: 4
    
    64bpp RGB half (GUID_WICPixelFormat64bppRGBHalf)
     Guid: 6fddc324-4e03-4bfe-b185-3d77768dc942
     Bits Per Pixel: 64
     Supports Transparency: False
     Numeric Representation: Float
     Channel Count: 3
    
    128bpp pRGBA float (GUID_WICPixelFormat128bppPRGBAFloat)
     Guid: 6fddc324-4e03-4bfe-b185-3d77768dc91a
     Bits Per Pixel: 128
     Supports Transparency: True
     Numeric Representation: Float
     Channel Count: 4
    
    128bpp RGB float (GUID_WICPixelFormat128bppRGBFloat)
     Guid: 6fddc324-4e03-4bfe-b185-3d77768dc91b
     Bits Per Pixel: 128
     Supports Transparency: False
     Numeric Representation: Float
     Channel Count: 3
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-24
    • 2012-12-22
    • 2017-11-08
    • 1970-01-01
    • 2020-01-23
    • 2010-12-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多