Home > Software engineering >  Used wic can't paint the picture of the alpha channel
Used wic can't paint the picture of the alpha channel

Time:10-04

Use the following code to open a PNG image with alpha channel, but you can't draw transparent effect, why?
 
Retrieves the hr;

IWICBitmapDecoder * pDecoder=NULL;
PSource IWICBitmapFrameDecode *=NULL;
PStream IWICStream *=NULL;
IWICFormatConverter * pConverter=NULL;
IWICBitmapScaler * pScaler=NULL;

Hr=pIWICFactory - & gt; CreateDecoderFromFilename (
Uri,
NULL,
GENERIC_READ,
WICDecodeMetadataCacheOnLoad,
& PDecoder
);
If (SUCCEEDED (hr))
{

//Create the initial frame.
Hr=pDecoder - & gt; GetFrame (0, & amp; PSource);
}

If (SUCCEEDED (hr))
{
Hr=pIWICFactory - & gt; CreateFormatConverter (& amp; PConverter);
}
UINT originalWidth originalHeight;
Hr=pSource - & gt; GetSize (& amp; OriginalWidth, & amp; OriginalHeight);
If (SUCCEEDED (hr))
{

Hr=pIWICFactory - & gt; CreateBitmapScaler (& amp; PScaler);
If (SUCCEEDED (hr))
{
Hr=pScaler - & gt; The Initialize (
PSource,
OriginalWidth.
OriginalHeight,
WICBitmapInterpolationModeCubic
);
}
If (SUCCEEDED (hr))
{
Hr=pConverter - & gt; The Initialize (
PScaler,
GUID_WICPixelFormat32bppPRGBA,
WICBitmapDitherTypeNone,
NULL,
0 f,
WICBitmapPaletteTypeMedianCut
);
}
}
If (SUCCEEDED (hr))
{
//Create a Direct2D bitmap from the WIC bitmap.
Hr=pRenderTarget - & gt; CreateBitmapFromWicBitmap (pConverter, NULL, ppBitmap);
}

D2D1: : Matrix3x2F a=D2D1: : Matrix3x2F: : Scale (2, 2, D2D1: : Point2F (250, 250));
G_pRenderTarget - & gt; SetTransform (a);

G_pRenderTarget - & gt; DrawBitmap (pBitmap,
D2D1: : RectF (200 f, 200. F, 300 f, 300 f), 1.0 f,
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
D2D1: : RectF (00 00, 200 f, 200. F)
);

CodePudding user response:

No one know? Can be paid well
Qq 542772758
  • Related