TNB Library
TnbBitmapWipers.h
[詳解]
1#pragma once
13#include "TnbBitmapAnimater.h"
14
15
16
17//TNB Library
18namespace TNB
19{
20
21
22
34{
35 DEFSUPER(IBitmapWipable);
36public:
37
42 virtual IBitmapWipable* Clone(void) const { return new CShrinkWiper(); }
43
54 virtual CBitmapHandle Wipe(CBitmapHandle baseBmp, CBitmapHandle overBmp, UINT par, UINT max) const
55 {
56 CBitmapImage bi;
57 bi.Set(baseBmp);
58 const SIZE& size = bi.GetSize();
59 int cx = size.cx * (max - par) / max;
60 int cy = size.cy * (max - par) / max;
61 bi.Insert(-cx, -cy, overBmp, SRCCOPY, size.cx + cx * 2, size.cy + cy * 2);
62 return bi.GetBitmapHandle();
63 }
64};
65
66
67
79{
80 DEFSUPER(IBitmapWipable);
81 UINT m_pos;
82public:
83
88 CSlideWiper(UINT uPos = 5) : m_pos(uPos)
89 {
90 }
91
96 virtual IBitmapWipable* Clone(void) const { return new CSlideWiper(m_pos); }
97
108 virtual CBitmapHandle Wipe(CBitmapHandle baseBmp, CBitmapHandle overBmp, UINT par, UINT max) const
109 {
110 CBitmapImage bi;
111 bi.Set(baseBmp);
112 const SIZE& size = bi.GetSize();
113 int cx = size.cx * (max - par) / max;
114 int cy = size.cy * (max - par) / max;
115 if ( m_pos >= 7 )
116 {
117 cy = -cy;
118 }
119 else if ( m_pos >= 4 )
120 {
121 cy = 0;
122 }
123 switch ( m_pos % 3 )
124 {
125 case 2: cx = 0; break;
126 case 1: cx = -cx; break;
127 }
128 bi.Insert(cx, cy, overBmp, SRCCOPY);
129 return bi.GetBitmapHandle();
130 }
131};
132
133
134
148{
149 DEFSUPER(IBitmapWipable);
150protected:
160 virtual HRGN CreateMaskRgn(const SIZE& size, UINT par, UINT max) const = 0;
161
162public:
173 virtual CBitmapHandle Wipe(CBitmapHandle baseBmp, CBitmapHandle overBmp, UINT par, UINT max) const
174 {
175 CBitmapImage bi;
176 bi.Set(baseBmp);
177 if ( ! bi.IsEmpty() )
178 {
179 HRGN hRgn = CreateMaskRgn(bi.GetSize(), par, max);
180 if ( hRgn != NULL )
181 {
182 HDC dc = bi.GetDC();
183 ::SelectClipRgn(dc, hRgn);
184 CBitmapImage b(overBmp);
185 b.Draw(dc, 0, 0);
186 ::SelectClipRgn(dc, NULL);
187 bi.ReleaseDC();
188 _DeleteObject(hRgn);
189 }
190 }
191 return bi.GetBitmapHandle();
192 }
193};
194
195
196
208{
209 DEFSUPER(CAbstractMaskWiper);
210 UINT m_pos;
211protected:
221 virtual HRGN CreateMaskRgn(const SIZE& size, UINT par, UINT max) const
222 {
223 HRGN rgn = ::CreateRectRgn(0, 0, size.cx, size.cy);
224 int cx = size.cx * (max - par) / max;
225 int cy = size.cy * (max - par) / max;
226 if ( m_pos >= 7 )
227 {
228 cy = -cy;
229 }
230 else if ( m_pos >= 4 )
231 {
232 cy = 0;
233 }
234 switch ( m_pos % 3 )
235 {
236 case 2: cx = 0; break;
237 case 1: cx = -cx; break;
238 }
239 ::OffsetRgn(rgn, cx, cy);
240 return rgn;
241 }
242
243public:
244
249 CSlideMaskWiper(UINT p) : m_pos(p)
250 {
251 }
252
257 virtual IBitmapWipable* Clone(void) const
258 {
259 return new CSlideMaskWiper(m_pos);
260 }
261};
262
263
264
276{
277 DEFSUPER(CAbstractMaskWiper);
278 size_t m_size;
279 mutable LPRGNDATA m_pRgnData;
280 mutable CWorkMem m_rgnWork;
281protected:
282
292 virtual HRGN CreateMaskRgn(const SIZE& size, UINT par, UINT max) const
293 {
294 size_t len = m_size * m_size;
295 if ( m_pRgnData == NULL )
296 {
297 m_rgnWork.Resize(sizeof(RGNDATAHEADER) + sizeof(RECT) * len);
298 m_pRgnData = reinterpret_cast<LPRGNDATA>(m_rgnWork.Ref());
299 LPRECT pRect = reinterpret_cast<LPRECT>(m_pRgnData->Buffer);
300 int i = 0;
301 loop ( y, m_size )
302 {
303 loop ( x, m_size )
304 {
305 ::SetRect(&pRect[i++], ToInt(x), ToInt(y), ToInt(x + 1), ToInt(y + 1));
306 }
307 }
308 loop ( i, len )
309 {
310 INDEX m = rand() % len;
311 Swap(pRect[i], pRect[m]);
312 }
313 m_pRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
314 m_pRgnData->rdh.iType = RDH_RECTANGLES;
315 m_pRgnData->rdh.rcBound.left = 0;
316 m_pRgnData->rdh.rcBound.top = 0;
317 m_pRgnData->rdh.rcBound.right = size.cx;
318 m_pRgnData->rdh.rcBound.bottom = size.cy;
319 }
320 //
321 size_t c = len * par / max;
322 if ( c == 0 )
323 {
324 return NULL;
325 }
326 m_pRgnData->rdh.nRgnSize = ToDword(sizeof(RGNDATAHEADER) + sizeof(RECT) * c);
327 m_pRgnData->rdh.nCount = ToDword(c);
328 HRGN hTmpRgn = ::ExtCreateRegion(NULL, m_pRgnData->rdh.nRgnSize, m_pRgnData);
329 HRGN hRgn = ::CreateRectRgn(0, 0, 0, 0);
330 loop ( x, (size.cx / m_size) + 1 )
331 {
332 ::CombineRgn(hRgn, hRgn, hTmpRgn, RGN_OR);
333 ::OffsetRgn(hTmpRgn, ToInt(m_size), 0);
334 }
335 ::CombineRgn(hTmpRgn, hRgn, NULL, RGN_COPY);
336 loop ( y, (size.cy / m_size) )
337 {
338 ::OffsetRgn(hTmpRgn, 0, ToInt(m_size));
339 ::CombineRgn(hRgn, hRgn, hTmpRgn, RGN_OR);
340 }
341 _DeleteObject(hTmpRgn);
342 return hRgn;
343 }
344
345public:
346
351 CRandomMaskWiper(size_t size = 32) : m_size(size), m_pRgnData(NULL)
352 {
353 ASSERT0( size > 1, "CRandomMaskWiper", "1より大きい数値を指定してください。" );
354 }
355
358 {
359 if ( m_pRgnData != NULL )
360 {
361 m_pRgnData = NULL;
362 m_rgnWork.Free();
363 }
364 }
365
370 virtual IBitmapWipable* Clone(void) const
371 {
372 return new CRandomMaskWiper(m_size);
373 }
374};
375
376
377
378}; //TNB
ビットマップアニメ関係のヘッダ
#define loop(VAR, CNT)
loop構文.
Definition: TnbDef.h:343
マスク型抽象ワイプ処理クラス
virtual HRGN CreateMaskRgn(const SIZE &size, UINT par, UINT max) const =0
[作成] マスク領域作成.
virtual CBitmapHandle Wipe(CBitmapHandle baseBmp, CBitmapHandle overBmp, UINT par, UINT max) const
[変換] ワイプ.
HBITMAP型ハンドルハンドル
ビットマップイメージ管理クラス
bool IsEmpty(void) const
[確認] Empty状態確認.
bool Insert(int x, int y, const CBitmapImage &bmpimg, DWORD raster=SRCCOPY, int cx=0, int cy=0)
[挿入] イメージ挿入.
HDC GetDC(void)
[取得]デバイスコンテキストハンドル取得.
const SIZE & GetSize(void) const
[取得] イメージサイズ取得.
bool Set(int cx, int cy, COLORREF color=CLR_INVALID)
[設定] イメージ設定.
CBitmapHandle GetBitmapHandle(void)
[取得] ビットマップハンドル取得
bool ReleaseDC(void)
[設定] デバイスコンテキストハンドル返却.
bool Draw(HDC hdc, int x=0, int y=0) const
[処理] イメージ描画.
スライドマスクワイプ処理クラス
~CRandomMaskWiper(void)
デストラクタ
CRandomMaskWiper(size_t size=32)
コンストラクタ
virtual HRGN CreateMaskRgn(const SIZE &size, UINT par, UINT max) const
[作成] マスク領域作成.
virtual IBitmapWipable * Clone(void) const
[複製] クローン
縮小ワイプ処理クラス
virtual IBitmapWipable * Clone(void) const
[複製] クローン
virtual CBitmapHandle Wipe(CBitmapHandle baseBmp, CBitmapHandle overBmp, UINT par, UINT max) const
[変換] ワイプ.
スライドマスクワイプ処理クラス
CSlideMaskWiper(UINT p)
コンストラクタ
virtual HRGN CreateMaskRgn(const SIZE &size, UINT par, UINT max) const
2,4,6,8
virtual IBitmapWipable * Clone(void) const
[複製] クローン
スライドワイプ処理クラス
virtual IBitmapWipable * Clone(void) const
[複製] クローン
virtual CBitmapHandle Wipe(CBitmapHandle baseBmp, CBitmapHandle overBmp, UINT par, UINT max) const
[変換] ワイプ.
CSlideWiper(UINT uPos=5)
コンストラクタ
void Resize(size_t l)
[設定] サイズ再設定
Definition: TnbDef.h:672
void Free(void)
[設定] 解放.
Definition: TnbDef.h:652
const TYP * Ref(void) const
[取得] ポインタ取得
Definition: TnbDef.h:712
DWORD ToDword(LPCSTR lpsz, int iBase=10)
[変換] INT変換(ASCII/SJIS用).
Definition: TnbStrLib.h:395
int ToInt(LPCSTR lpsz, int iBase=10)
[変換] INT変換(ASCII/SJIS用).
Definition: TnbStrLib.h:367
void Swap(T &t1, T &t2)
[変換] スワッパー.
Definition: TnbDef.h:963
TNB Library
Definition: TnbDoxyTitle.txt:2
ビットマップワイパブルインターフェース