随笔分类 -  Direct2D学习笔记

摘要:.NET中生成水印更好的方法 为了保护知识产权,防止资源被盗用,水印在博客、网店等场景中非常常见。 本文首先演示了基于 做正常操作。然后基于 /`WIC DirectWrite`,演示了一种全新、不同的“ 骚 ”操作。 方法1 给图片加水印 原生属于 的一部分,是Windows Only,但随着Nu 阅读全文
posted @ 2019-06-28 23:47 .NET骚操作 阅读(3177) 评论(4) 推荐(4)
摘要:DWrite可以高速地呈现文字:View Code #include "stdafx.h"class unicode_file{ PCWSTR m_view; UINT32 m_size;public: unicode_file(); ~unicode_file(); PCWSTR text() const; UINT32 size() const;};struct SampleWindow : DesktopWindow<SampleWindow>{ ComPtr<ID2D1SolidColorBrush> m_brush; ComPtr... 阅读全文
posted @ 2013-04-23 16:57 .NET骚操作 阅读(642) 评论(0) 推荐(0)
摘要:可以通过矩阵变换来给几何图形作平移(Translation)、旋转(Rotate)、扭曲(Skew)和大小变换(Scale):View Code #include "stdafx.h"struct SampleWindow : DesktopWindow<SampleWindow>{ ComPtr<ID2D1RectangleGeometry> m_geometry; ComPtr<ID2D1SolidColorBrush> m_brush; void CreateDeviceIndependentResources() { HR(m_f 阅读全文
posted @ 2013-04-22 23:11 .NET骚操作 阅读(629) 评论(0) 推荐(0)
摘要:通过ID2D1HwndRenderTarget,可以轻松地画作各种样式的长方形和椭圆形:View Code #include "Precompiled.h"#include "DesktopWindow.h"D2D1_COLOR_F const COLOR_BLUE = { 0.26f, 0.56f, 0.87f, 1.0f };D2D1_COLOR_F const COLOR_WHITE = { 1.0f, 1.0f, 1.0f, 1.0f };D2D1_COLOR_F const COLOR_BLACK = { 0.0f, 0.0f, 0.0f, 1 阅读全文
posted @ 2013-04-19 09:53 .NET骚操作 阅读(771) 评论(0) 推荐(0)
摘要:为方便,将D2D的一个基本类DesktopWindow写成如下所示:View Code #include "Precompiled.h"#include <d2d1.h>#include <wrl.h>#pragma comment(lib, "d2d1")using namespace D2D1;using namespace Microsoft::WRL;template<typename T>struct DesktopWindow : CWindowImpl<T, CWindow, CWinTraits& 阅读全文
posted @ 2013-04-18 13:21 .NET骚操作 阅读(642) 评论(0) 推荐(1)
摘要:Direct2D基于Windows窗体,因此必须了解一些基本的Windows窗体编程:首先,最基本的,可以使用Windows API写一个窗体:View Code #include <Windows.h>typedef LRESULT (* message_callback)(HWND, WPARAM, LPARAM);struct message_handler{ UINT message; message_callback handler;};static message_handler s_handlers[] = { { WM_PAINT, [] (HW... 阅读全文
posted @ 2013-04-18 13:09 .NET骚操作 阅读(650) 评论(0) 推荐(0)