Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Файл Test.cpp
- //Включаем заголовочный файл "windows.h" в проект.
- #include "windows.h"
- //Определяем идентификатор для экспорта функций.
- #define EXPORT __declspec(dllexport)
- //Точка входа в динамически-подключаемую библиотеку (DLL).
- BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
- {
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
- //Функция _HSB_to_RGB.
- EXPORT int __stdcall _HSB_to_RGB(double nH, double nS, double nL, int iScale1, int iScale2, int iScale3)
- {
- double nR = 0;
- double nG = 0;
- double nB = 0;
- int Sector = 0;
- double f = 0;
- double p = 0;
- double q = 0;
- double t = 0;
- nL /= iScale3;
- if (nS = 0)
- {
- nR = nL;
- nG = nR;
- nB = nR;
- }
- else
- {
- while (nH >= iScale1) {nH -= iScale1;}
- nS /= iScale2;
- nH /= iScale1 / 6;
- Sector = (int) nH; // так как тип переменной int, то атоматическое приведение
- f = nH - (double) Sector;
- p = nL * (1 - nS);
- q = nL * (1 - nS * f);
- t = nL * (1 - nS * (1 - f));
- switch (Sector)
- {
- case 0:
- nR = nL;
- nG = t;
- nB = p;
- break;
- case 1:
- nR = q;
- nG = nL;
- nB = p;
- break;
- case 2:
- nR = p;
- nG = nL;
- nB = t;
- break;
- case 3:
- nR = p;
- nG = q;
- nB = nL;
- break;
- case 4:
- nR = t;
- nG = p;
- nB = nL;
- break;
- default:
- nR = nL;
- nG = p;
- nB = q;
- }
- nR *= 255;
- nG *= 255;
- nB *= 255;
- }
- return nR;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement