Duilib真彩色序列幀動畫。

2021-07-27 22:29:19 字數 4720 閱讀 7775

#ifndef imageanimui_h__

#define imageanimui_h__

#pragma once

#include

namespace duilib

; typedef

std::vector

animframelist;

cimageanimui(void);

~cimageanimui(void);

lpctstr getclass() const;

lpvoid getinte***ce(lpctstr pstrname);

void doinit() override;

void dopaint(hdc hdc, const rect& rcpaint) override;

void doevent(teventui& event) override;

void setvisible(bool bvisible = true ) override;

void setattribute(lpctstr pstrname, lpctstr pstrvalue) override;

void setbkimage(lpctstr pstrimage);

lpctstr getbkimage();

void setautoplay(bool bisauto = true );

bool isautoplay() const;

void setautosize(bool bisauto = true );

bool isautosize() const;

void playgif();

void pausegif();

void stopgif();

private:

void initgifimage();

void deletegif();

void ontimer( uint_ptr idevent );

void drawframe( hdc hdc ); // 繪製gif每幀

void loadanimxmlfromfile(lpctstr pstrgifpath);

void initanimxmlfrommemory( lpvoid pbuf,size_t dwsize );

gdiplus::image* loadimagefromfile(lpctstr pstrgifpath);

private:

uint m_nframeposition; // 當前放到第幾幀

cduistring m_aniname; //動畫名

cduistring m_bkimage;

bool m_biswebp;

bool m_bisautosize; // 是否自動根據設定大小

bool m_bisplaying;

animframelist m_framelist;

};}#endif // imageanimui_h__

#include "stdafx.h"

#include "uiimageanim.h"

#include "utils/thirdparty.h"

#include

#include

namespace duilib

cimageanimui::~cimageanimui(void)

lpctstr cimageanimui::getclass() const

lpvoid cimageanimui::getinte***ce( lpctstr pstrname )

void cimageanimui::doinit()

void cimageanimui::dopaint( hdc hdc, const rect& rcpaint )

drawframe( hdc );

}void cimageanimui::doevent( teventui& event )

void cimageanimui::setvisible(bool bvisible /* = true */)

void cimageanimui::setattribute(lpctstr pstrname, lpctstr pstrvalue)

else

if( _tcscmp(pstrname, _t("autosize")) == 0 )

else

ccontrolui::setattribute(pstrname, pstrvalue);

}void cimageanimui::setbkimage(lpctstr pstrimage)

lpctstr cimageanimui::getbkimage()

void cimageanimui::setautoplay(bool bisauto)

bool cimageanimui::isautoplay() const

void cimageanimui::setautosize(bool bisauto)

bool cimageanimui::isautosize() const

void cimageanimui::playgif()

}void cimageanimui::pausegif()

m_pmanager->killtimer(this, event_tiem_id);

this->invalidate();

m_bisplaying = false;

}void cimageanimui::stopgif()

m_pmanager->killtimer(this, event_tiem_id);

m_nframeposition = 0;

this->invalidate();

m_bisplaying = false;

}void cimageanimui::initgifimage()

}void cimageanimui::deletegif()

}m_framelist.clear();

m_nframeposition = 0;

}void cimageanimui::ontimer( uint_ptr idevent )

void cimageanimui::drawframe( hdc hdc )

}void cimageanimui::loadanimxmlfromfile(lpctstr pstrgifpath)

else

if (!pdata)

initanimxmlfrommemory(pdata, dwsize);

delete pdata;

}void cimageanimui::initanimxmlfrommemory( lpvoid pbuf,size_t dwsize )

else

if( _tcscmp(pstrname, _t("loop")) == 0 )

else

if (_tcscmp(pstrname, _t("iswebp")) == 0)

} for( cmarkupnode node = root.getchild() ; node.isvalid(); node = node.getsibling() )

else

if( _tcscmp(pstrname, _t("time")) == 0 )

}if (ppathimage)}}

return ;

}gdiplus::image* cimageanimui::loadimagefromfile(lpctstr pstrgifpath)

else

if (!pdata)

gdiplus::image *pimg = nullptr;

if (m_biswebp)

else

}else

}delete pdata;

return pimg;

}}

這裡是配置檔案,要用到他直接在ui檔案裡這麼寫就行了。

<?xml version="1.0" encoding="ascii" standalone="yes" ?>

name="bkani"

loop="true">

image="snapshot/snapshot_0.png"

time="10"/>

image="snapshot/snapshot_1.png"

time="10"/>

image="snapshot/snapshot_2.png"

time="10"/>

image="snapshot/snapshot_3.png"

time="10"/>

image="snapshot/snapshot_4.png"

time="10"/>

animation>

由於專案還沒有上線,截圖不就不截了。。

注意:webp庫似乎能在vs2013的版本下使用,2012的版本只能是64位版本的(坑)。

24 32位真彩色

24 32位真彩色 1.24位定位 dword pixel addr 3 x y lpitch video buffer pixel addr blue video buffer pixel addr 1 green video buffer pixel addr 2 red 知識回顧 lpitch...

真彩色與偽彩色的概念

真彩色簡介 真彩色是指影象中的每個畫素 值都分成r g b三個基色分量,每個基色分量直接決定其基 色的強度,這樣產生的色彩稱為真彩色。計算機表示顏色也是用二進位制 16位色的髮色總數是65536色,也就是2的16次方 24位色被稱為真彩色,它可以達到人眼分辨的極限,髮色數是1677萬多色,也就是2的...

真彩色調色盤

執行開始 紅色綠色 藍色黑色 public class frmmain inherits system.windows.forms.form private sub frmmain load byval sender as system.object,byval e as system.eventa...