//プロジェクト名overlayprn001 C++ソースファイルoverlayprn001.cpp //EXTERN CDECL CLONG createdc01(CSTRING,CINT,CINT,CINT,CINT) overlayprn001.dll //("プリンタ名",PAPERSIZE,ORIENTATION,DUPLEX,印刷ダイアログ0非表示1表示) //createdc01(char * printername01,int papersize01,int orientation01,int duplex01,int dlg01) //createdc01("",9,1,2,0) //プリンタ名 ""はデフォルト //用紙サイズ 0はデフォルト //DMPAPER_A3 = 8 //DMPAPER_A4 = 9 //DMPAPER_A4SMALL = 10 //DMPAPER_A5 = 11 //DMPAPER_B4 = 12 //DMPAPER_B5 = 13 //DMPAPER_JAPANESE_POSTCARD = 43 //用紙方向 0はデフォルト //DMORIENT_PORTRAIT = 1 //DMORIENT_LANDSCAPE = 2 //両面印刷 0はデフォルト //DMDUP_SIMPLEX = 1 //DMDUP_VERTICAL = 2 //DMDUP_HORIZONTAL = 3 //印刷ダイアログ 0は非表示 1は表示 #include #include #include #include "math.h" static char tempa[255]; static char tempb[255]; static char tempc[8192]; char * defaultprn = tempa; char * pDevice = tempb; LPDEVMODE pDevMode = (LPDEVMODE)tempc; PRINTDLG pd; extern "C" { __declspec(dllexport) char * yubar00(char * char01,char * char02); __declspec(dllexport) int yubar01(char * char01,char * file01); __declspec(dllexport) int barcode01(char * char01,int barwidth,int barheight,int guardbar,char * file01); __declspec(dllexport) HDC createdc01(char * printername01,int papersize01,int orientation01,int duplex01,int dlg01); __declspec(dllexport) void startdoc01( HDC hdc, char * string01); __declspec(dllexport) void overlaybmp( HDC hdc, int by1, int bx1, int by2, int bx2, char * string01); __declspec(dllexport) void overlaytext( HDC hdc, int ty1, int tx1, char * string01, int tr, int tg, int tb, char * string02, int th, int tw, int pitch, int bold, int ti, int tu, int ts, int angle1, int angle2); __declspec(dllexport) void overlaytextu( HDC hdc, int ty1, int tx1, char * string01, int tr, int tg, int tb, char * string02, int th, int tw, int pitch, int bold, int ti, int tu, int ts, int angle1, int angle2); __declspec(dllexport) void overlayline( HDC hdc, int ly1, int lx1, int ly2, int lx2, int lr, int lg, int lb, int width); __declspec(dllexport) void overlaycircle( HDC hdc, int cy1, int cx1, int cy2, int cx2, int cr, int cg, int cb, int width); __declspec(dllexport) void overlayrrect( HDC hdc, int cy1, int cx1, int cy2, int cx2, int cy3, int cx3, int cr, int cg, int cb, int width); __declspec(dllexport) void overlayrect( HDC hdc, int ry1, int rx1, int ry2, int rx2, int rr, int rg, int rb, int cr, int cg, int cb, int width); __declspec(dllexport) void overlaypie( HDC hdc, int py1, int px1, int py2, int px2, int pr, int pg, int pb, int angle1, int angle2, int cr, int cg, int cb, int width); char * yubar00(char * char01,char * char02) { unsigned int len01 = strlen(char01); if (len01>20) { * char02='\0'; return char02; } char buff01[21]; strcpy(buff01, char01); char buff02[22]; buff02[20]=0; buff02[21]=0; unsigned int src01=0; unsigned int dst01=0; while (dst01<20) { if (src01= '0') && (buff01[src01] <= '9')) { buff02[dst01] = buff01[src01]; dst01++; } else if (buff01[src01] == '-') { buff02[dst01] = buff01[src01]; dst01++; } else if ((buff01[src01] >= 'A') && (buff01[src01] <= 'J')) { buff02[dst01] = 'a'; dst01++; if (dst01>19) break; buff02[dst01] = buff01[src01]-'A'+'0'; dst01++; } else if ((buff01[src01] >= 'K') && (buff01[src01] <= 'T')) { buff02[dst01] = 'b'; dst01++; if (dst01>19) break; buff02[dst01] = buff01[src01]-'K'+'0'; dst01++; } else if ((buff01[src01] >= 'U') && (buff01[src01] <= 'Z')) { buff02[dst01] = 'c'; dst01++; if (dst01>19) break; buff02[dst01] = buff01[src01]-'U'+'0'; dst01++; } else { * char02='\0'; return char02; } src01++; } else { buff02[dst01] = 'd'; dst01++; } } int sum01 =0; src01=0; while (src01<20) { if ((buff02[src01] >= '0') && (buff02[src01] <= '9')) { sum01=sum01+buff02[src01]-'0'; } else if (buff02[src01] == '-') { sum01=sum01+10; } else if ((buff02[src01] >= 'a') && (buff02[src01] <= 'h')) { sum01=sum01+buff02[src01]-'a'+11; } src01++; } sum01=19-(sum01 % 19); if (sum01==19) sum01=0; if ((sum01>=0) && (sum01<=9)) buff02[20]='0'+sum01; else if (sum01==10) buff02[20]='-'; else if ((sum01>=11) && (sum01<=18)) buff02[20]='a'+sum01-11; len01=strlen(char02); if (len01>21) { memcpy(char02,buff02,21+1); } else { * char02='\0'; } return char02; } int yubar01(char * char01,char * file01) { unsigned int len01 = strlen(char01); if (len01>20) return -1; char buff01[21]; strcpy(buff01, char01); char buff02[22]; buff02[20]=0; buff02[21]=0; unsigned int src01=0; unsigned int dst01=0; while (dst01<20) { if (src01= '0') && (buff01[src01] <= '9')) { buff02[dst01] = buff01[src01]; dst01++; } else if (buff01[src01] == '-') { buff02[dst01] = buff01[src01]; dst01++; } else if ((buff01[src01] >= 'A') && (buff01[src01] <= 'J')) { buff02[dst01] = 'a'; dst01++; if (dst01>19) break; buff02[dst01] = buff01[src01]-'A'+'0'; dst01++; } else if ((buff01[src01] >= 'K') && (buff01[src01] <= 'T')) { buff02[dst01] = 'b'; dst01++; if (dst01>19) break; buff02[dst01] = buff01[src01]-'K'+'0'; dst01++; } else if ((buff01[src01] >= 'U') && (buff01[src01] <= 'Z')) { buff02[dst01] = 'c'; dst01++; if (dst01>19) break; buff02[dst01] = buff01[src01]-'U'+'0'; dst01++; } else return -2; src01++; } else { buff02[dst01] = 'd'; dst01++; } } int sum01 =0; src01=0; while (src01<20) { if ((buff02[src01] >= '0') && (buff02[src01] <= '9')) { sum01=sum01+buff02[src01]-'0'; } else if (buff02[src01] == '-') { sum01=sum01+10; } else if ((buff02[src01] >= 'a') && (buff02[src01] <= 'h')) { sum01=sum01+buff02[src01]-'a'+11; } src01++; } sum01=19-(sum01 % 19); if (sum01==19) sum01=0; if ((sum01>=0) && (sum01<=9)) buff02[20]='0'+sum01; else if (sum01==10) buff02[20]='-'; else if ((sum01>=11) && (sum01<=18)) buff02[20]='a'+sum01-11; char code01[73]; char code02[73]; char code03[73]; strcpy(code01, "0010"); strcpy(code02, "0011"); strcpy(code03, "0011"); src01=0; while (src01<21) { switch (buff02[src01]) { case '1': strcat(code01, "110"); strcat(code02, "111"); strcat(code03, "110"); break; case '2': strcat(code01, "101"); strcat(code02, "111"); strcat(code03, "110"); break; case '3': strcat(code01, "011"); strcat(code02, "111"); strcat(code03, "110"); break; case '4': strcat(code01, "110"); strcat(code02, "111"); strcat(code03, "101"); break; case '5': strcat(code01, "101"); strcat(code02, "111"); strcat(code03, "101"); break; case '6': strcat(code01, "011"); strcat(code02, "111"); strcat(code03, "101"); break; case '7': strcat(code01, "110"); strcat(code02, "111"); strcat(code03, "011"); break; case '8': strcat(code01, "101"); strcat(code02, "111"); strcat(code03, "011"); break; case '9': strcat(code01, "011"); strcat(code02, "111"); strcat(code03, "011"); break; case '0': strcat(code01, "100"); strcat(code02, "111"); strcat(code03, "100"); break; case '-': strcat(code01, "010"); strcat(code02, "111"); strcat(code03, "010"); break; case 'a': strcat(code01, "010"); strcat(code02, "111"); strcat(code03, "100"); break; case 'b': strcat(code01, "001"); strcat(code02, "111"); strcat(code03, "100"); break; case 'c': strcat(code01, "100"); strcat(code02, "111"); strcat(code03, "010"); break; case 'd': strcat(code01, "001"); strcat(code02, "111"); strcat(code03, "010"); break; case 'e': strcat(code01, "100"); strcat(code02, "111"); strcat(code03, "001"); break; case 'f': strcat(code01, "010"); strcat(code02, "111"); strcat(code03, "001"); break; case 'g': strcat(code01, "001"); strcat(code02, "111"); strcat(code03, "001"); break; case 'h': strcat(code01, "111"); strcat(code02, "111"); strcat(code03, "111"); break; default: return -3; } src01++; } strcat(code01, "01000"); strcat(code02, "11000"); strcat(code03, "11000"); unsigned long writesize01 = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)+8+36*28; BYTE * string01 = (BYTE *)calloc(1, writesize01); BITMAPFILEHEADER * fileheader = (BITMAPFILEHEADER *)string01; memset(fileheader, 0, sizeof(BITMAPFILEHEADER)); fileheader->bfType = ('M' << 8) | 'B'; fileheader->bfSize = writesize01; fileheader->bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)+8; BITMAPINFOHEADER * infoheader = (BITMAPINFOHEADER *)(string01 + sizeof(BITMAPFILEHEADER)); infoheader->biSize = 40; infoheader->biWidth = 36*8-6; infoheader->biHeight = 28; infoheader->biPlanes = 1; infoheader->biBitCount = 1; infoheader->biCompression = BI_RGB; infoheader->biSizeImage = 0; infoheader->biXPelsPerMeter = 0; infoheader->biYPelsPerMeter = 0; infoheader->biClrUsed = 2; infoheader->biClrImportant = 0; * (string01+54) = 0xFF; * (string01+55) = 0xFF; * (string01+56) = 0xFF; * (string01+58) = 0x0; * (string01+59) = 0x0; * (string01+60) = 0x0; int c = 62+36*8; int p = 0; while (p<71) { if (code03[p]=='1') * (string01+c) = * (string01+c) | 0xC0; if (code03[p+1]=='1') * (string01+c) = * (string01+c) | 0x0C; p++; p++; c++; } BYTE * src; BYTE * dst; unsigned int size01; size01 = 36; src = string01+62+36*8; dst = src+size01; c = 1; while (c <4) { memcpy( dst, src, size01 ); dst = dst+size01; c++; } c = 62+36*12; p = 0; while (p<71) { if (code02[p]=='1') * (string01+c) = * (string01+c) | 0xC0; if (code02[p+1]=='1') * (string01+c) = * (string01+c) | 0x0C; p++; p++; c++; } src = string01+62+36*12; dst = src+size01; c = 1; while (c <4) { memcpy( dst, src, size01 ); dst = dst+size01; c++; } c = 62+36*16; p = 0; while (p<71) { if (code01[p]=='1') * (string01+c) = * (string01+c) | 0xC0; if (code01[p+1]=='1') * (string01+c) = * (string01+c) | 0x0C; p++; p++; c++; } src = string01+62+36*16; dst = src+size01; c = 1; while (c <4) { memcpy( dst, src, size01 ); dst = dst+size01; c++; } FILE * fp01 = NULL; if((fp01=fopen(file01,"wb"))==NULL) { return(-1); } fwrite( string01, 1, writesize01, fp01); fclose(fp01); free(string01); return 0; } int barcode01(char * char01,int barwidth,int barheight,int guardbar,char * file01) { if (barwidth <= 1) barwidth = 1; if (barwidth >= 2) barwidth = 2; if (barheight <= 1) barheight = 1; if (barheight >= 128) barheight = 128; if (guardbar >= 64) guardbar = 64; char code00[16]; strcpy( code00, char01); char check01[16] = "x"; int sum01 =0; int c = 1; while (c<=6) { sum01 = sum01 + (code00[c*2-1]-'0')*3; c++; } c=1; while (c<=6) { sum01 = sum01 + (code00[c*2-2]-'0'); c++; } sum01 = 10 - (sum01 % 10); if (sum01 == 10) sum01 = 0; check01[0] = '0' + sum01; strcat( code00, check01); unsigned long writesize01 = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)+8+(barwidth*12+8)*(barheight+guardbar); BYTE * string01 = (BYTE *)calloc(1, writesize01); BITMAPFILEHEADER * fileheader = (BITMAPFILEHEADER *)string01; memset(fileheader, 0, sizeof(BITMAPFILEHEADER)); fileheader->bfType = ('M' << 8) | 'B'; fileheader->bfSize = writesize01; fileheader->bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)+8; BITMAPINFOHEADER * infoheader = (BITMAPINFOHEADER *)(string01 + sizeof(BITMAPFILEHEADER)); infoheader->biSize = 40; infoheader->biWidth = barwidth*96+40; infoheader->biHeight = barheight+guardbar; infoheader->biPlanes = 1; infoheader->biBitCount = 1; infoheader->biCompression = BI_RGB; infoheader->biSizeImage = 0; infoheader->biXPelsPerMeter = 0; infoheader->biYPelsPerMeter = 0; infoheader->biClrUsed = 2; infoheader->biClrImportant = 0; * (string01+54) = 0xFF; * (string01+55) = 0xFF; * (string01+56) = 0xFF; * (string01+58) = 0x0; * (string01+59) = 0x0; * (string01+60) = 0x0; char code01[16]; char code02[16]; int flag[96]; flag[0] = 1; flag[1] = 0; flag[2] = 1; switch (code00[0]) { case '0': strcpy( code01, "000000"); break; case '1': strcpy( code01, "001011"); break; case '2': strcpy( code01, "001101"); break; case '3': strcpy( code01, "001110"); break; case '4': strcpy( code01, "010011"); break; case '5': strcpy( code01, "011001"); break; case '6': strcpy( code01, "011100"); break; case '7': strcpy( code01, "010101"); break; case '8': strcpy( code01, "010110"); break; case '9': strcpy( code01, "011010"); break; default: strcpy( code01, "000000"); break; } int p; int i; p = 3; c = 0; while (c<=5) { if (code01[c] == '0') { switch (code00[c+1]) { case '0': strcpy( code02, "0001101"); break; case '1': strcpy( code02, "0011001"); break; case '2': strcpy( code02, "0010011"); break; case '3': strcpy( code02, "0111101"); break; case '4': strcpy( code02, "0100011"); break; case '5': strcpy( code02, "0110001"); break; case '6': strcpy( code02, "0101111"); break; case '7': strcpy( code02, "0111011"); break; case '8': strcpy( code02, "0110111"); break; case '9': strcpy( code02, "0001011"); break; default: strcpy( code02, "001101"); break; } } else { switch (code00[c+1]) { case '0': strcpy( code02, "0100111"); break; case '1': strcpy( code02, "0110011"); break; case '2': strcpy( code02, "0011011"); break; case '3': strcpy( code02, "0100001"); break; case '4': strcpy( code02, "0011101"); break; case '5': strcpy( code02, "0111001"); break; case '6': strcpy( code02, "0000101"); break; case '7': strcpy( code02, "0010001"); break; case '8': strcpy( code02, "0001001"); break; case '9': strcpy( code02, "0010111"); break; default: strcpy( code02, "0100111"); break; } } i = 0; while (i<=6) { if (code02[i]=='0') flag[p] = 0; else flag[p] = 1; p++; i++; } c++; } flag[45] = 0; flag[46] = 1; flag[47] = 0; flag[48] = 1; flag[49] = 0; p = 50; c = 0; while (c<=5) { switch (code00[c+7]) { case '0': strcpy( code02, "1110010"); break; case '1': strcpy( code02, "1100110"); break; case '2': strcpy( code02, "1101100"); break; case '3': strcpy( code02, "1000010"); break; case '4': strcpy( code02, "1011100"); break; case '5': strcpy( code02, "1001110"); break; case '6': strcpy( code02, "1010000"); break; case '7': strcpy( code02, "1000100"); break; case '8': strcpy( code02, "1001000"); break; case '9': strcpy( code02, "1110100"); break; default: strcpy( code02, "1110010"); break; } i = 0; while (i<=6) { if (code02[i]=='0') flag[p] = 0; else flag[p] = 1; p++; i++; } c++; } flag[92] = 1; flag[93] = 0; flag[94] = 1; flag[95] = 0; int chr00 = 0; int bit = 0; if (barwidth == 1) { c = 65+20*guardbar; p = 0; while (p<=95) { if (flag[p]) chr00 = chr00 + (int)pow(2, (double)(7-bit)); bit++; if (bit>=8) { * (string01+c) = chr00; c++; chr00 = 0; bit = 0; } p++; } } else { c = 65+32*guardbar; p = 0; while (p<=95) { if (flag[p]) chr00 = chr00 + (int)pow(2, (double)(7-bit)) + (int)pow(2, (double)(6-bit)); bit++; bit++; if (bit>=8) { * (string01+c) = chr00; c++; chr00 = 0; bit = 0; } p++; } } BYTE * src; BYTE * dst; unsigned int size01; if (guardbar>=1) { if (barwidth == 1) { size01 = 20; * (string01+65) = 0xA0; * (string01+70) = 0x02; * (string01+71) = 0x80; * (string01+76) = 0x0A; } else { size01 = 32; * (string01+65) = 0xCC; * (string01+76) = 0x0C; * (string01+77) = 0xC0; * (string01+88) = 0xCC; } src = string01+62; dst = src+size01; c = 1; while (c < guardbar) { memcpy( dst, src, size01 ); dst = dst+size01; c++; } } if (barwidth == 1) { size01 = 20; src = string01+62+20*guardbar; } else { size01 = 32; src = string01+62+32*guardbar; } dst = src+size01; c = 1; while (c < barheight) { memcpy( dst, src, size01 ); dst = dst+size01; c++; } FILE * fp01 = NULL; if((fp01=fopen(file01,"wb"))==NULL) { return(-1); } fwrite( string01, 1, writesize01, fp01); fclose(fp01); free(string01); return sum01; } HDC createdc01(char * printername01,int papersize01,int orientation01,int duplex01,int dlg01) { memset(&pd, 0, sizeof(PRINTDLG)); pd.lStructSize = sizeof(PRINTDLG); if (dlg01 == 0) pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC | PD_NOPAGENUMS | PD_NOSELECTION | PD_HIDEPRINTTOFILE | PD_RETURNDEFAULT; else pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC | PD_NOPAGENUMS | PD_NOSELECTION | PD_HIDEPRINTTOFILE; GetProfileString("windows", "device", "error", defaultprn, 250); int flag01 = 0; if (* printername01 != NULL) { char * param1,* param2; param1 = (char *)calloc(1,255); param2 = (char *)calloc(1,255); GetProfileString("devices", printername01, "error", param1, 250); if (strcmp(param1,"error") == 0) { free(param1); free(param2); return 0; } wsprintf(param2, "%s,%s", printername01, param1); WriteProfileString("windows","device", param2); // SendMessageTimeout(HWND_BROADCAST, WM_WININICHANGE, 0L, (LPARAM)(LPCTSTR)"windows", SMTO_NORMAL, 1000, NULL); flag01 = 1; free(param1); free(param2); } GetProfileString("windows", "device", "error", pDevice, 250); char * index02 = strstr(pDevice,","); * index02 = '\0'; HANDLE hPrinter; HWND hWnd=GetForegroundWindow(); if (!OpenPrinter(pDevice, &hPrinter, NULL)) { if (flag01 == 1) { WriteProfileString("windows","device", defaultprn); } return 0; } DWORD dwRet = DocumentProperties(hWnd, hPrinter, pDevice, pDevMode, NULL, DM_OUT_BUFFER); if (dwRet != IDOK) { ClosePrinter(hPrinter); if (flag01 == 1) { WriteProfileString("windows","device", defaultprn); } return 0; } if (pDevMode->dmFields & DM_PAPERSIZE) { if (papersize01 != 0) { pDevMode->dmPaperSize = papersize01; } } if (pDevMode->dmFields & DM_ORIENTATION) { if (orientation01 != 0) { pDevMode->dmOrientation = orientation01; } } if (pDevMode->dmFields & DM_DUPLEX) { if (duplex01 != 0) { pDevMode->dmDuplex = duplex01; } } dwRet = DocumentProperties(hWnd, hPrinter, pDevice, pDevMode, pDevMode, DM_IN_BUFFER | DM_OUT_BUFFER); ClosePrinter(hPrinter); if (dwRet != IDOK) { if (flag01 == 1) { WriteProfileString("windows","device", defaultprn); } return 0; } if (dlg01 == 0) { PrintDlg(&pd); ResetDC(pd.hDC,pDevMode); } else { pd.hDevMode=pDevMode; if (!PrintDlg(&pd)) { if (flag01 == 1) { WriteProfileString("windows","device", defaultprn); } return 0; } } if (flag01 == 1) { WriteProfileString("windows","device", defaultprn); } return (pd.hDC); } void startdoc01( HDC hdc, char * string01) { DOCINFO di; memset(&di, 0, sizeof(DOCINFO)); di.cbSize = sizeof(DOCINFO); di.lpszDocName = string01; di.lpszOutput=0; di.lpszDatatype=0; di.fwType=0; StartDoc( hdc, &di); return; } void overlaybmp( HDC hdc, int by1, int bx1, int by2, int bx2, char * string01) { SetGraphicsMode( hdc,GM_ADVANCED); SetBkMode( hdc,TRANSPARENT); SetStretchBltMode( hdc, COLORONCOLOR); int dpix=GetDeviceCaps( hdc,LOGPIXELSX); int dpiy=GetDeviceCaps( hdc,LOGPIXELSY); BITMAPFILEHEADER * fileheader; BITMAPINFOHEADER * infoheader; BITMAPINFO * info; BYTE * bitmap; BYTE * string02; FILE * fp01; struct stat stat01; if((fp01=fopen(string01,"rb"))==NULL) { return; } fstat(fileno(fp01),&stat01); string02=(BYTE *)malloc(stat01.st_size+1); fread(string02,1,stat01.st_size,fp01); string02[stat01.st_size]=0; fclose(fp01); fileheader = (BITMAPFILEHEADER *)string02; infoheader = (BITMAPINFOHEADER *)(string02 + sizeof(BITMAPFILEHEADER)); info = (BITMAPINFO *)infoheader; bitmap = string02 + fileheader->bfOffBits; StretchDIBits( hdc, (int)((dpix * bx1)/254), (int)((dpix * by1)/254), (int)((dpix * (bx2-bx1))/254), (int)((dpix * (by2-by1))/254), 0, 0, info->bmiHeader.biWidth, info->bmiHeader.biHeight, bitmap, info, DIB_RGB_COLORS, SRCCOPY); free(string02); return; } void overlaytext( HDC hdc, int ty1, int tx1, char * string01, int tr, int tg, int tb, char * string02, int th, int tw, int pitch, int bold, int ti, int tu, int ts, int angle1, int angle2) { int dpix=GetDeviceCaps( hdc,LOGPIXELSX); int dpiy=GetDeviceCaps( hdc,LOGPIXELSY); SetGraphicsMode( hdc,GM_ADVANCED); SetBkMode( hdc,TRANSPARENT); SetTextCharacterExtra(hdc , (int)((dpix * pitch)/2540)); HFONT hFont, hFontOld; int bold01; if (bold == 0) bold01 = 400; else bold01 = 700; hFont = CreateFont( -(dpiy * th)/720, (dpix * tw)/720, angle1, angle2, bold01, ti, tu, ts, SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FIXED_PITCH | FF_MODERN, string02); hFontOld = (HFONT)SelectObject( hdc, (HGDIOBJ)hFont); SetTextColor( hdc, RGB( tr, tg, tb)); TextOut( hdc, (int)((dpix * tx1)/254), (int)((dpiy * ty1)/254), string01, strlen(string01)); SelectObject( hdc, (HGDIOBJ)hFontOld); DeleteObject(hFont); return; } void overlaytextu( HDC hdc, int ty1, int tx1, char * string01, int tr, int tg, int tb, char * string02, int th, int tw, int pitch, int bold, int ti, int tu, int ts, int angle1, int angle2) { int dpix=GetDeviceCaps( hdc,LOGPIXELSX); int dpiy=GetDeviceCaps( hdc,LOGPIXELSY); SetGraphicsMode( hdc,GM_ADVANCED); SetBkMode( hdc,TRANSPARENT); SetTextCharacterExtra(hdc , (int)((dpix * pitch)/2540)); HFONT hFont, hFontOld; int bold01; if (bold == 0) bold01 = 400; else bold01 = 700; hFont = CreateFont( -(dpiy * th)/720, (dpix * tw)/720, angle1, angle2, bold01, ti, tu, ts, SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FIXED_PITCH | FF_MODERN, string02); hFontOld = (HFONT)SelectObject( hdc, (HGDIOBJ)hFont); SetTextColor( hdc, RGB( tr, tg, tb)); int n = MultiByteToWideChar( CP_UTF8, 0, string01, -1, NULL, 0); char * param1 = (char *)calloc( 1,n*2 + 2); MultiByteToWideChar( CP_UTF8, 0, string01, -1, (LPWSTR)param1, n+1); TextOutW( hdc, (int)((dpix * tx1)/254), (int)((dpiy * ty1)/254), (LPWSTR)param1, lstrlenW( (LPWSTR)param1)); SelectObject( hdc, (HGDIOBJ)hFontOld); DeleteObject(hFont); free(param1); return; } void overlayline( HDC hdc, int ly1, int lx1, int ly2, int lx2, int lr, int lg, int lb, int width) { int dpix=GetDeviceCaps( hdc,LOGPIXELSX); int dpiy=GetDeviceCaps( hdc,LOGPIXELSY); SetGraphicsMode( hdc,GM_ADVANCED); SetBkMode( hdc,TRANSPARENT); HPEN hPen; hPen = CreatePen(PS_SOLID, (int)((dpix * width)/2540), RGB( lr, lg, lb)); SelectObject( hdc, hPen); MoveToEx( hdc, (int)((dpix * lx1)/254), (int)((dpiy * ly1)/254), NULL); LineTo( hdc, (int)((dpix * lx2)/254), (int)((dpiy * ly2)/254)); DeleteObject(hPen); } void overlaycircle( HDC hdc, int cy1, int cx1, int cy2, int cx2, int cr, int cg, int cb, int width) { int dpix=GetDeviceCaps( hdc,LOGPIXELSX); int dpiy=GetDeviceCaps( hdc,LOGPIXELSY); SetGraphicsMode( hdc,GM_ADVANCED); SetBkMode( hdc,TRANSPARENT); SelectObject( hdc, GetStockObject(NULL_BRUSH)); HPEN hPen; hPen = CreatePen(PS_SOLID, (int)((dpix * width)/2540), RGB( cr, cg, cb)); SelectObject( hdc, hPen); Ellipse( hdc, (int)((dpix * cx1)/254), (int)((dpix * cy1)/254), (int)((dpix * cx2)/254), (int)((dpix * cy2)/254)); DeleteObject(hPen); } void overlayrrect( HDC hdc, int cy1, int cx1, int cy2, int cx2, int cy3, int cx3, int cr, int cg, int cb, int width) { int dpix=GetDeviceCaps( hdc,LOGPIXELSX); int dpiy=GetDeviceCaps( hdc,LOGPIXELSY); SetGraphicsMode( hdc,GM_ADVANCED); SetBkMode( hdc,TRANSPARENT); SelectObject( hdc, GetStockObject(NULL_BRUSH)); HPEN hPen; hPen = CreatePen(PS_SOLID, (int)((dpix * width)/2540), RGB( cr, cg, cb)); SelectObject( hdc, hPen); RoundRect( hdc, (int)((dpix * cx1)/254), (int)((dpix * cy1)/254), (int)((dpix * cx2)/254), (int)((dpix * cy2)/254), (int)((dpix * cx3)/254), (int)((dpix * cy3)/254)); DeleteObject(hPen); } void overlayrect( HDC hdc, int ry1, int rx1, int ry2, int rx2, int rr, int rg, int rb, int cr, int cg, int cb, int width) { int dpix=GetDeviceCaps( hdc,LOGPIXELSX); int dpiy=GetDeviceCaps( hdc,LOGPIXELSY); SetGraphicsMode( hdc,GM_ADVANCED); SetBkMode( hdc,TRANSPARENT); HBRUSH hBrush; hBrush = CreateSolidBrush( RGB( rr, rg, rb)); SelectObject( hdc, hBrush); HPEN hPen; hPen = CreatePen(PS_SOLID, (int)((dpix * width)/2540), RGB( cr, cg, cb)); SelectObject( hdc, hPen); Rectangle( hdc, (int)((dpix * rx1)/254), (int)((dpix * ry1)/254), (int)((dpix * rx2)/254), (int)((dpix * ry2)/254)); DeleteObject( hBrush); DeleteObject( hPen); } void overlaypie( HDC hdc, int py1, int px1, int py2, int px2, int pr, int pg, int pb, int angle1, int angle2, int cr, int cg, int cb, int width) { int dpix=GetDeviceCaps( hdc,LOGPIXELSX); int dpiy=GetDeviceCaps( hdc,LOGPIXELSY); SetGraphicsMode( hdc,GM_ADVANCED); SetBkMode( hdc,TRANSPARENT); HBRUSH hBrush; hBrush = CreateSolidBrush( RGB( pr, pg, pb)); SelectObject( hdc, hBrush); HPEN hPen; hPen = CreatePen(PS_SOLID, (int)((dpix * width)/2540), RGB( cr, cg, cb)); SelectObject( hdc, hPen); int r; if ((px2-px1)>=(py2-py1)) r = px2-px1+1; else r = py2-py1+1; double pi = 3.14159265358979; Pie( hdc, (int)((dpix * px1)/254), (int)((dpix * py1)/254), (int)((dpix * px2)/254), (int)((dpix * py2)/254), (int)((dpix * ((px1+px2)/2 + r * cos((pi*angle1)/1800)))/254), (int)((dpix * ((py1+py2)/2 - r * sin((pi*angle1)/1800)))/254), (int)((dpix * ((px1+px2)/2 + r * cos((pi*angle2)/1800)))/254), (int)((dpix * ((py1+py2)/2 - r * sin((pi*angle2)/1800)))/254)); DeleteObject( hBrush); DeleteObject( hPen); } }