Direct2D Intro - Load Bitmap From Resource
来源:互联网 发布:云上贵州大数据的意义 编辑:程序博客网 时间:2024/06/05 06:14
https://msdn.microsoft.com/en-us/library/windows/desktop/ee719657(v=vs.85).aspx
This topic demonstrates how to obtain a rectangular portion of an IWICBitmapSource using an IWICBitmapClipper component.
To clip a bitmap source
Create an IWICImagingFactory object to create Windows Imaging Component (WIC) objects.
C++Copy// Create WIC factoryhr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pIWICFactory) );
Use the CreateDecoderFromFilename method to create an IWICBitmapDecoder from an image file.
C++CopyHRESULT hr = S_OK;IWICBitmapDecoder *pIDecoder = NULL;IWICBitmapFrameDecode *pIDecoderFrame = NULL;hr = m_pIWICFactory->CreateDecoderFromFilename( L"turtle.jpg", // Image to be decoded NULL, // Do not prefer a particular vendor GENERIC_READ, // Desired read access to the file WICDecodeMetadataCacheOnDemand, // Cache metadata when needed &pIDecoder // Pointer to the decoder );
Get the first IWICBitmapFrameDecode of the image.
C++Copy// Retrieve the first bitmap frame.if (SUCCEEDED(hr)){ hr = pIDecoder->GetFrame(0, &pIDecoderFrame);}
The JPEG file format only supports a single frame. Because the file in this example is a JPEG file, the first frame (
0
) is used. For image formats that have multiple frames, seeHow to Retrieve the Frames of an Image for accessing each frame of the image.Create the IWICBitmapClipper to use for the image clipping.
C++CopyIWICBitmapClipper *pIClipper = NULL;if (SUCCEEDED(hr)){ hr = m_pIWICFactory->CreateBitmapClipper(&pIClipper);}
Initialize the clipper object with the image data within the given rectangle of the bitmap frame.
C++Copy// Create the clipping rectangle.WICRect rcClip = { 0, 0, uiWidth/2, uiHeight/2 };// Initialize the clipper with the given rectangle of the frame's image data.if (SUCCEEDED(hr)){ hr = pIClipper->Initialize(pIDecoderFrame, &rcClip);}
Draw or process the clipped image.
The following illustration demonstrates imaging clipping. The original image on the left is 200 x 130 pixels. The image on the right is the original image clipped to a rectangle defined as
{20,20,100,100}
.
- Direct2D Intro - Load Bitmap From Resource
- Direct2D Intro - Scale a Bitmap Source
- Direct2D Intro - Clip a Bitmap Source
- Direct2D Intro - Flip and Rotate a Bitmap Source
- Direct2D Intro - Modify the Pixels of a Bitmap Source
- Direct2D Intro - Retrieve the Frames from an Image
- Direct2D Intro - Draw a BitmapSource
- Direct2D draw bitmap
- Windows Dev Intro - Direct2D Compile Error
- XML Unable to load embedded resource from assembly解决方案
- Load any resource from any installed plugin of Eclipse
- How to Load Dialog From a Resource DLL?
- how-to-load-resource-from-jar-file-packaged-in-a-war-file
- C# Load DLL From Embedded Resource(把exe和dll捆绑起来)
- Could not load definitions from resource net/sf/antcontrib/antcontrib.properties.
- Resource、drawable、bitmap 转换
- webkit之Resource Load
- 关于Resource.load
- Reveal逆向工程:分析任意iOS应用的UI界面
- MySQL数据库引擎详解
- [C]常用字符串函数
- java package实验
- AR手机应用安装包大小优化
- Direct2D Intro - Load Bitmap From Resource
- 2. 变量和基本类型
- 走迷宫
- Android Wear API 中文 ---- 翻译目录
- Java之—— java mail 发送邮件 no object DCH for MIME type multipart/mixed 之正解
- 从客户端中检测到有潜在危险的 Request.Form 值
- spring mvc CommonsMultipartResolver文件上传maxUploadSize限制大小
- Python 中用 Ctrl+C 终止多线程程序的问题解决
- 百万连接之路