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

📄 colorref2.h

📁 C++ image processing.Mainly it occupies some filters to detect some prperties of image. Release.
💻 H
字号:
#ifndef COLROREF2_h
#define COLROREF2_h

/* 

This "SOFTWARE" is a free software.

You are allowed to download, use, modify and redistribute this software.
The software is provided "AS IS" without warranty of any kind.

Copyright: 2002, University of Koblenz-Landau, Dirk Balthasar

*/


#include <TypesWin32.h>

// COLORREF only defined in win32. We introduced COLORREF2 for compabibility reasons.
typedef DWORD COLORREF2;
#define RGB2(r,g,b)          ((COLORREF2)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
#define GetRValue2(rgb)      ((BYTE)(rgb))
#define GetGValue2(rgb)      ((BYTE)(((WORD)(rgb)) >> 8))
#define GetBValue2(rgb)      ((BYTE)((rgb)>>16))

/// access to colorref
namespace tools
{
	/// class ecapsulated access to CCOLORREF2access
	class CCOLORREF2access
	{
	public:
		/// combines red, green and blue component into a COLOREF2 structure
		static COLORREF2 PackRGB(unsigned char r, unsigned char g, unsigned char b)
		{
			return COLORREF2 RGB2(r,g,b);
		}
		/// read out red component of a COLORREF2 structure
		static unsigned char GetR(COLORREF2 pix)
		{
			return GetRValue2(pix);
		}
		/// read out green component of a COLORREF2 structure
		static unsigned char GetG(COLORREF2 pix)
		{
			return GetGValue2(pix);
		}
		/// read out blue component of a COLORREF2 structure
		static unsigned char GetB(COLORREF2 pix)
		{
			return GetBValue2(pix);
		}
	};

	/// let binary images act like rgb images
	class CBoolaccess
	{
	public:
		/// combines red, green, blue component into one bit
		static bool PackRGB(unsigned char r, unsigned char g, unsigned char b)
		{
			if (r > 128) return true;
			else
				return false;
		}
		/// returns 0 if pix = 0, 1 if pix > 0 
		static unsigned char GetR(bool pix)
		{
			if (pix) return 255;
			else 
				return 0;
		}
		/// returns 0 if pix = 0, 1 if pix > 0 
		static unsigned char GetG(bool pix)
		{
			if (pix) return 255;
			else 
				return 0;
		}
		/// returns 0 if pix = 0, 1 if pix > 0 
		static unsigned char GetB(bool pix)
		{
			if (pix) return 255;
			else 
				return 0;
		}
	};
};

#endif

⌨️ 快捷键说明

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