(For more information, see the source)
Question! Why D2d 1.1 instead of 1.0?
Answer: D2d Special Effects
In direct2d 1.1, the id2d1effect interface is provided, allowing programmers to use real-time effects of hardware acceleration. This is almost the absolute reason for using D2d 1.1.
I don't know anything about commandlist or something.
The header file is d2d1effects. h, but please link "dxguid. lib" to the static library
Use id2d1devicecontext: createeffect to create a D2d effect,
You can use id2d1devicecontext: drawimage to render this effect.
D2d 1.1 provides many built-in effects, such as Gaussian blur. All built-in special effects are here.
Here we will briefly introduce several built-in special effects.
0. Summary
Input object:
See the interface provided by id2d1effect.
A D2d effect requires a limited number of input objects, and the input object can also make D2d effect (Setinputeffect),
It can also be a D2d image, such as id2d1bitmap1 (Setinput).
Input 0 images that can be generated using code, such as functional images and advanced fragment images.
Input 1 such as Gaussian blur to blur the input image. Most (probably) are 1
Input Multiple images, for example, combining multiple images
Control variable.
Of course, a special effect requires many control variables. For example, Gaussian Blur must require a quantity to control the Blur degree.
It inherits from id2d1properties and has setvalue and setvaluebyname to set variables.
The former uses offset index settings, and the latter uses string settings. In other words, C ++ has no reason to use the latter. There are both macros and enumerations. It must be
Other languages .....
Special Effect category:
Microsoft divides special effects into several categories, such as filter effects. Gaussian Blur is a filter. Category is not mandatory,
So you can understand.
Here are some built-in special effects:
1. Gaussian blur
Create:
M_pd2ddevicecontext-> createeffect (clsid_d2d1gaussianblur, & m_peffecttest );
Clsid_d2d1gaussianblur is the guid provided by the built-in special effects.
Set input:
M_peffecttest-> setinput (0, m_pbitmaptest );
0 indicates that the first input image is m_pbitmaptest.
The built-in Gaussian Blur has three control variables, which are defined in the "d2d1_gaussianblur_prop" enumeration class.
To dynamically control the degree, you need:
M_peffecttest-> setvalue (d2d1_gaussianblur_prop_standard_deviation, 2.33f );
Set the Blur level to 2.33
The other two can be viewed by yourself: the header file is clear.
A gray solemnly warned: too much coding will lead to blurred vision.
In addition. We need to dynamically change this amount. Changing the Blur degree over time is a good option, but it is too
Shame. We can create a slider to change the degree, but it is too troublesome. Click and slide directly in the window.
In this way, you only need to process Windows messages. Here you can process wm_mousemove and wm_lbuttondown.
Windows message processing is not in the scope of this article. You can search for details.
2. Targeted fuzzy search
Similarly.
Use guid: clsid_d2d1directionalblur
The only thing that hurts is that it is not a vector, but a "fuzzy degree" and "angle"... I think it is more convenient to use a vector.
(Too much coding will cause blurred vision .)
There are a lot of built-in functions, some of which are practical and some are not clear. You can take the time to introduce it again,
After all, what is powerful isCustom EffectsThis is the focus of this article.
Download example: click here
Direct2d 1.1 Development Notes Special Effects (1) Use D2d Special Effects