⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ic_dec.h

📁 实时监控
💻 H
字号:
#ifndef _IC_DEC_H
#define _IC_DEC_H

#include "vfw.h"
#pragma comment(lib,"vfw32.lib")
#include "is.h"

struct bih: public BITMAPINFOHEADER
{
public:
	bih()
	{
		init();
	}
	void init()
	{
		biSize = init_struct(*this);
		biPlanes = 1;
	}
	void set_size(int w, int h)
	{
		biWidth = w;
		biHeight = h;
	}
	void set_bytes(DWORD bytes)
	{
		biSizeImage = bytes;
	}
	// fcc: 0 indicates RGB
	void set_fcc(DWORD fcc, int bitcount)
	{
		biCompression = fcc;
		biBitCount = bitcount;
	}
};

class ic_dec
{
	HIC h;
	bih bi;	// bih_in
	bih bo;	// bih_out

	void init()
	{
		bi.init();
		bi.init();
	}
public:
	ic_dec():h(NULL){}
	~ic_dec(){destroy();}

	bool create(int in_w, int in_h, DWORD in_fcc, DWORD out_fcc, int out_bitcount)
	{
		if( h )
			return true;
		h = ICOpen(ICTYPE_VIDEO, in_fcc, ICMODE_DECOMPRESS);
		if( !h )
			return false;

		bi.set_size(in_w, in_h);
		bi.set_fcc(in_fcc, 0);

		bo.set_size(in_w, in_h);
		bo.set_fcc(out_fcc, out_bitcount);
		bo.set_bytes(in_w*in_h*out_bitcount/8);
		return true;
	}
	void destroy(){if(h) {ICClose(h); h = NULL;}}

	bool begin()
	{
		int err = ICDecompressBegin(h, &bi, &bo);
		if( err != ICERR_OK )
			return false;
		
		return true;
	}
	void end()
	{
		ICDecompressEnd(h);
	}

	bool decode(void* in_buf, DWORD in_bytes, void* out_buf)
	{
		bi.set_bytes(in_bytes);
		if( ICERR_OK != ICDecompress(h, 0, &bi, in_buf, &bo, out_buf) )
			return false;
		return true;
	}
};
#endif	// _IC_DEC_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -