2014-09-03 67 views
0

我已經建立使用存在於內存中 數據使用創建WIC位圖渲染目標

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

一個IWicBitmap一個IWicBitmap現在我想畫位圖這樣的IM創造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; 

回答

1

自己進入這個錯誤。錯誤代碼-2003292288實際上是WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT(0x88982F80)。 CreateWicBitmapRenderTarget方法不接受所有WIC的像素格式。

我在Windows 7和8.1箱實驗已經證明的方法似乎接受了以下WIC像素格式(如你所見,沒有灰色格式):

8bpp Alpha 
Guid: e6cd0116-eeba-4161-aa85-27dd9fb3a895 
Bits Per Pixel: 8 
Supports Transparency: True 
Numeric Representation: UnsignedInteger 
Channel Count: 1 

32bpp BGR 
Guid: 6fddc324-4e03-4bfe-b185-3d77768dc90e 
Bits Per Pixel: 32 
Supports Transparency: False 
Numeric Representation: UnsignedInteger 
Channel Count: 3 

32bpp RGB 
Guid: d98c6b95-3efe-47d6-bb25-eb1748ab0cf1 
Bits Per Pixel: 32 
Supports Transparency: False 
Numeric Representation: UnsignedInteger 
Channel Count: 3 

32bpp pBGRA 
Guid: 6fddc324-4e03-4bfe-b185-3d77768dc910 
Bits Per Pixel: 32 
Supports Transparency: True 
Numeric Representation: UnsignedInteger 
Channel Count: 4 

32bpp pRGBA 
Guid: 3cc4a650-a527-4d37-a916-3142c7ebedba 
Bits Per Pixel: 32 
Supports Transparency: True 
Numeric Representation: UnsignedInteger 
Channel Count: 4 

64bpp RGB 
Guid: a1182111-186d-4d42-bc6a-9c8303a8dff9 
Bits Per Pixel: 64 
Supports Transparency: False 
Numeric Representation: UnsignedInteger 
Channel Count: 3 

64bpp pRGBA 
Guid: 6fddc324-4e03-4bfe-b185-3d77768dc917 
Bits Per Pixel: 64 
Supports Transparency: True 
Numeric Representation: UnsignedInteger 
Channel Count: 4 

64bpp pRGBA half 
Guid: 58ad26c2-c623-4d9d-b320-387e49f8c442 
Bits Per Pixel: 64 
Supports Transparency: True 
Numeric Representation: Float 
Channel Count: 4 

64bpp RGB half 
Guid: 6fddc324-4e03-4bfe-b185-3d77768dc942 
Bits Per Pixel: 64 
Supports Transparency: False 
Numeric Representation: Float 
Channel Count: 3 

128bpp pRGBA float 
Guid: 6fddc324-4e03-4bfe-b185-3d77768dc91a 
Bits Per Pixel: 128 
Supports Transparency: True 
Numeric Representation: Float 
Channel Count: 4 

128bpp RGB float 
Guid: 6fddc324-4e03-4bfe-b185-3d77768dc91b 
Bits Per Pixel: 128 
Supports Transparency: False 
Numeric Representation: Float 
Channel Count: 3