Skip to content

Instantly share code, notes, and snippets.

@rzhukov
rzhukov / rgb_hsi.h
Created February 21, 2014 06:05
RGB to HSI and HSI to RGB color space conversion
inline void HSI2RGB(double h, double s, double i, double* r, double* g, double* b)
{
double x = i * (1 - s);
if(h < 2 * M_PI / 3)
{
double y = i * (1 + (s * cos(h)) / (cos(M_PI / 3 - h)));
double z = 3 * i - (x + y);
*b = x; *r = y; *g = z;
}
else if(h < 4 * M_PI / 3)
@rzhukov
rzhukov / logger.h
Created February 12, 2014 08:38
Simple logger for C++ like qDebug()
#pragma once
#include <ostream>
#include <sstream>
class logstream
{
private:
int _logLevel;
struct log_buf
@rzhukov
rzhukov / gist:8951859
Created February 12, 2014 08:30
Gets path to application
CString GetAppPath()
{
CString fullPath;
DWORD pathLen = ::GetModuleFileName( NULL, fullPath.GetBufferSetLength(MAX_PATH+1), MAX_PATH); // hmod of zero gets the main EXE
fullPath.ReleaseBuffer( pathLen );
PathRemoveFileSpec(fullPath.GetBuffer());
fullPath.ReleaseBuffer();
return fullPath;
}