// blend1.cpp : DLL アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" #include #include #ifdef _MANAGED #pragma managed(push, off) #endif extern "C" { typedef unsigned char n_byte; int line_01[] ={252,244,220,188,82,46,22,8,4,12,36,68,174,210,234,248, 240,228,204,164,102,62,32,20,16,28,52,92,154,194,224,236, 216,200,184,148,118,88,60,44,40,56,72,108,138,168,196,212, 180,160,144,132,128,116,100,80,76,96,112,124,128,140,156,176, 73,93,109,121,131,143,159,179,183,163,147,135,125,113,97,77, 37,53,69,105,137,171,199,215,219,203,187,151,119,85,57,41, 13,25,49,89,153,193,227,239,243,231,207,167,103,63,29,17, 1,9,33,65,173,209,233,251,255,247,223,191,83,47,23,5, 3,11,35,67,175,211,235,249,253,245,221,189,81,45,21,7, 15,27,51,91,155,195,225,237,241,229,205,165,101,61,31,19, 39,55,71,107,139,169,197,213,217,201,185,149,117,87,59,43, 75,95,111,123,129,141,157,177,181,161,145,133,127,115,99,79, 182,162,146,134,126,114,98,78,74,94,110,122,130,142,158,178, 218,202,186,150,120,86,58,42,38,54,70,106,136,170,198,214, 242,230,206,166,104,64,30,18,14,26,50,90,152,192,226,238, 254,246,222,190,84,48,24,6,2,10,34,66,172,208,232,250}; int __stdcall get_blend_func_count(); char* __stdcall get_blend_func_key(int no); char* __stdcall get_blend_func_name(int no); void __stdcall blend(unsigned char* dst,const unsigned char* col,const unsigned char* alpha,int col_step ,int alpha_step,int num_channel,int num_pixel,int no); //追加する合成方法の数を返す。 int __stdcall get_blend_func_count() { return 1; } //psdファイルに保存するときのkeyを返す。 /* 'norm' = normal 'dark' = darken 'lite' = lighten 'hue ' = hue 'sat ' = saturation 'colr' = color 'lum ' = luminosity 'mul ' = multiply 'scrn' = screen 'diss' = dissolve 'over' = overlay 'hLit' = hard light 'sLit' = soft light 'diff' = difference 'smud' = exlusion 'div ' = color dodge 'idiv' = color burn */ char* __stdcall get_blend_func_key(int no) { if (no == 0) { return "dotw"; } return 0; } //合成方法の名前を返す。 char* __stdcall get_blend_func_name(int no) { if (no == 0) { return "600dpi 50線 黒白"; } return ""; } //合成を行う関数。 //num_channel チャンネル数。グレーモードの場合は1、カラーモードの場合は3 void __stdcall blend(unsigned char* dst,const unsigned char* col,const unsigned char* alpha,int col_step,int alpha_step ,int num_channel,int num_pixel,int no) { if (no == 0) { if (num_channel == 1) { const unsigned char* col_end = col + num_pixel * col_step; int li =0 ; int l_01; int l_w ; int l_h ; int l_h2 ; for(l_h2=0 ; l_h2 < 4 ; l_h2++){ for(l_h=0 ; l_h < 16 ; l_h++){ for(l_w=0 ; l_w < 4 ; l_w++){ for(l_01=0+li ; l_01 < 16+li ; l_01 ++){ unsigned int a1 = *alpha; int kido = (77 * *col + 150 * *col + 29 * *col) / 256;//輝度計算 double kido2 = (int)(255 - kido) * (*alpha/255.0) ; if(a1 != 0){ if(kido2 >= line_01[l_01]){ *dst = 0 ; } else { *dst = 255 ; } } alpha += alpha_step; col += col_step; dst += col_step; }} li +=16; } l_h=0 ; l_w=0 ; li =0 ; l_01=0 ; } } else if (num_channel == 3) { const unsigned char* col_end = col + num_pixel * col_step; // while (col < col_end) { int li =0 ; int l_01; int l_w ; int l_h ; int l_h2 ; for(l_h2=0 ; l_h2 < 4 ; l_h2++){ for(l_h=0 ; l_h < 16 ; l_h++){ for(l_w=0 ; l_w < 4 ; l_w++){ for(l_01=0+li ; l_01 < 16+li ; l_01 ++){ unsigned int a1 = *alpha; int kido = (77 * *(col + 2) + 150 * *(col + 1) + 29 * *col) / 256;//輝度計算 double kido2 = (int)(255 - kido) * (*alpha/255.0) ; if(a1 != 0){ if(kido2 >= line_01[l_01]){ *dst = 0 ; *(dst + 1) = 0 ; *(dst + 2) = 0 ; } else { *dst = 255 ; *(dst + 1) = 255; *(dst + 2) = 255; } } alpha += alpha_step; col += col_step; dst += col_step; }} li +=16; } l_h=0 ; l_w=0 ; li =0 ; l_01=0 ; } } } } //下のレイヤーと結合で使用される void __stdcall merge(n_byte* dst,const n_byte* col,const n_byte* base_col,const n_byte* alpha,const n_byte* base_alpha ,int col_step,int alpha_step,int base_alpha_step,int num_channel,int num_pixel,int no) { if (no == 0) { if (num_channel == 1) { const unsigned char* col_end = col + num_pixel * col_step; int li =0 ; int l_01=0; int l_w ; int l_h ; int l_h2 ; for(l_h2=0 ; l_h2 < 4 ; l_h2++){ for(l_h=0 ; l_h < 16 ; l_h++){ for(l_w=0 ; l_w < 4 ; l_w++){ for(l_01=0+li ; l_01 < 16+li ; l_01 ++){ unsigned int a1 = *alpha; int kido = (77 * *col + 150 * *col + 29 * *col) / 256;//輝度計算 double kido2 = (int)(255 - kido) * (*alpha/255.0) ; if(kido2 >= line_01[l_01] && a1 != 0){ *dst = 0 ; *(dst + 1) = 255 ; } else if (kido2 < line_01[l_01] && a1 != 0){ *dst = 255; *(dst + 1) = 255; } else { *dst = *base_col; *(dst + 1) = *base_alpha; } dst += 2; col += col_step; base_col += col_step; alpha += alpha_step; base_alpha += base_alpha_step; } } li +=16; } l_h=0 ; l_w=0 ; li =0 ; l_01=0 ; } } else if (num_channel == 3) { const unsigned char* col_end = col + num_pixel * col_step; int li =0 ; int l_01; int l_w ; int l_h ; int l_h2 ; for(l_h2=0 ; l_h2 < 4 ; l_h2++){ for(l_h=0 ; l_h < 16 ; l_h++){ for(l_w=0 ; l_w < 4 ; l_w++){ for(l_01=0+li ; l_01 < 16+li ; l_01 ++){ unsigned int a1 = *alpha; int kido = (77 * *(col + 2) + 150 * *(col + 1) + 29 * *col) / 256;//輝度計算 double kido2 = (int)(255 - kido) * (*alpha/255.0) ; if(kido2 >= line_01[l_01] && a1 != 0){ *dst = 0 ; *(dst + 1) = 0 ; *(dst + 2) = 0 ; *(dst + 3) = 255 ; } else if(kido2 < line_01[l_01] && a1 != 0){ *dst = 255; *(dst + 1) = 255; *(dst + 2) = 255; *(dst + 3) = 255; } else { *dst = *base_col; *(dst + 1) = *(base_col + 1); *(dst + 2) = *(base_col + 2); *(dst + 3) = *base_alpha; } dst += 4; col += col_step; base_col += col_step; alpha += alpha_step; base_alpha += base_alpha_step; }} li +=16; } l_h=0 ; l_w=0 ; li =0 ; l_01=0 ; } } } } } BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } #ifdef _MANAGED #pragma managed(pop) #endif