//--------------------------------------------------------------------------- #include #include #include #include #include #include #include #include #include #include #include #include #include #include "RzCmboBx.hpp" #include "RzEdit.hpp" #include "RzGrids.hpp" #include "RzSpnEdt.hpp" #include "TNumEdit.h" #pragma hdrstop #include "LogData.h" #include "Common.h" #include "Define.h" #include "File.h" #include "Exception.h" #include "LeadToolsFileOption.h" #if defined(TEXSTYLIST) #include "VecDraw.h" // By GreenFish ÀÎŬ·çµå ¾ÈÇϰí´Â ¹æ¹ýÀÌ ¾ø³×...ToT #include "Palette.h" // by siuaa 080414 vector printÇÒ¶§ ÇÊ¿äÇØ¼­ include #endif //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- TStringTable CommonStringTable; String Language; //===============================//2001.4.10. by lhskys confi¿¡¼­ Á¾ÀÌ size, unit ³Ö±â String Size_Type; String TUnits, WUnits, KUnits; String Select; //========================= #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC int Password[4]; // HASPÀÇ SeedCode¿Í SerialNumber¸¦ ¿©±â¿¡ ÀúÀåÇÑ´Ù - by monkman (2004.11.29) int unsigned HASP_SerialNumber[4]; int unsigned HASP_SeedCode; #endif #endif String InstallPath; String DirectoryBin; String DirectoryItem; String DirectoryTemp; String DirectoryColor; String DirectoryTexture; String DirectoryTexStyleOpen; //2001.4.11. by lhskys Congi¿¡ Open Ãß°¡ #if defined(TEXSTYLIST) String DirectoryStyle; String DirectoryVStyle; String DirectoryStyleLib; String DirectoryTreatment; #endif String DefaultFontName; TFont *SmallFont; String AppDataBin; String AppDataItem; String LibraryInstallPath; TPrinterColor *PrinterColor; TStandardColor *StandardColor; TTextileColor *TextileColor; TPantone1000 *Pantone1000; // k3dogs 20001211 TPantoneTextile *PantoneTextile; TTablet *Tablet = NULL; #if defined(TEXSTYLIST) //--------------------------------------------------------------------------- // TPlaneVertex //--------------------------------------------------------------------------- __fastcall TPlaneVertex::TPlaneVertex() { bit = new TPBitmap; } //--------------------------------------------------------------------------- __fastcall TPlaneVertex::~TPlaneVertex() { if (bit) delete bit; } //--------------------------------------------------------------------------- // Reivate Method //--------------------------------------------------------------------------- void __fastcall TPlaneVertex::Angle(int a, int b, int x, int y, double &sum) { double dx1, dy1, dx2, dy2; dx1 = p[a].x - x; dy1 = p[a].y - y; dx2 = p[b].x - x; dy2 = p[b].y - y; if (dx1 * dy2 - dx2 * dy1 > 0) { sum += acos((dx1 * dx2 + dy1 * dy2) / (sqrt(dx1 * dx1 + dy1 * dy1) * sqrt(dx2 * dx2 + dy2 * dy2))); } else { sum -= acos((dx1 * dx2 + dy1 * dy2) / (sqrt(dx1 * dx1 + dy1 * dy1) * sqrt(dx2 * dx2 + dy2 * dy2))); } } //--------------------------------------------------------------------------- // Rublic Method //--------------------------------------------------------------------------- void __fastcall TPlaneVertex::Create(TPoint a, TPoint b, TPoint c, TPoint d) { BEGIN_LOG("Common"); double s; int sx, sy, ex, ey, x, y, xx[4]; int i, j; p[0].x = a.x; p[0].y = a.y; p[1].x = b.x; p[1].y = b.y; p[2].x = c.x; p[2].y = c.y; p[3].x = d.x; p[3].y = d.y; start.x = p[0].x; start.y = p[0].y; end.x = p[0].x; end.y = p[0].y; for (i = 1; i < 4; i++) { if (start.x > p[i].x) start.x = p[i].x; if (end.x < p[i].x) end.x = p[i].x; if (start.y > p[i].y) start.y = p[i].y; if (end.y < p[i].y) end.y = p[i].y; } if (bit) { if (!bit->Create(end.x - start.x + 1, end.y - start.y + 1, 1)) goto fail; if (!bit->Lock()) goto fail; for (i = 0; i < 4; i++) { sx = p[i].x - start.x; ex = p[(i + 1) % 4].x - start.x; sy = p[i].y - start.y; ey = p[(i + 1) % 4].y - start.y; if (ex - sx && ey - sy) { s = (double)(ey - sy) / (ex - sx); if (ey > sy) { for (y = sy; y <= ey; y++) { x = (double)(y - sy) / s + sx + 0.5; #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } else { for (y = ey; y <= sy; y++) { x = (double)(y - sy) / s + sx + 0.5; #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } } else if (ex - sx) { #ifdef TPDEBUG if (sx>=0 && sxWidth && sy>=0 && syHeight) { BWSetX(bit->ScanLine(sy), sx); } else { SHOWDEBUG; } if (ex>=0 && exWidth && sy>=0 && syHeight) { BWSetX(bit->ScanLine(sy), ex); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(sy), sx); BWSetX(bit->ScanLine(sy), ex); #endif } else { if (ey > sy) { for (y = sy; y <= ey; y++) { #ifdef TPDEBUG if (sx>=0 && sxWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), sx); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), sx); #endif } } else { for (y = ey; y <= sy; y++) { #ifdef TPDEBUG if (sx>=0 && sxWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), sx); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), sx); #endif } } } } for (y = 1; y < end.y - start.y; y++) { sx = -1; for (x = i = 0; x <= end.x - start.x; x++) { if (BWGetX(bit->ScanLine(y), x)) { for (j = 0; j < 4; j++) { if (start.x + x == p[j].x && start.y + y == p[j].y) { sx = i; break; } } xx[i++] = x; } } if (i && (i % 2) == 0) { for (x = xx[0]; x <= xx[1]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } if (i == 4) { for (x = xx[2]; x <= xx[3]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } } else if (i == 3) { if (sx == 0) { for (x = xx[1]; x <= xx[2]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } else if (sx == 1) { for (x = xx[0]; x <= xx[2]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } else if (sx == 2) { for (x = xx[0]; x <= xx[1]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } else if (i) { for (x = xx[0]; x <= xx[i - 1]; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && y>=0 && yHeight) { BWSetX(bit->ScanLine(y), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(y), x); #endif } } } } for (i = 0; i < 4; i++) { sx = p[i].x - start.x; ex = p[(i + 1) % 4].x - start.x; sy = p[i].y - start.y; ey = p[(i + 1) % 4].y - start.y; if (ex - sx && ey == sy) { if (ex > sx) { for (x = sx + 1; x < ex; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && sy>=0 && syHeight) { BWSetX(bit->ScanLine(sy), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(sy), x); #endif } } else { for (x = ex + 1; x < sx; x++) { #ifdef TPDEBUG if (x>=0 && xWidth && sy>=0 && syHeight) { BWSetX(bit->ScanLine(sy), x); } else { SHOWDEBUG; } #else BWSetX(bit->ScanLine(sy), x); #endif } } } } } END_LOG; return; fail: doDestroy(bit) END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TPlaneVertex::Check(int x, int y) { int dis_x, dis_y; double sum = 0.0; if (bit) return BWGetX(bit->ScanLine(y - start.y), x - start.x); for (int i = 0; i < 4; i++) { if (i) { dis_x = abs(p[i].x - p[i - 1].x); dis_y = abs(p[i].y - p[i - 1].y); if (abs(x - p[i].x) <= dis_x && abs(x - p[i - 1].x) <= dis_x && abs(y - p[i].y) <= dis_y && abs(y - p[i - 1].y) <= dis_y && (y - p[i].y) * (p[i - 1].x - p[i].x) == (x - p[i].x) * (p[i - 1].y - p[i].y)) return true; } else { dis_x = abs(p[0].x - p[3].x); dis_y = abs(p[0].y - p[3].y); if (abs(x - p[0].x) <= dis_x && abs(x - p[3].x) <= dis_x && abs(y - p[0].y) <= dis_y && abs(y - p[3].y) <= dis_y && (y - p[0].y) * (p[3].x - p[0].x) == (x - p[0].x) * (p[3].y - p[0].y)) return true; } } Angle(0, 3, x, y, sum); Angle(3, 2, x, y, sum); Angle(2, 1, x, y, sum); Angle(1, 0, x, y, sum); if (2.0 * M_PI - fabs(sum) < 0.0000000001) { if (fabs(sum) - 2.0 * M_PI < 0.0000000001) return true; } return false; } #endif //--------------------------------------------------------------------------- // TPCanvasInfor //--------------------------------------------------------------------------- void __fastcall TPCanvasInfor::SetSize(TPCanvasSizeType st, int w, int h) { SizeType = st; if (st==cstFree) { Width = w; Height = h; } else { Width = GetWidth(); Height = GetHeight(); } } //--------------------------------------------------------------------------- int __fastcall TPCanvasInfor::GetWidth() { if (SizeType==cstFree) return Width; if (Orientation==coPortrait) { switch (SizeType) { case cstTabloid: return 10.3 * DotsPerInch; case cstLetter: return 8.0 * DotsPerInch; //k3dogs letter case cstLegal: return 8.0 * DotsPerInch; case cstA0: return 31.2 * DotsPerInch; case cstA1: return 22.0 * DotsPerInch; case cstA2: return 15.6 * DotsPerInch; case cstA3: return 11.0 * DotsPerInch; default: return 7.8 * DotsPerInch; } } else { switch (SizeType) { case cstTabloid: return 16.0 * DotsPerInch; case cstLetter: return 10.3 * DotsPerInch; //k3dogs letter case cstLegal: return 13.2 * DotsPerInch; case cstA0: return 44.0 * DotsPerInch; case cstA1: return 31.2 * DotsPerInch; case cstA2: return 22.0 * DotsPerInch; case cstA3: return 15.6 * DotsPerInch; default: return 11.0 * DotsPerInch; } } } //--------------------------------------------------------------------------- int __fastcall TPCanvasInfor::GetHeight() { if (SizeType==cstFree) return Height; if (Orientation==coPortrait) { switch (SizeType) { case cstTabloid: return 16.0 * DotsPerInch; case cstLetter: return 10.3 * DotsPerInch; //k3dogs letter case cstLegal: return 13.2 * DotsPerInch; case cstA0: return 44.0 * DotsPerInch; case cstA1: return 31.2 * DotsPerInch; case cstA2: return 22.0 * DotsPerInch; case cstA3: return 15.6 * DotsPerInch; default: return 11.0 * DotsPerInch; } } else { switch (SizeType) { case cstTabloid: return 10.3 * DotsPerInch; case cstLetter: return 8.0 * DotsPerInch; //k3dogs letter case cstLegal: return 8.0 * DotsPerInch; case cstA0: return 31.2 * DotsPerInch; case cstA1: return 22.0 * DotsPerInch; case cstA2: return 15.6 * DotsPerInch; case cstA3: return 11.0 * DotsPerInch; default: return 7.8 * DotsPerInch; } } } //--------------------------------------------------------------------------- void __fastcall TPCanvasInfor::SetExtFileOption() { LoadFileOption.XResolution = DotsPerInch; LoadFileOption.YResolution = DotsPerInch; } //--------------------------------------------------------------------------- String __fastcall TPCanvasInfor::Name(TUnit Unit, int w, int h) { switch (SizeType) { case cstA4: return "A4"; case cstA3: return "A3"; case cstA2: return "A2"; case cstA1: return "A1"; case cstA0: return "A0"; case cstLetter: return "Letter"; //k3dogs letter case cstLegal: return "Legal"; case cstTabloid: return "Tabloid"; default: /*if(w == 1247 && h == 1760) return "A4"; //qe »çÀÌÁî°¡ ±Ô°Ý »çÀÌÁî¶û ¶È°°À¸¸é »çÀÌÁîÀÇ Å©±â¸¦ if(w == 1760 && h == 2496) return "A3"; //º¸¿©ÁÖ´Â°Í ´ë½Å¿¡ »çÀÌÁîÀ̸§À» º¸¿©ÁÖ°Ô Çß´Ù..(½ÃÄѼ­..) if(w == 2496 && h == 3520) return "A2"; //´Ù½Ã ¸·¾Ò´Ù...»çÀÌÁîÀÇ Å©±â°¡ ÀÏÁ¤ÇÏÁö ¾Ê´Ù...ÇѵµÆ®Á¤µµ Â÷À̰¡ ³­´Ù. if(w == 3520 && h == 4992) return "A1"; if(w == 4992 && h == 7040) return "A0"; if(w == 1280 && h == 1648) return "Letter"; if(w == 1280 && h == 2112) return "Legal"; */ if (Unit == uDot) { return Format("%d x %d", OPENARRAY(TVarRec, (w, h))); } else if (Unit == uInch) { return Format("%f x %f", OPENARRAY(TVarRec, ((double)w/DotsPerInch, (double)h/DotsPerInch))); } else if (Unit == uCm) { return Format("%f x %f", OPENARRAY(TVarRec, (2.54*w/DotsPerInch, 2.54*h/DotsPerInch))); } break; } return ""; } //--------------------------------------------------------------------------- // External Function //--------------------------------------------------------------------------- void __fastcall LoadFromMainRegIniFile() { //BEGIN_LOG("Common"); /* This table has been assembled from Usenet postings, personal observations, and reading other people's code. Please feel free to add to it or correct it. dwPlatFormID dwMajorVersion dwMinorVersion dwBuildNumber 95 1 4 0 950 95 SP1 1 4 0 >950 && <=1080 95 OSR2 1 4 <10 >1080 98 1 4 10 1998 98 SP1 1 4 10 >1998 && <2183 98 SE 1 4 10 >=2183 ME 1 4 90 3000 NT 3.51 2 3 51 NT 4 2 4 0 1381 2000 2 5 0 2195 XP 2 5 1 Vista 6 0 Server 2008 6 0 Server 2008 R2 6 1 Windows 7 6 1 CE 3 */ TRegIniFile *RegIniFile = NULL; TIniFile *IniFile = NULL; Char tp[MAX_PATH+1]; String pw; OSVERSIONINFO osinfo; osinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osinfo); GetTempPath(MAX_PATH, tp); if (tp[_tcslen(tp)-1]=='\\') tp[_tcslen(tp)-1] = 0; DirectoryTemp = tp; InstallPath = DefaultDir; // DefaultDir Àº splash form ¿¡¼­ ¹Ù²ï »óÅ´Ù.. ¤Ñ¤Ñ; /////------------------------------------------------------------------- AppDataBin = UserAppDataDir + "\\YoungWoo"; if (!DirectoryExists(AppDataBin)) { if (!CreateDir(AppDataBin)) throw Exception("Cannot create " + AppDataBin); } #ifdef NETHASP AppDataBin = AppDataBin + "\\NetTexStylist" + TexStylistVersion; #else AppDataBin = AppDataBin + "\\TexStylist" + TexStylistVersion; #endif if (!DirectoryExists(AppDataBin)) { if (!CreateDir(AppDataBin)) throw Exception("Cannot create " + AppDataBin); } /////------------------------------------------------------------------- #ifndef LOCK_USB RegIniFile = new TRegIniFile(RegFilename); if (RegIniFile) { RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC pw = RegIniFile->ReadString("Common", "Serial", ""); swscanf_s(pw.c_str(), L"%d-%d-%d-%d", &Password[0], &Password[1], &Password[2], &Password[3]); #endif #endif DirectoryBin = RegIniFile->ReadString("Directory", "Bin", FullPathName(DefaultDir, "Bin")); Language = RegIniFile->ReadString("Common", "Language", "English"); // Vista¿¡´Â "MS Sans Serif"°¡ "Microsoft Sans Serif"·Î ¹Ù²î¾ú´Ù - by monkman (2007.05.10) if (osinfo.dwMajorVersion >= 5) { DefaultFontName = RegIniFile->ReadString("Common", "DefaultFontName", "Microsoft Sans Serif"); // XP ÀÌ»ó } else { DefaultFontName = RegIniFile->ReadString("Common", "DefaultFontName", "MS Sans Serif"); // XP ÀÌÀü } Select = RegIniFile->ReadString("Common", "Select", "READ" ); //2001.4.11. by lhskys congi¿¡¼­ Select ³Ö±â #if defined(TEXSTYLIST) Size_Type = RegIniFile->ReadString("Common", "TREG_Size", "cstA4" ); //2001.4.24. by lhskys congi¿¡¼­ Á¾ÀÌ size ³Ö±â TUnits = RegIniFile->ReadString("Common", "TUnits", "uCm" ); //2001.4.10. by lhskys congi¿¡¼­ unit ³Ö±â #endif DirectoryTexStyleOpen = RegIniFile->ReadString("Directory", "TexstyleOpen", DefaultDir ); //2001.4.11. by lhskys congi¿¡¼­ Open ³Ö±â DirectoryColor = RegIniFile->ReadString("Directory", "Color", FullPathName(DefaultDir, "Color")); DirectoryTexture = RegIniFile->ReadString("Directory", "Texture", FullPathName(DefaultDir, "Texture")); #if defined(TEXSTYLIST) DirectoryStyle = RegIniFile->ReadString("Directory", "Style", FullPathName(DefaultDir, "Style")); DirectoryVStyle = FullPathName(DefaultDir, "VStyle"); DirectoryStyleLib = FullPathName(DefaultDir, "StyleLib"); DirectoryTreatment = RegIniFile->ReadString("Directory", "Treatment", FullPathName(DefaultDir, "Treatment")); #endif delete RegIniFile; } else { Language = "English"; // Vista¿¡´Â "MS Sans Serif"°¡ "Microsoft Sans Serif"·Î ¹Ù²î¾ú´Ù - by monkman (2007.05.10) if (osinfo.dwMajorVersion >= 5) { DefaultFontName = "Microsoft Sans Serif"; // XP ÀÌ»ó } else { DefaultFontName = "MS Sans Serif"; // XP ÀÌÀü } DirectoryBin = FullPathName(DefaultDir, "Bin"); DirectoryColor = FullPathName(DefaultDir, "Color"); DirectoryTexture = FullPathName(DefaultDir, "Texture"); DirectoryTexStyleOpen = DefaultDir; //2001.4.11. by lhskys congi¿¡¼­ Open ³Ö±â #if defined(TEXSTYLIST) DirectoryStyle = FullPathName(DefaultDir, "Style"); DirectoryVStyle = FullPathName(DefaultDir, "VStyle"); DirectoryStyleLib = FullPathName(DefaultDir, "StyleLib"); DirectoryTreatment = FullPathName(DefaultDir, "Treatment"); #endif } if (IniFile) { delete IniFile; IniFile = NULL; } #else // LOCK_USB DirectoryBin = FullPathName(DefaultDir, "Bin"); DirectoryColor = FullPathName(DefaultDir, "Color"); DirectoryTexture = FullPathName(DefaultDir, "Texture"); DirectoryTexStyleOpen = FullPathName(DefaultDrive, "Pattern"); //2001.4.11. by lhskys congi¿¡¼­ Open ³Ö±â #if defined(TEXSTYLIST) DirectoryStyle = FullPathName(DefaultDir, "Style"); DirectoryVStyle = FullPathName(DefaultDir, "VStyle"); DirectoryStyleLib = FullPathName(DefaultDir, "StyleLib"); DirectoryTreatment = FullPathName(DefaultDir, "Treatment"); #endif AppDataBin = DirectoryBin; IniFile = new TIniFile(AppDataBin + "\\Configuration.ini"); Language = IniFile->ReadString("Common", "Language", "Korean"); // Vista¿¡´Â "MS Sans Serif"°¡ "Microsoft Sans Serif"·Î ¹Ù²î¾ú´Ù - by monkman (2007.05.10) if (osinfo.dwMajorVersion >= 5) { DefaultFontName = IniFile->ReadString("Common", "DefaultFontName", "±¼¸²"); // XP ÀÌ»ó } else { DefaultFontName = IniFile->ReadString("Common", "DefaultFontName", "±¼¸²"); // XP ÀÌÀü } Select = IniFile->ReadString("Common", "Select", "READ"); //2001.4.11. by lhskys congi¿¡¼­ Select ³Ö±â // Vista¿¡´Â "MS Sans Serif"°¡ "Microsoft Sans Serif"·Î ¹Ù²î¾ú´Ù - by monkman (2007.05.10) if (osinfo.dwMajorVersion >= 5) { DefaultFontName = "±¼¸²"; //"Microsoft Sans Serif"; // Vista } else { DefaultFontName = "±¼¸²"; //"MS Sans Serif"; // Etc (!Vista) } #if defined(TEXSTYLIST) Size_Type = IniFile->ReadString("Common", "TREG_Size", "cstA4" ); //2001.4.24. by lhskys congi¿¡¼­ Á¾ÀÌ size ³Ö±â TUnits = IniFile->ReadString("Common", "TUnits", "uCm" ); //2001.4.10. by lhskys congi¿¡¼­ unit ³Ö±â #endif delete IniFile; IniFile = NULL; #endif // LOCK_USB #if defined(TEXSTYLIST) DirectoryItem = DirectoryBin + "\\TexStylist"; AppDataItem = AppDataBin + "\\TexStylist"; #endif if (!DirectoryExists(AppDataItem)) { if (!CreateDir(AppDataItem)) throw Exception("Cannot create " + AppDataItem); } //END_LOG; } //--------------------------------------------------------------------------- bool __fastcall LibraryRegCheck() { // LibraryInstallPath = "C:\\YoungWoo\\Library"; // return true; bool rtn = false; TRegIniFile *RegIniFile = NULL; String RegFilename = "\\Software\\YoungWoo\\TexPro\\Library"; RegIniFile = new TRegIniFile(RegFilename); if (RegIniFile) { RegIniFile->RootKey = HKEY_LOCAL_MACHINE; if (RegIniFile->OpenKey(RegFilename + "\\", false)){ LibraryInstallPath = RegIniFile->ReadString("Directory", "DefaultDir", "");//"C:\\Youngwoo\\Library"); if (!LibraryInstallPath.IsEmpty()) rtn = true; } delete RegIniFile; } return rtn; } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void *memset24(void *s, DWORD c, size_t n) { asm { mov edx,n cmp edx,0 jz label5 mov edi,s test edx,0xfffffffc jz label4 mov eax,c mov [edi+0x02],al mov [edi+0x05],al mov [edi+0x08],al mov [edi+0x0B],al shr eax,0x08 mov [edi+0x01],al mov [edi+0x04],al mov [edi+0x07],al mov [edi+0x0A],al shr eax,0x08 mov [edi],al mov [edi+0x03],al mov [edi+0x06],al mov [edi+0x09],al mov eax,[edi] mov ebx,[edi+0x04] mov ecx,[edi+0x08] shr edx,0x02 label1: mov [edi],eax mov [edi+0x04],ebx mov [edi+0x08],ecx add edi,0x0c dec edx jz label2 mov [edi],eax mov [edi+0x04],ebx mov [edi+0x08],ecx add edi,0x0c dec edx jz label2 mov [edi],eax mov [edi+0x04],ebx mov [edi+0x08],ecx add edi,0x0c dec edx jz label2 mov [edi],eax mov [edi+0x04],ebx mov [edi+0x08],ecx add edi,0x0c dec edx jnz label1 label2: mov edx,n and edx,0x03 jz label5 label4: mov ebx,c mov [edi+2],bl shr ebx,0x08 mov [edi+1],bl shr ebx,0x08 mov [edi],bl add edi,0x03 dec edx jnz label4 label5: mov eax,s } } //--------------------------------------------------------------------------- Graphics::TBitmap* __fastcall GetRegion(int ws, int hs) { #ifndef UNIT #define UNIT 4 #endif BEGIN_LOG("Common"); int i; POINT Start, End; Graphics::TBitmap *bm; POINT *pt; HDC dc; BYTE *p; long temp; long Garo, Sero; int VertexCount[4]; bm = new Graphics::TBitmap; bm->PixelFormat = pf16bit; bm->Width = ws -2; // ºñÆ®¸ÊÀÇ ³ÐÀÌ ¼³Á¤ bm->Height = hs -2; // ºñÆ®¸ÊÀÇ ³ôÀÌ ¼³Á¤ bm->Canvas->Brush->Color = clWhite; bm->Canvas->FillRect(Rect(0,0,bm->Width,bm->Height)); // Èò»öÀ¸·Î Bitmap À» ä¿ò bm->Canvas->Pen->Color = clBlack; bm->Canvas->Brush->Color = clBlack; End.x = bm->Width - 3; End.y = bm->Height - 3; Start.x = Start.y = 2; Garo = abs(End.x - Start.x -UNIT); // Polygon ÀÇ °¡·Î ±æÀÌ Sero = abs(End.y - Start.y -UNIT); // Polygon ÀÇ ¼¼·Î ±æÀÌ // ¼¼·Î º¯ÀÇ VerTex ¼ö ±¸Çϱâ VertexCount[0] = VertexCount[2] = Sero / UNIT ; // °¡·Î º¯ÀÇ VerTex ¼ö ±¸Çϱâ VertexCount[1] = VertexCount[3] = Garo / UNIT; int Total = VertexCount[0] + VertexCount[1] + VertexCount[2] + VertexCount[3]; pt = new POINT[Total]; bm->Canvas->MoveTo(Start.x + UNIT,Start.y + UNIT); // Polygon ÀÇ ½ÃÀÛÁ¡ int ValueX ,ValueY; // Áº¯ÀÇ ÁÂÇ¥ ±¸Çϱâ ValueY = Start.y; for(i = 0; i < VertexCount[0] ; i++) { if( i %2 == 1){ pt[i].x = Start.x ; } if (i %2 == 0){ pt[i].x = Start.x +UNIT; } pt[i].y = ValueY = ValueY + UNIT; if(pt[i].y > End.y - UNIT){ if(abs(pt[i].y - pt[i-1].y) < 4) pt[i].x = Start.x +UNIT; pt[i].y = End.y - UNIT; } } // ¹Øº¯ÀÇ ÁÂÇ¥ ±¸Çϱâ ValueX = Start.x; int RoopStart; RoopStart = VertexCount[0]; for (i = RoopStart ; i < RoopStart + VertexCount[1];i++) { if(i % 2 == 1) pt[i].y = End.y; if(i % 2 == 0) pt[i].y = End.y - UNIT; pt[i].x = ValueX = ValueX + UNIT; if(pt[i].x > End.x - UNIT){ if(abs(pt[i].x - pt[i-1].x) < 4) pt[i].y = Start.y +UNIT; pt[i].x = End.x - UNIT; } } // ¿ìº¯ÀÇ ÁÂÇ¥ ±¸Çϱâ RoopStart = RoopStart + VertexCount[1]; ValueY = End.y; for(i = RoopStart; i < RoopStart + VertexCount[2]; i++) { if( i %2 == 1){ pt[i].x = End.x ; } if (i %2 == 0){ pt[i].x = End.x -UNIT; } pt[i].y = ValueY = ValueY - UNIT; if(pt[i].y < Start.y + UNIT){ if(abs(pt[i].y - pt[i-1].y) < 4) pt[i].x = End.x -UNIT; pt[i].y = Start.y + UNIT; } } // À­º¯ÀÇ ÁÂÇ¥ ±¸Çϱâ ValueX = End.x; RoopStart = RoopStart + VertexCount[2]; for(i = RoopStart ; i < RoopStart + VertexCount[3];i++) { if(i % 2 == 1) pt[i].y = Start.y; if(i % 2 == 0) pt[i].y = Start.y + UNIT; pt[i].x = ValueX = ValueX - UNIT; if(pt[i].x < Start.x + UNIT){ if(abs(pt[i].x - pt[i-1].x) < 4) pt[i].y = Start.y +UNIT; pt[i].x = Start.x + UNIT; } } bm->Canvas->Polygon((TPoint *)pt, Total -1); // ±¸ÇÑ ÁÂÇ¥·Î Polygon ±×¸®±â delete[] pt; END_LOG; return bm; } /*--------------------------------------------------------------------------- void __fastcall PrintColorChip8(Graphics::TBitmap *Pattern, TRect rect, BYTE pi, Graphics::TBitmap * BitMask) { WORD *p; BYTE *q; int by,py,x; if (BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ for (by = 0, py=rect.Top; by < BitMask->Height; py++,by++) { p = (WORD * ) BitMask->ScanLine[by]; // BitMask ÀÇ À̹ÌÁö Á¤º¸ q = (BYTE *) Pattern->ScanLine[py] + rect.Left; // Pattern ÀÇ À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++,p++,q++){ if(*p == 0 ){ // polygon ÀÇ ³»ºÎÀÎÁö¸¦ üũ *q = pi; // »ö°ªÀ» ¼³Á¤ } } } } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. for( py = rect.Top ; py < rect.Bottom ; py++) { memset((BYTE *)Pattern->ScanLine[py] + rect.Left, pi, rect.Right - rect.Left); } } } */ //--------------------------------------------------------------------------- void __fastcall PrintColorChip8(TTexpiaBitmap *Pattern, TRect rect, BYTE pi, Graphics::TBitmap * BitMask) { BEGIN_LOG("Common"); WORD *p; BYTE *q; int by,py,x; if (BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ Pattern->StartScanLine(); for (by=0, py=rect.Top; byHeight; py++,by++) { p = (WORD * ) BitMask->ScanLine[by]; // BitMask ÀÇ À̹ÌÁö Á¤º¸ q = Pattern->GetScanLine(py) + rect.Left; // Pattern ÀÇ À̹ÌÁö Á¤º¸ for (x=0; xWidth; x++,p++,q++) { if(*p == 0) { // polygon ÀÇ ³»ºÎÀÎÁö¸¦ üũ *q = pi; // »ö°ªÀ» ¼³Á¤ } } Pattern->PutScanLine(py); } Pattern->StopScanLine(); } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. Pattern->StartScanLine(); for(py=rect.Top; pyGetScanLine(py) + rect.Left; memset(q, pi, rect.Right - rect.Left); Pattern->PutScanLine(py); } Pattern->StopScanLine(); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall PrintColorChip8(TUnionBitmap *Pattern, TRect rect, BYTE pi, Graphics::TBitmap *BitMask) { BEGIN_LOG("Common"); WORD *p; BYTE *q; int by,py,x; if (BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ Pattern->StartScanLine(); for (by=0, py=rect.Top; byHeight; py++,by++) { p = (WORD * ) BitMask->ScanLine[by]; // BitMask ÀÇ À̹ÌÁö Á¤º¸ q = Pattern->GetScanLine(py) + rect.Left; // Pattern ÀÇ À̹ÌÁö Á¤º¸ for (x=0; xWidth; x++,p++,q++) { if(*p == 0) { // polygon ÀÇ ³»ºÎÀÎÁö¸¦ üũ *q = pi; // »ö°ªÀ» ¼³Á¤ } } Pattern->PutScanLine(py); } Pattern->StopScanLine(); } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. Pattern->StartScanLine(); for(py=rect.Top; pyGetScanLine(py) + rect.Left; memset(q, pi, rect.Right - rect.Left); Pattern->PutScanLine(py); } Pattern->StopScanLine(); } END_LOG; } //--------------------------------------------------------------------------- /*--------------------------------------------------------------------------- void __fastcall PrintColorChip15(Graphics::TBitmap *Pattern, TRect rect, BYTE red, BYTE green, BYTE blue, Graphics::TBitmap *BitMask) { WORD *p; WORD *q; int by,py,x; WORD color = ((red & 0xF8) << 7) | ((green & 0xF8) << 2) | (blue >> 3); if(BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ for (by = 0, py=rect.Top; by < BitMask->Height; py++,by++) { p = (WORD *)BitMask->ScanLine[by]; // BitMask ÀÇ À̹ÌÁö Á¤º¸ q = (WORD *) Pattern->ScanLine[py] + rect.Left; // Pattern ÀÇ À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++,p++,q++){ if((*p == 0)) { // polygon ÀÇ ³»ºÎÀÎÁö¸¦ üũ *q = color; // »ö°ªÀ» ¼³Á¤ } } } } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. for (int py=rect.Top; pyScanLine[py] + rect.Left; for (int x=rect.Left; x> 3); if(BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ Pattern->StartScanLine(); for (by=0, py=rect.Top; byHeight; py++, by++) { p = (WORD *)BitMask->ScanLine[by]; // BitMask ÀÇ À̹ÌÁö Á¤º¸ q = (WORD *)Pattern->GetScanLine(py) + rect.Left; // Pattern ÀÇ À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++, p++, q++) { if((*p == 0)) { // polygon ÀÇ ³»ºÎÀÎÁö¸¦ üũ *q = color; // »ö°ªÀ» ¼³Á¤ } } Pattern->PutScanLine(py); } Pattern->StopScanLine(); } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. Pattern->StartScanLine(); for (py=rect.Top; pyGetScanLine(py) + rect.Left; for (x=rect.Left; xPutScanLine(py); } Pattern->StopScanLine(); } END_LOG; } /*--------------------------------------------------------------------------- void __fastcall PrintColorChip24(Graphics::TBitmap *Pattern, TRect rect, BYTE red, BYTE green, BYTE blue, Graphics::TBitmap *BitMask ) { WORD *p; BYTE *q; int by,py,x; int i,j; int color = 0x00000000; if( BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ for (by = 0, py=rect.Top; by < BitMask->Height; py++,by++) { p = (WORD *) BitMask->ScanLine[by]; // Mask À̹ÌÁö Á¤º¸ q = (BYTE *) Pattern->ScanLine[py] + 3 * rect.Left; // Ãâ·Â À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++, p++, q+=3) { if((*p == 0)) { // BitMask üũ *q = blue; // Ä®¶ó°ª ¼³Á¤ *(q + 1) = green; *(q + 2) = red; } } } } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. color = (blue << 16) + (green << 8) + red; for (int py=rect.Top; pyScanLine[py] + 3 * rect.Left, color, rect.Right - rect.Left); } } } */ //--------------------------------------------------------------------------- void __fastcall PrintColorChip24TP(TTexpiaBitmap *Pattern, TRect rect, BYTE red, BYTE green, BYTE blue, Graphics::TBitmap *BitMask ) { // convert by celberus BEGIN_LOG("Common"); WORD *p; BYTE *q; int by,py,x; COLORREF color; // int color = 0x00000000; if( BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ Pattern->StartScanLine(); for (by = 0, py=rect.Top; by < BitMask->Height; py++,by++) { p = (WORD *) BitMask->ScanLine[by]; // Mask À̹ÌÁö Á¤º¸ q = Pattern->GetScanLine(py) + 3*rect.Left; // Ãâ·Â À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++, p++, q+=3) { if((*p == 0)) { // BitMask üũ *q = blue; // Ä®¶ó°ª ¼³Á¤ *(q + 1) = green; *(q + 2) = red; } } Pattern->PutScanLine(py); } Pattern->StopScanLine(); } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. color = (blue << 16) + (green << 8) + red; Pattern->StartScanLine(); for (int py=rect.Top; pyGetScanLine(py) + 3*rect.Left; memset24(q, color, rect.Right - rect.Left); Pattern->PutScanLine(py); } Pattern->StopScanLine(); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall PrintColorChip24(TUnionBitmap *Pattern, TRect rect, BYTE red, BYTE green, BYTE blue, Graphics::TBitmap *BitMask ) { BEGIN_LOG("Common"); WORD *p; BYTE *q; int by,py,x; COLORREF color; // int color = 0x00000000; if( BitMask) { // °¡À§ È¿°ú¸¦ ÁÙ°ÍÀÎÁö¸¦ üũ Pattern->StartScanLine(); for (by = 0, py=rect.Top; by < BitMask->Height; py++,by++) { p = (WORD *) BitMask->ScanLine[by]; // Mask À̹ÌÁö Á¤º¸ q = Pattern->GetScanLine(py) + 3*rect.Left; // Ãâ·Â À̹ÌÁö Á¤º¸ for (x = 0 ; x < BitMask->Width ; x++, p++, q+=3) { if((*p == 0)) { // BitMask üũ *q = blue; // Ä®¶ó°ª ¼³Á¤ *(q + 1) = green; *(q + 2) = red; } } Pattern->PutScanLine(py); } Pattern->StopScanLine(); } else { // °¡À§ È¿°ú¸¦ ÁÖÁö¾Ê°í Rectangle ¿µ¿ªÀ» »ö±ò·Î ä¿ò. color = (blue << 16) + (green << 8) + red; Pattern->StartScanLine(); for (int py=rect.Top; pyGetScanLine(py) + 3*rect.Left; memset24(q, color, rect.Right - rect.Left); Pattern->PutScanLine(py); } Pattern->StopScanLine(); } END_LOG; } //--------------------------------------------------------------------------- /* bool __fastcall SendToPrinter(Graphics::TBitmap *Pattern, int dpi, String title, int page, int method) { HDC hPrintDC = NULL, hDC = NULL; // Test Version by kjs TRect Src, Dst; int WidthRes, HeightRes, x, y, cnt; TSize Area, n, s; RGBQUAD rgb[256]; String str; TTexpiaBitmap Bitmap; hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if (Pattern->PixelFormat == pf8bit) { GetDIBColorTable(Pattern->Canvas->Handle, 0, 256, rgb); } cnt=0; str = "/"+IntToStr(n.cy*n.cx); if (method == 2) { Dst.Left = 0; Dst.Top = 0; for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { cnt++; Printer()->Title = title+IntToStr(cnt)+str; Printer()->Copies = page; Printer()->BeginDoc(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (Pattern->PixelFormat == pf8bit) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; Printer()->Canvas->CopyMode = cmSrcCopy; Printer()->Canvas->CopyRect(Dst, Pattern->Canvas, Src); Printer()->EndDoc(); } } } else { switch (Pattern->PixelFormat) { case pf8bit: if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) return false; break; case pf15bit: if (!Bitmap.Create(Area.cx, Area.cy, 16)) return false; break; case pf24bit: if (!Bitmap.Create(Area.cx, Area.cy, 24)) return false; break; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { cnt++; Printer()->Title = title+IntToStr(cnt)+str; Printer()->Copies = page; Printer()->BeginDoc(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { Bitmap.Resize(s.cx, s.cy, clWhite); } hDC = Bitmap.CreateDC(); BitBlt(hDC, 0, 0, s.cx, s.cy, Pattern->Canvas->Handle, Src.Left, Src.Top, SRCCOPY); Bitmap.DeleteDC(hDC); if (method) { L_PrintBitmapExt(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } else { L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } Printer()->EndDoc(); } } } return true; } */ /* bool __fastcall SendToPrinter(Graphics::TBitmap *Pattern, int dpi, String title, int page, int method) { HDC hPrintDC = NULL, hDC = NULL; TRect Src, Dst; int WidthRes, HeightRes, x, y; TSize Area, n, s; RGBQUAD rgb[256]; TTexpiaBitmap Bitmap; Printer()->Title = title; Printer()->Copies = page; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if (Pattern->PixelFormat == pf8bit) { GetDIBColorTable(Pattern->Canvas->Handle, 0, 256, rgb); } if (method == 2) { Dst.Left = 0; Dst.Top = 0; for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (Pattern->PixelFormat == pf8bit) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; Printer()->Canvas->CopyMode = cmSrcCopy; Printer()->Canvas->CopyRect(Dst, Pattern->Canvas, Src); } } } else { switch (Pattern->PixelFormat) { case pf8bit: if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) return false; break; case pf15bit: if (!Bitmap.Create(Area.cx, Area.cy, 16)) return false; break; case pf24bit: if (!Bitmap.Create(Area.cx, Area.cy, 24)) return false; break; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { Bitmap.Resize(s.cx, s.cy, clWhite); } hDC = Bitmap.CreateDC(); BitBlt(hDC, 0, 0, s.cx, s.cy, Pattern->Canvas->Handle, Src.Left, Src.Top, SRCCOPY); Bitmap.DeleteDC(hDC); if (method) { L_PrintBitmapExt(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } else { L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } } } } Printer()->EndDoc(); return true; } */ //--------------------------------------------------------------------------- #if defined(TEXSTYLIST) bool __fastcall SendToPrinterTP(TTexpiaBitmap *Pattern, double dpi, String title, int page, int method, int PrintPositions, float WRatio, float HRatio, int number) { BEGIN_LOG("Common"); HDC hPrintDC, hDC = NULL, phDC = NULL, dcTemp = NULL; TRect Src, Dst; int WidthRes, HeightRes, x, y, PosWidth, PosHeight; TSize Area, n, s; RGBQUAD rgb[256]; TTexpiaBitmap Bitmap, TempBitmap; Printer()->Title = title; Printer()->Copies = page; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); //ÀåÄ¡°íÀ¯Á¤º¸¸¦ ±¸ÇÔ. LOGPIXELSX=È­¸éÆø¹æÇâÀ¸·Î ·ÎÁöÄà ÀÎÄ¡´ç Çȼ¿ °³¼ö. -k3dogs HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; //HORXRES=½ºÅ©¸°ÀÇ Æø(Çȼ¿ ´ÜÀ§). Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if ((phDC = Pattern->CreateDC()) == NULL) goto fail; if (Pattern->BitsPerPixel == 8) { GetDIBColorTable(phDC, 0, 256, rgb); } if(PrintPositions != 0){ if (method == 2) { //Ãʱ⠹öÀü... À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â ¹æ¹ýÀÌ¿ë. Dst.Left = 0; Dst.Top = 0; //============ if (Pattern->BitsPerPixel == 8) { if (!TempBitmap.Create(Printer()->PageWidth, Printer()->PageHeight, 8, rgb)) goto fail; } else { if (!TempBitmap.Create(Printer()->PageWidth, Printer()->PageHeight, Pattern->BitsPerPixel)) goto fail; } if ((dcTemp = TempBitmap.CreateDC()) == NULL) goto fail; //============ if (Pattern->BitsPerPixel == 8) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; // if (Pattern->BitsPerPixel == 8) { // SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); // } Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; // Printer()->Canvas->CopyMode = cmSrcCopy; // Printer()->Canvas->CopyRect(Dst, Pattern->Canvas, Src); //which is right? SetStretchBltMode(dcTemp, COLORONCOLOR); StretchBlt(dcTemp, Dst.Left, Dst.Top, Dst.Right, Dst.Bottom, phDC, Src.Left, Src.Top, Src.Right-Src.Left, Src.Bottom-Src.Top, SRCCOPY); //==========GreenFish Vector ÇÁ¸°Æ® VecDraw->PrintDraw(dcTemp, Src.Left, Src.Top, WidthRes, HeightRes, dpi, number); BitBlt(Printer()->Canvas->Handle,0,0,Printer()->PageWidth,Printer()->PageHeight,dcTemp,0,0,SRCCOPY); // VectorPrint¿¡¼­´Â ÇÁ¸°Æ® ±¸¿ª(ºñÆ®¸Ê)À» ³Ñ¾î°¥ °æ¿ì°¡ »ý±â´Âµ¥ ÀÌ·±°ÍÀ» Áö¿ö¹ö¸®±â À§ÇÔ Printer()->Canvas->Brush->Color = clWhite; Printer()->Canvas->FillRect(Rect(Dst.Left, Dst.Bottom, Printer()->PageWidth, Printer()->PageHeight)); Printer()->Canvas->FillRect(Rect(Dst.Right, Dst.Top, Printer()->PageWidth, Printer()->PageHeight)); } } if (dcTemp) TempBitmap.DeleteDC(dcTemp); } else { //ÇÁ¸°ÅÍ ±âÁ¾¿¡ µû¶ó¼­ À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â if (Pattern->BitsPerPixel == 8) { //ÇÔ¼ö¸¸À¸·Î ÇÁ¸°Æ®Çϱ⿡´Â ¹®Á¦°¡ ¹ß»ýÇÏ¿© Ãß°¡ if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) goto fail; } else { if (!Bitmap.Create(Area.cx, Area.cy, Pattern->BitsPerPixel)) goto fail; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { if (!Bitmap.Resize(s.cx, s.cy, clWhite)) goto fail; } if ((hDC = Bitmap.CreateDC()) == NULL) goto fail; if (!BitBlt(hDC, 0, 0, s.cx, s.cy, phDC, Src.Left, Src.Top, SRCCOPY)) goto fail; Bitmap.DeleteDC(hDC); hDC = NULL; //PrintPositions=1 LT //PrintPositions=2 MT //PrintPositions=3 RT //PrintPositions=4 LM //PrintPositions=5 MM //PrintPositions=6 RM //PrintPositions=7 LB //PrintPositions=8 MB //PrintPositions=9 RB //PrintPositions=10 FREE if(PrintPositions == 1){ PosWidth = 0; PosHeight = 0; }else if(PrintPositions == 2){ PosWidth = (Area.cx - s.cx)/2; PosHeight = 0; }else if(PrintPositions == 3){ PosWidth = Area.cx - s.cx; PosHeight = 0; }else if(PrintPositions == 4){ PosWidth = 0; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 5){ PosWidth = (Area.cx - s.cx)/2; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 6){ PosWidth = Area.cx - s.cx; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 7){ PosWidth = 0; PosHeight= Area.cy - s.cy; }else if(PrintPositions == 8){ PosWidth = (Area.cx - s.cx)/2; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 9){ PosWidth = Area.cx - s.cx; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 10){ PosWidth = Area.cx * WRatio / 10000; PosHeight = Area.cy * HRatio / 10000; } if (method) { // LEADTOOLS V13 -> 15 : L_PrintBitmapExt() -> L_PrintBitmap() - by monkman (2007.05.04) if (!L_PrintBitmap(hPrintDC, Bitmap.Handle, 1+PosWidth*WidthRes/dpi, 1+PosHeight*WidthRes/dpi, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false)) goto fail; } else { if (!L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1+PosWidth*WidthRes/dpi, 1+PosHeight*WidthRes/dpi, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false)) goto fail; } //==========GreenFish Vector ÇÁ¸°Æ® VecDraw->PrintDraw(Printer()->Canvas->Handle, Src.Left - PosWidth, Src.Top - PosHeight, WidthRes, HeightRes, dpi, number); // VectorPrint¿¡¼­´Â ÇÁ¸°Æ® ±¸¿ª(ºñÆ®¸Ê)À» ³Ñ¾î°¥ °æ¿ì°¡ »ý±â´Âµ¥ ÀÌ·±°ÍÀ» Áö¿ö¹ö¸®±â À§ÇÔ Printer()->Canvas->Brush->Color = clWhite; Printer()->Canvas->FillRect(Rect((Src.left+PosWidth)*WidthRes/dpi, (Pattern->Height+PosHeight)*HeightRes/dpi, Printer()->PageWidth, Printer()->PageHeight)); Printer()->Canvas->FillRect(Rect((Pattern->Width+PosWidth)*WidthRes/dpi, (Src.top+PosHeight)*HeightRes/dpi, Printer()->PageWidth, Printer()->PageHeight)); if (PosHeight) Printer()->Canvas->FillRect(Rect(0, 0, Printer()->PageWidth, PosHeight*HeightRes/dpi)); if (PosWidth) Printer()->Canvas->FillRect(Rect(0, 0, PosWidth*WidthRes/dpi, Printer()->PageHeight)); } } } }else { if (method == 2) { //Ãʱ⠹öÀü... À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â ¹æ¹ýÀÌ¿ë. Dst.Left = 0; Dst.Top = 0; if (Pattern->BitsPerPixel == 8) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; // if (Pattern->BitsPerPixel == 8) { // SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); // } Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; // Printer()->Canvas->CopyMode = cmSrcCopy; // Printer()->Canvas->CopyRect(Dst, Pattern->Canvas, Src); //which is right? SetStretchBltMode(Printer()->Canvas->Handle, COLORONCOLOR); StretchBlt(Printer()->Canvas->Handle, Dst.Left, Dst.Top, Dst.Right, Dst.Bottom, phDC, Src.Left, Src.Top, Src.Right-Src.Left, Src.Bottom-Src.Top, SRCCOPY); } } } else { //ÇÁ¸°ÅÍ ±âÁ¾¿¡ µû¶ó¼­ À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â if (Pattern->BitsPerPixel == 8) { //ÇÔ¼ö¸¸À¸·Î ÇÁ¸°Æ®Çϱ⿡´Â ¹®Á¦°¡ ¹ß»ýÇÏ¿© Ãß°¡ if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) goto fail; } else { if (!Bitmap.Create(Area.cx, Area.cy, Pattern->BitsPerPixel)) goto fail; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { if (!Bitmap.Resize(s.cx, s.cy, clWhite)) goto fail; } if ((hDC = Bitmap.CreateDC()) == NULL) goto fail; if (!BitBlt(hDC, 0, 0, s.cx, s.cy, phDC, Src.Left, Src.Top, SRCCOPY)) goto fail; Bitmap.DeleteDC(hDC); hDC = NULL; if (method) { // LEADTOOLS V13 -> 15 : L_PrintBitmapExt() -> L_PrintBitmap() - by monkman (2007.05.04) if (!L_PrintBitmap(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false)) goto fail; } else { if (!L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false)) goto fail; } } } } } Pattern->DeleteDC(phDC); #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->EndDoc(); END_LOG; return true; fail: if (hDC) Bitmap.DeleteDC(hDC); if (phDC) Pattern->DeleteDC(phDC); Printer()->EndDoc(); END_LOG; return false; } //--------------------------------------------------------------------------- //by siuaa 080408 //vectorÀÇ print¸¦ À§ÇØ ¼öÁ¤ //¹Ýº¹ÇØÁÖ´Â Èܼö¸¦ ÀúÀåÇÑ TSize r, print ¹æ¹ý(Ç¥ÁØ, °¡·ÎºÐÇÒ, ¼¼·ÎºÐÇÒ)À» Ç¥½ÃÇÏ´Â itemÀ» Ãß°¡ bool __fastcall SendToPrinter(TUnionBitmap *Pattern, double dpi, String title, int page, int method, TSize r, int item, int printHeader, int PrintPositions, float WRatio, float HRatio, int number) // convert by celberus { BEGIN_LOG("Common"); HDC hPrintDC, hDC = NULL, phDC = NULL;//, hPrintCanvasDC; TRect Src, Dst; int WidthRes, HeightRes, x, y, PosWidth, PosHeight; TSize Area, n, s, TempSize, TempSrcSize, TempSrcN; const int TLimitSize = 4800; RGBQUAD rgb[256]; TUnionBitmap Bitmap; TTexpiaBitmap TempBitmap; Printer()->Title = title; Printer()->Copies = page; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; // hPrintCanvasDC = Printer()->Canvas->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); //ÀåÄ¡°íÀ¯Á¤º¸¸¦ ±¸ÇÔ. LOGPIXELSX=È­¸éÆø¹æÇâÀ¸·Î ·ÎÁöÄà ÀÎÄ¡´ç Çȼ¿ °³¼ö. -k3dogs HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; //HORXRES=½ºÅ©¸°ÀÇ Æø(Çȼ¿ ´ÜÀ§). Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if (Pattern->BitsPerPixel == 8) { Pattern->GetColors(0, 256, rgb); } if(PrintPositions != 0){ if (method == 2) { //Ãʱ⠹öÀü... À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â ¹æ¹ýÀÌ¿ë. Dst.Left = 0; Dst.Top = 0; //============ TempSize.cx = min(TLimitSize, Printer()->PageWidth); TempSize.cy = min(TLimitSize, Printer()->PageHeight); if (Pattern->BitsPerPixel == 8) { if (!TempBitmap.Create(TempSize.cx, TempSize.cy, 8, rgb)) goto fail; } else { if (!TempBitmap.Create(TempSize.cx, TempSize.cy, Pattern->BitsPerPixel)) goto fail; } //============ if (Pattern->BitsPerPixel == 8) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; //PrintPositions=1 LT //PrintPositions=2 MT //PrintPositions=3 RT //PrintPositions=4 LM //PrintPositions=5 MM //PrintPositions=6 RM //PrintPositions=7 LB //PrintPositions=8 MB //PrintPositions=9 RB //PrintPositions=10 FREE if(PrintPositions == 1){ PosWidth = 0; PosHeight = 0; }else if(PrintPositions == 2){ PosWidth = (Area.cx - s.cx)/2; PosHeight = 0; }else if(PrintPositions == 3){ PosWidth = Area.cx - s.cx; PosHeight = 0; }else if(PrintPositions == 4){ PosWidth = 0; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 5){ PosWidth = (Area.cx - s.cx)/2; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 6){ PosWidth = Area.cx - s.cx; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 7){ PosWidth = 0; PosHeight= Area.cy - s.cy; }else if(PrintPositions == 8){ PosWidth = (Area.cx - s.cx)/2; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 9){ PosWidth = Area.cx - s.cx; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 10){ PosWidth = Area.cx * WRatio / 10000; PosHeight = Area.cy * HRatio / 10000; } TempBitmap.FillRect(Rect(0, 0, TempBitmap.Width, TempBitmap.Height), clWhite); HDC dcTemp = TempBitmap.CreateDC(); TempSrcSize.cx = TempSize.cx * dpi / WidthRes; TempSrcSize.cy = TempSize.cy * dpi / HeightRes; TempSrcN.cx = (Src.Width() - 1) / TempSrcSize.cx + 1; TempSrcN.cy = (Src.Height() - 1) / TempSrcSize.cy + 1; TRect TempSrcArea; double printY =PosHeight*HeightRes/dpi; for (int ty = 0; ty < TempSrcN.cy; ty++ ) { double printX = PosWidth*WidthRes/dpi; for (int tx = 0; tx < TempSrcN.cx; tx++ ) { TempSrcArea = Rect(Src.Left + TempSrcSize.cx * tx, Src.Top + TempSrcSize.cy * ty, Src.Left + TempSrcSize.cx * (tx + 1), Src.Top + TempSrcSize.cy * (ty + 1)); Pattern->UnionStretchBlt(dcTemp, 0, 0, TempSrcArea.Width() * WidthRes / dpi, TempSrcArea.Height() * HeightRes / dpi, TempSrcArea.Left, TempSrcArea.Top, TempSrcArea.Width(), TempSrcArea.Height(), SRCCOPY); //by siuaa 080424 //¿ø·¡ dcTemp¿¡ patternÀ» copyÇÑ ÈÄ vector¸¦ ¸ðµÎ ±×·Á ÁØ ÈÄ dcTemp¸¦ printer DC¿¡ copyÇϵµ·Ï //µÇ¾î ÀÖ¾ú´Âµ¥ vector°¡ Á¦´ë·Î ±×·ÁÁöÁö ¾Ê´Â ¿À·ù°¡ »ý°Ü¼­ //dcTemp¿¡ patternÀ» copyÇÑ ÈÄ printer DC¿¡ dcTempÀ» copyÇϰí printer DC¿¡ vector¸¦ Á÷Á¢ ±×¸®µµ·Ï ¼öÁ¤ BitBlt(Printer()->Canvas->Handle, printX, printY, TempSrcArea.Width() * WidthRes / dpi, TempSrcArea.Height() * HeightRes / dpi, dcTemp, 0, 0, SRCCOPY); if(printHeader != 2) // ColorChipÀ» printÇÒ ¶§´Â vector¸¦ ¾È ±×¸®±â À§ÇØ { // Vector ÇÁ¸°Æ® //by siuaa 080408 vector ¹Ýº¹ ÇÁ¸°Æ®¸¦ À§ÇØ Ãß°¡ // ÆäÀÌÁö º°·Î Ãâ·ÂµÇ¾îÁú patternÀÇ ¼ö°¡ ´Ù¸£¹Ç·Î À̰ÍÀ» °è»êÇØÁØ´Ù TSize stCnt; // ½ÃÀÛÇÏ´Â patternÀÇ index¸¦ ÀúÀå TSize endCnt; // ³¡³ª´Â patternÀÇ index¸¦ ÀúÀå stCnt.cx = TempSrcArea.Left / (Pattern->Width / r.cx); stCnt.cy = TempSrcArea.Top / (Pattern->Height / r.cy); endCnt.cx = (TempSrcArea.Left + TempSrcArea.Width() - 1) / (Pattern->Width / r.cx) + 1; endCnt.cy = (TempSrcArea.Top + TempSrcArea.Height() - 1) / (Pattern->Height / r.cy) + 1; if(stCnt.cx > r.cx) { stCnt.cx = 0; endCnt.cx = 0; }else if(endCnt.cx > r.cx) { endCnt.cx = r.cx; endCnt.cx -= stCnt.cx; }else { endCnt.cx -= stCnt.cx; } if(stCnt.cy > r.cy) { stCnt.cy = 0; endCnt.cy = 0; }else if(endCnt.cy > r.cy) { endCnt.cy = r.cy; endCnt.cy -= stCnt.cy; }else { endCnt.cy -= stCnt.cy; } //óÀ½ clippingÀÌ ¾ÈµÇ´Â ¹®Á¦¶§¹®¿¡ ³ªÁß¿¡ ´Ù½Ã ±×·ÁÁÖ±â À§ÇÑ color¸¦ Àоî¿È TColor tempColor; if(Pattern->BitsPerPixel == 8) { int indx = Pattern->GetPixelColor(TempSrcArea.Left, TempSrcArea.Top); tempColor = PaletteForm->DIB256Palette->Palette->ColorData[indx]->Color; }else { tempColor = static_cast(Pattern->GetPixelColor(TempSrcArea.Left, TempSrcArea.Top)); } SelectClipRgn(Printer()->Handle, NULL); VecDraw->PrintDraw(Printer()->Canvas->Handle, Src.Left - stCnt.cx * (Pattern->Width / r.cx) - PosWidth, Src.Top - stCnt.cy * (Pattern->Height / r.cy) - PosHeight, WidthRes, HeightRes, dpi, number, endCnt, item, tempColor); SelectClipRgn(Printer()->Handle, NULL); //VecDraw->PrintDraw(dcTemp, TempSrcArea.Left, TempSrcArea.Top, WidthRes, HeightRes, dpi, number, stCnt, endCnt); //VecDraw->PrintDraw(dcTemp, TempSrcArea, WidthRes, HeightRes, dpi, number); } //BitBlt(Printer()->Canvas->Handle, printX, printY, // TempSrcArea.Width() * WidthRes / dpi, TempSrcArea.Height() * HeightRes / dpi, dcTemp, 0, 0, SRCCOPY); printX += TempSrcArea.Width() * WidthRes / dpi; if (tx == TempSrcN.cx - 1) { printY += TempSrcArea.Height() * HeightRes / dpi; } } } TempBitmap.DeleteDC(dcTemp); // VectorPrint¿¡¼­´Â ÇÁ¸°Æ® ±¸¿ª(ºñÆ®¸Ê)À» ³Ñ¾î°¥ °æ¿ì°¡ »ý±â´Âµ¥ ÀÌ·±°ÍÀ» Áö¿ö¹ö¸®±â À§ÇÔ Printer()->Canvas->Brush->Color = clWhite; Printer()->Canvas->FillRect(Rect((s.cx+PosWidth)*WidthRes/dpi, 0, Printer()->PageWidth, Printer()->PageHeight)); Printer()->Canvas->FillRect(Rect(0, (s.cy+PosHeight)*HeightRes/dpi, Printer()->PageWidth, Printer()->PageHeight)); if (PosHeight) Printer()->Canvas->FillRect(Rect(0, 0, Printer()->PageWidth, PosHeight*HeightRes/dpi)); if (PosWidth) Printer()->Canvas->FillRect(Rect(0, 0, PosWidth*WidthRes/dpi, Printer()->PageHeight)); } } } else { //ÇÁ¸°ÅÍ ±âÁ¾¿¡ µû¶ó¼­ À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â if (Pattern->BitsPerPixel == 8) { //ÇÔ¼ö¸¸À¸·Î ÇÁ¸°Æ®Çϱ⿡´Â ¹®Á¦°¡ ¹ß»ýÇÏ¿© Ãß°¡ if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) goto fail; } else { if (!Bitmap.Create(Area.cx, Area.cy, Pattern->BitsPerPixel)) goto fail; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { if (!Bitmap.Resize(s.cx, s.cy, clWhite)) goto fail; } if (!Bitmap.Copy(0, 0, s.cx, s.cy, Pattern, Src.Left, Src.Top, SRCCOPY)) goto fail; //PrintPositions=1 LT //PrintPositions=2 MT //PrintPositions=3 RT //PrintPositions=4 LM //PrintPositions=5 MM //PrintPositions=6 RM //PrintPositions=7 LB //PrintPositions=8 MB //PrintPositions=9 RB //PrintPositions=10 FREE if(PrintPositions == 1){ PosWidth = 0; PosHeight = 0; }else if(PrintPositions == 2){ PosWidth = (Area.cx - s.cx)/2; PosHeight = 0; }else if(PrintPositions == 3){ PosWidth = Area.cx - s.cx; PosHeight = 0; }else if(PrintPositions == 4){ PosWidth = 0; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 5){ PosWidth = (Area.cx - s.cx)/2; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 6){ PosWidth = Area.cx - s.cx; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 7){ PosWidth = 0; PosHeight= Area.cy - s.cy; }else if(PrintPositions == 8){ PosWidth = (Area.cx - s.cx)/2; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 9){ PosWidth = Area.cx - s.cx; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 10){ PosWidth = Area.cx * WRatio / 10000; PosHeight = Area.cy * HRatio / 10000; } if (method) { if(!Bitmap.PrintBitmap(hPrintDC, 1+PosWidth*WidthRes/dpi, 1+PosHeight*WidthRes/dpi, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false, false)) goto fail; } else { if(!Bitmap.PrintBitmap(hPrintDC, 1+PosWidth*WidthRes/dpi, 1+PosHeight*WidthRes/dpi, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false, true)) goto fail; } //==========GreenFish Vector ÇÁ¸°Æ® //VecDraw->PrintDraw(Printer()->Canvas->Handle, Src.Left - PosWidth, Src.Top - PosHeight, WidthRes, HeightRes, dpi, number); if(printHeader != 2) // ColorChipÀ» printÇÒ ¶§´Â vector¸¦ ¾È ±×¸®±â À§ÇØ { // Vector ÇÁ¸°Æ® //by siuaa 080408 vector ¹Ýº¹ ÇÁ¸°Æ®¸¦ À§ÇØ Ãß°¡ // ÆäÀÌÁö º°·Î Ãâ·ÂµÇ¾îÁú patternÀÇ ¼ö°¡ ´Ù¸£¹Ç·Î À̰ÍÀ» °è»êÇØÁØ´Ù TSize stCnt; // ½ÃÀÛÇÏ´Â patternÀÇ index¸¦ ÀúÀå TSize endCnt; // ³¡³ª´Â patternÀÇ index¸¦ ÀúÀå stCnt.cx = Src.Left / (Pattern->Width / r.cx); stCnt.cy = Src.Top / (Pattern->Height / r.cy); endCnt.cx = (Src.Left + s.cx - 1) / (Pattern->Width / r.cx) + 1; endCnt.cy = (Src.Top + s.cy - 1) / (Pattern->Height / r.cy) + 1; if(stCnt.cx > r.cx) { stCnt.cx = 0; endCnt.cx = 0; }else if(endCnt.cx > r.cx) { endCnt.cx = r.cx; endCnt.cx -= stCnt.cx; }else { endCnt.cx -= stCnt.cx; } if(stCnt.cy > r.cy) { stCnt.cy = 0; endCnt.cy = 0; }else if(endCnt.cy > r.cy) { endCnt.cy = r.cy; endCnt.cy -= stCnt.cy; }else { endCnt.cy -= stCnt.cy; } //VecDraw->PrintDraw(hPrintCanvasDC, Src.Left - PosWidth, Src.Top - PosHeight, WidthRes, HeightRes, dpi, number, stCnt, endCnt); //óÀ½ clippingÀÌ ¾ÈµÇ´Â ¹®Á¦¶§¹®¿¡ ³ªÁß¿¡ ´Ù½Ã ±×·ÁÁÖ±â À§ÇÑ color¸¦ Àоî¿È TColor tempColor; if(Pattern->BitsPerPixel == 8) { int indx = Bitmap.GetPixelColor(0, 0); tempColor = PaletteForm->DIB256Palette->Palette->ColorData[indx]->Color; }else { tempColor = static_cast(Bitmap.GetPixelColor(0, 0)); } SelectClipRgn(hPrintDC, NULL); VecDraw->PrintDraw(hPrintDC, Src.Left - stCnt.cx * (Pattern->Width / r.cx) - PosWidth, Src.Top - stCnt.cy * (Pattern->Height / r.cy) - PosHeight, WidthRes, HeightRes, dpi, number, endCnt, item, tempColor); SelectClipRgn(hPrintDC, NULL); // ¼Óµµ °³¼±À» À§Çؼ­ ¸¸µé¾î º¸´Ù°¡ ÁÖ¼®À¸·Î ó¸®// ³ªÁß¿¡ ÇÊ¿äÇÒÁö ¸ô¶ó ±×³É ³²±è maxleo21c 05.07.18 // VecDraw->PrintDraw(hPrintCanvasDC, Src.Left - PosWidth, Src.Top - PosHeight, WidthRes, HeightRes, dpi, number); // Dst.Left = Src.Left - PosWidth; Dst.Top = Src.Top - PosHeight; // Dst.Right = Dst.Left + Area.cx; Dst.Bottom = Dst.Top + Area.cy; // VecDraw->PrintDraw(Printer()->Canvas->Handle, Dst, WidthRes, HeightRes, dpi, number); } // VectorPrint¿¡¼­´Â ÇÁ¸°Æ® ±¸¿ª(ºñÆ®¸Ê)À» ³Ñ¾î°¥ °æ¿ì°¡ »ý±â´Âµ¥ ÀÌ·±°ÍÀ» Áö¿ö¹ö¸®±â À§ÇÔ Printer()->Canvas->Brush->Color = clWhite; Printer()->Canvas->FillRect(Rect((s.cx+PosWidth)*WidthRes/dpi, 0, Printer()->PageWidth, Printer()->PageHeight)); Printer()->Canvas->FillRect(Rect(0, (s.cy+PosHeight)*HeightRes/dpi, Printer()->PageWidth, Printer()->PageHeight)); if (PosHeight) Printer()->Canvas->FillRect(Rect(0, 0, Printer()->PageWidth, PosHeight*HeightRes/dpi)); if (PosWidth) Printer()->Canvas->FillRect(Rect(0, 0, PosWidth*WidthRes/dpi, Printer()->PageHeight)); } } } }else { if (method == 2) { //Ãʱ⠹öÀü... À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â ¹æ¹ýÀÌ¿ë. Dst.Left = 0; Dst.Top = 0; if (Pattern->BitsPerPixel == 8) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; SetStretchBltMode(Printer()->Canvas->Handle, COLORONCOLOR); Pattern->UnionStretchBlt(Printer()->Canvas->Handle, Dst.Left, Dst.Top, Dst.Right, Dst.Bottom, Src.Left, Src.Top, Src.Right-Src.Left, Src.Bottom-Src.Top, SRCCOPY); } } } else { //ÇÁ¸°ÅÍ ±âÁ¾¿¡ µû¶ó¼­ À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â if (Pattern->BitsPerPixel == 8) { //ÇÔ¼ö¸¸À¸·Î ÇÁ¸°Æ®Çϱ⿡´Â ¹®Á¦°¡ ¹ß»ýÇÏ¿© Ãß°¡ if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) goto fail; } else { if (!Bitmap.Create(Area.cx, Area.cy, Pattern->BitsPerPixel)) goto fail; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { if (!Bitmap.Resize(s.cx, s.cy, clWhite)) goto fail; } if (!Bitmap.Copy(0, 0, s.cx, s.cy, Pattern, Src.Left, Src.Top, SRCCOPY)) goto fail; if (method) { if (!Bitmap.PrintBitmap(hPrintDC, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false, false)) goto fail; } else { if (!Bitmap.PrintBitmap(hPrintDC, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false, true)) goto fail; } } } } } #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->EndDoc(); END_LOG; return true; fail: if (hDC) Bitmap.DeleteDC(hDC); if (phDC) Pattern->DeleteDC(phDC); Printer()->EndDoc(); END_LOG; return false; } //--------------------------------------------------------------------------- //by siuaa 080408 //vectorÀÇ print¸¦ À§ÇØ ¼öÁ¤ //¹Ýº¹ÇØÁÖ´Â Èܼö¸¦ ÀúÀåÇÑ TSize r, print ¹æ¹ý(Ç¥ÁØ, °¡·ÎºÐÇÒ, ¼¼·ÎºÐÇÒ)À» Ç¥½ÃÇÏ´Â itemÀ» Ãß°¡ bool __fastcall SendToPrinterOnePage(TUnionBitmap *Pattern, double dpi, String title, int page, int method, unsigned int targetPageIndex, TSize r, int item, int printHeader, int PrintPositions, float WRatio, float HRatio, int number) // convert by celberus { BEGIN_LOG("Common"); HDC hPrintDC, hDC = NULL, phDC = NULL, hPrintCanvasDC; TRect Src, Dst; int WidthRes, HeightRes, x, y, PosWidth, PosHeight; TSize Area, n, s, TempSize, TempSrcSize, TempSrcN; const int TLimitSize = 4800; RGBQUAD rgb[256]; TUnionBitmap Bitmap; TTexpiaBitmap TempBitmap; int targetPageX=-1,targetPageY=-1; if(!targetPageIndex) goto fail; Printer()->Title = title; Printer()->Copies = page; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; hPrintCanvasDC = Printer()->Canvas->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); //ÀåÄ¡°íÀ¯Á¤º¸¸¦ ±¸ÇÔ. LOGPIXELSX=È­¸éÆø¹æÇâÀ¸·Î ·ÎÁöÄà ÀÎÄ¡´ç Çȼ¿ °³¼ö. -k3dogs HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; //HORXRES=½ºÅ©¸°ÀÇ Æø(Çȼ¿ ´ÜÀ§). Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; targetPageY = (targetPageIndex-1)/n.cx; targetPageX = (targetPageIndex-1) - targetPageY*n.cx; if(targetPageY>=n.cy) goto fail; if (Pattern->BitsPerPixel == 8) { Pattern->GetColors(0, 256, rgb); } if(PrintPositions != 0){ if (method == 2) { //Ãʱ⠹öÀü... À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â ¹æ¹ýÀÌ¿ë. Dst.Left = 0; Dst.Top = 0; //============ TempSize.cx = min(TLimitSize, Printer()->PageWidth); TempSize.cy = min(TLimitSize, Printer()->PageHeight); if (Pattern->BitsPerPixel == 8) { if (!TempBitmap.Create(TempSize.cx, TempSize.cy, 8, rgb)) goto fail; } else { if (!TempBitmap.Create(TempSize.cx, TempSize.cy, Pattern->BitsPerPixel)) goto fail; } //============ if (Pattern->BitsPerPixel == 8) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } y = targetPageY; { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; x = targetPageX; { //if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; //PrintPositions=1 LT //PrintPositions=2 MT //PrintPositions=3 RT //PrintPositions=4 LM //PrintPositions=5 MM //PrintPositions=6 RM //PrintPositions=7 LB //PrintPositions=8 MB //PrintPositions=9 RB //PrintPositions=10 FREE if(PrintPositions == 1){ PosWidth = 0; PosHeight = 0; }else if(PrintPositions == 2){ PosWidth = (Area.cx - s.cx)/2; PosHeight = 0; }else if(PrintPositions == 3){ PosWidth = Area.cx - s.cx; PosHeight = 0; }else if(PrintPositions == 4){ PosWidth = 0; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 5){ PosWidth = (Area.cx - s.cx)/2; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 6){ PosWidth = Area.cx - s.cx; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 7){ PosWidth = 0; PosHeight= Area.cy - s.cy; }else if(PrintPositions == 8){ PosWidth = (Area.cx - s.cx)/2; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 9){ PosWidth = Area.cx - s.cx; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 10){ PosWidth = Area.cx * WRatio / 10000; PosHeight = Area.cy * HRatio / 10000; } TempBitmap.FillRect(Rect(0, 0, TempBitmap.Width, TempBitmap.Height), clWhite); HDC dcTemp = TempBitmap.CreateDC(); TempSrcSize.cx = TempSize.cx * dpi / WidthRes; TempSrcSize.cy = TempSize.cy * dpi / HeightRes; TempSrcN.cx = (Src.Width() - 1) / TempSrcSize.cx + 1; TempSrcN.cy = (Src.Height() - 1) / TempSrcSize.cy + 1; TRect TempSrcArea; double printY =PosHeight*HeightRes/dpi; for (int ty = 0; ty < TempSrcN.cy; ty++ ) { double printX = PosWidth*WidthRes/dpi; for (int tx = 0; tx < TempSrcN.cx; tx++ ) { TempSrcArea = Rect(Src.Left + TempSrcSize.cx * tx, Src.Top + TempSrcSize.cy * ty, Src.Left + TempSrcSize.cx * (tx + 1), Src.Top + TempSrcSize.cy * (ty + 1)); Pattern->UnionStretchBlt(dcTemp, 0, 0, TempSrcArea.Width() * WidthRes / dpi, TempSrcArea.Height() * HeightRes / dpi, TempSrcArea.Left, TempSrcArea.Top, TempSrcArea.Width(), TempSrcArea.Height(), SRCCOPY); //by siuaa 080424 //¿ø·¡ dcTemp¿¡ patternÀ» copyÇÑ ÈÄ vector¸¦ ¸ðµÎ ±×·Á ÁØ ÈÄ dcTemp¸¦ printer DC¿¡ copyÇϵµ·Ï //µÇ¾î ÀÖ¾ú´Âµ¥ vector°¡ Á¦´ë·Î ±×·ÁÁöÁö ¾Ê´Â ¿À·ù°¡ »ý°Ü¼­ //dcTemp¿¡ patternÀ» copyÇÑ ÈÄ printer DC¿¡ dcTempÀ» copyÇϰí printer DC¿¡ vector¸¦ Á÷Á¢ ±×¸®µµ·Ï ¼öÁ¤ BitBlt(Printer()->Canvas->Handle, printX, printY, TempSrcArea.Width() * WidthRes / dpi, TempSrcArea.Height() * HeightRes / dpi, dcTemp, 0, 0, SRCCOPY); if(printHeader != 2) // ColorChipÀ» printÇÒ ¶§´Â vector¸¦ ¾È ±×¸®±â À§ÇØ { // Vector ÇÁ¸°Æ® //by siuaa 080408 vector ¹Ýº¹ ÇÁ¸°Æ®¸¦ À§ÇØ Ãß°¡ // ÆäÀÌÁö º°·Î Ãâ·ÂµÇ¾îÁú patternÀÇ ¼ö°¡ ´Ù¸£¹Ç·Î À̰ÍÀ» °è»êÇØÁØ´Ù TSize stCnt; // ½ÃÀÛÇÏ´Â patternÀÇ index¸¦ ÀúÀå TSize endCnt; // ³¡³ª´Â patternÀÇ index¸¦ ÀúÀå stCnt.cx = TempSrcArea.Left / (Pattern->Width / r.cx); stCnt.cy = TempSrcArea.Top / (Pattern->Height / r.cy); endCnt.cx = (TempSrcArea.Left + TempSrcArea.Width() - 1) / (Pattern->Width / r.cx) + 1; endCnt.cy = (TempSrcArea.Top + TempSrcArea.Height() - 1) / (Pattern->Height / r.cy) + 1; if(stCnt.cx > r.cx) { stCnt.cx = 0; endCnt.cx = 0; }else if(endCnt.cx > r.cx) { endCnt.cx = r.cx; endCnt.cx -= stCnt.cx; }else { endCnt.cx -= stCnt.cx; } if(stCnt.cy > r.cy) { stCnt.cy = 0; endCnt.cy = 0; }else if(endCnt.cy > r.cy) { endCnt.cy = r.cy; endCnt.cy -= stCnt.cy; }else { endCnt.cy -= stCnt.cy; } //óÀ½ clippingÀÌ ¾ÈµÇ´Â ¹®Á¦¶§¹®¿¡ ³ªÁß¿¡ ´Ù½Ã ±×·ÁÁÖ±â À§ÇÑ color¸¦ Àоî¿È TColor tempColor; if(Pattern->BitsPerPixel == 8) { int indx = Pattern->GetPixelColor(TempSrcArea.Left, TempSrcArea.Top); tempColor = PaletteForm->DIB256Palette->Palette->ColorData[indx]->Color; }else { tempColor = static_cast(Pattern->GetPixelColor(TempSrcArea.Left, TempSrcArea.Top)); } SelectClipRgn(Printer()->Handle, NULL); VecDraw->PrintDraw(Printer()->Canvas->Handle, tx * TempSrcArea.Width() + Src.Left - stCnt.cx * (Pattern->Width / r.cx) - PosWidth, ty * TempSrcArea.Height() + Src.Top - stCnt.cy * (Pattern->Height / r.cy) - PosHeight, WidthRes, HeightRes, dpi, number, endCnt, item, tempColor); SelectClipRgn(Printer()->Handle, NULL); //VecDraw->PrintDraw(dcTemp, TempSrcArea.Left, TempSrcArea.Top, WidthRes, HeightRes, dpi, number); //VecDraw->PrintDraw(dcTemp, TempSrcArea, WidthRes, HeightRes, dpi, number); } //BitBlt(Printer()->Canvas->Handle, printX, printY, // TempSrcArea.Width() * WidthRes / dpi, TempSrcArea.Height() * HeightRes / dpi, dcTemp, 0, 0, SRCCOPY); printX += TempSrcArea.Width() * WidthRes / dpi; if (tx == TempSrcN.cx - 1) { printY += TempSrcArea.Height() * HeightRes / dpi; } } } TempBitmap.DeleteDC(dcTemp); // VectorPrint¿¡¼­´Â ÇÁ¸°Æ® ±¸¿ª(ºñÆ®¸Ê)À» ³Ñ¾î°¥ °æ¿ì°¡ »ý±â´Âµ¥ ÀÌ·±°ÍÀ» Áö¿ö¹ö¸®±â À§ÇÔ Printer()->Canvas->Brush->Color = clWhite; Printer()->Canvas->FillRect(Rect((s.cx+PosWidth)*WidthRes/dpi, 0, Printer()->PageWidth, Printer()->PageHeight)); Printer()->Canvas->FillRect(Rect(0, (s.cy+PosHeight)*HeightRes/dpi, Printer()->PageWidth, Printer()->PageHeight)); if (PosHeight) Printer()->Canvas->FillRect(Rect(0, 0, Printer()->PageWidth, PosHeight*HeightRes/dpi)); if (PosWidth) Printer()->Canvas->FillRect(Rect(0, 0, PosWidth*WidthRes/dpi, Printer()->PageHeight)); } } } else { //ÇÁ¸°ÅÍ ±âÁ¾¿¡ µû¶ó¼­ À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â if (Pattern->BitsPerPixel == 8) { //ÇÔ¼ö¸¸À¸·Î ÇÁ¸°Æ®Çϱ⿡´Â ¹®Á¦°¡ ¹ß»ýÇÏ¿© Ãß°¡ if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) goto fail; } else { if (!Bitmap.Create(Area.cx, Area.cy, Pattern->BitsPerPixel)) goto fail; } y = targetPageY; { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; x = targetPageX; { //if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { if (!Bitmap.Resize(s.cx, s.cy, clWhite)) goto fail; } if (!Bitmap.Copy(0, 0, s.cx, s.cy, Pattern, Src.Left, Src.Top, SRCCOPY)) goto fail; //PrintPositions=1 LT //PrintPositions=2 MT //PrintPositions=3 RT //PrintPositions=4 LM //PrintPositions=5 MM //PrintPositions=6 RM //PrintPositions=7 LB //PrintPositions=8 MB //PrintPositions=9 RB //PrintPositions=10 FREE if(PrintPositions == 1){ PosWidth = 0; PosHeight = 0; }else if(PrintPositions == 2){ PosWidth = (Area.cx - s.cx)/2; PosHeight = 0; }else if(PrintPositions == 3){ PosWidth = Area.cx - s.cx; PosHeight = 0; }else if(PrintPositions == 4){ PosWidth = 0; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 5){ PosWidth = (Area.cx - s.cx)/2; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 6){ PosWidth = Area.cx - s.cx; PosHeight = (Area.cy - s.cy)/2; }else if(PrintPositions == 7){ PosWidth = 0; PosHeight= Area.cy - s.cy; }else if(PrintPositions == 8){ PosWidth = (Area.cx - s.cx)/2; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 9){ PosWidth = Area.cx - s.cx; PosHeight = Area.cy - s.cy; }else if(PrintPositions == 10){ PosWidth = Area.cx * WRatio / 10000; PosHeight = Area.cy * HRatio / 10000; } if (method) { if(!Bitmap.PrintBitmap(hPrintDC, 1+PosWidth*WidthRes/dpi, 1+PosHeight*WidthRes/dpi, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false, false)) goto fail; } else { if(!Bitmap.PrintBitmap(hPrintDC, 1+PosWidth*WidthRes/dpi, 1+PosHeight*WidthRes/dpi, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false, true)) goto fail; } //==========GreenFish Vector ÇÁ¸°Æ® if(printHeader != 2) // ColorChipÀ» printÇÒ ¶§´Â vector¸¦ ¾È ±×¸®±â À§ÇØ { //by siuaa 080408 vector ¹Ýº¹ ÇÁ¸°Æ®¸¦ À§ÇØ Ãß°¡ // ÆäÀÌÁö º°·Î Ãâ·ÂµÇ¾îÁú patternÀÇ ¼ö°¡ ´Ù¸£¹Ç·Î À̰ÍÀ» °è»êÇØÁØ´Ù TSize stCnt; // ½ÃÀÛÇÏ´Â patternÀÇ index¸¦ ÀúÀå TSize endCnt; // ³¡³ª´Â patternÀÇ index¸¦ ÀúÀå stCnt.cx = Src.Left / (Pattern->Width / r.cx); stCnt.cy = Src.Top / (Pattern->Height / r.cy); endCnt.cx = (Src.Left + s.cx - 1) / (Pattern->Width / r.cx) + 1; endCnt.cy = (Src.Top + s.cy - 1) / (Pattern->Height / r.cy) + 1; if(stCnt.cx > r.cx) { stCnt.cx = 0; endCnt.cx = 0; }else if(endCnt.cx > r.cx) { endCnt.cx = r.cx; endCnt.cx -= stCnt.cx; }else { endCnt.cx -= stCnt.cx; } if(stCnt.cy > r.cy) { stCnt.cy = 0; endCnt.cy = 0; }else if(endCnt.cy > r.cy) { endCnt.cy = r.cy; endCnt.cy -= stCnt.cy; }else { endCnt.cy -= stCnt.cy; } //óÀ½ clippingÀÌ ¾ÈµÇ´Â ¹®Á¦¶§¹®¿¡ ³ªÁß¿¡ ´Ù½Ã ±×·ÁÁÖ±â À§ÇÑ color¸¦ Àоî¿È TColor tempColor; if(Pattern->BitsPerPixel == 8) { int indx = Bitmap.GetPixelColor(0, 0); tempColor = PaletteForm->DIB256Palette->Palette->ColorData[indx]->Color; }else { tempColor = static_cast(Bitmap.GetPixelColor(0, 0)); } SelectClipRgn(hPrintDC, NULL); VecDraw->PrintDraw(hPrintCanvasDC, Src.Left - stCnt.cx * (Pattern->Width / r.cx) - PosWidth, Src.Top - stCnt.cy * (Pattern->Height / r.cy) - PosHeight, WidthRes, HeightRes, dpi, number, endCnt, item, tempColor); SelectClipRgn(hPrintDC, NULL); //VecDraw->PrintDraw(Printer()->Canvas->Handle, Src.Left - PosWidth, Src.Top - PosHeight, WidthRes, HeightRes, dpi, number); // ¼Óµµ °³¼±À» À§Çؼ­ ¸¸µé¾î º¸´Ù°¡ ÁÖ¼®À¸·Î ó¸®// ³ªÁß¿¡ ÇÊ¿äÇÒÁö ¸ô¶ó ±×³É ³²±è maxleo21c 05.07.18 // VecDraw->PrintDraw(hPrintCanvasDC, Src.Left - PosWidth, Src.Top - PosHeight, WidthRes, HeightRes, dpi, number); // Dst.Left = Src.Left - PosWidth; Dst.Top = Src.Top - PosHeight; // Dst.Right = Dst.Left + Area.cx; Dst.Bottom = Dst.Top + Area.cy; // VecDraw->PrintDraw(Printer()->Canvas->Handle, Dst, WidthRes, HeightRes, dpi, number); } // VectorPrint¿¡¼­´Â ÇÁ¸°Æ® ±¸¿ª(ºñÆ®¸Ê)À» ³Ñ¾î°¥ °æ¿ì°¡ »ý±â´Âµ¥ ÀÌ·±°ÍÀ» Áö¿ö¹ö¸®±â À§ÇÔ Printer()->Canvas->Brush->Color = clWhite; Printer()->Canvas->FillRect(Rect((s.cx+PosWidth)*WidthRes/dpi, 0, Printer()->PageWidth, Printer()->PageHeight)); Printer()->Canvas->FillRect(Rect(0, (s.cy+PosHeight)*HeightRes/dpi, Printer()->PageWidth, Printer()->PageHeight)); if (PosHeight) Printer()->Canvas->FillRect(Rect(0, 0, Printer()->PageWidth, PosHeight*HeightRes/dpi)); if (PosWidth) Printer()->Canvas->FillRect(Rect(0, 0, PosWidth*WidthRes/dpi, Printer()->PageHeight)); } } } }else { if (method == 2) { //Ãʱ⠹öÀü... À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â ¹æ¹ýÀÌ¿ë. Dst.Left = 0; Dst.Top = 0; if (Pattern->BitsPerPixel == 8) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } y = targetPageY; { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; x = targetPageX; { //if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; SetStretchBltMode(Printer()->Canvas->Handle, COLORONCOLOR); Pattern->UnionStretchBlt(Printer()->Canvas->Handle, Dst.Left, Dst.Top, Dst.Right, Dst.Bottom, Src.Left, Src.Top, Src.Right-Src.Left, Src.Bottom-Src.Top, SRCCOPY); } } } else { //ÇÁ¸°ÅÍ ±âÁ¾¿¡ µû¶ó¼­ À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â if (Pattern->BitsPerPixel == 8) { //ÇÔ¼ö¸¸À¸·Î ÇÁ¸°Æ®Çϱ⿡´Â ¹®Á¦°¡ ¹ß»ýÇÏ¿© Ãß°¡ if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) goto fail; } else { if (!Bitmap.Create(Area.cx, Area.cy, Pattern->BitsPerPixel)) goto fail; } y = targetPageY; { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; x = targetPageX; { // ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { if (!Bitmap.Resize(s.cx, s.cy, clWhite)) goto fail; } if (!Bitmap.Copy(0, 0, s.cx, s.cy, Pattern, Src.Left, Src.Top, SRCCOPY)) goto fail; if (method) { if (!Bitmap.PrintBitmap(hPrintDC, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false, false)) goto fail; } else { if (!Bitmap.PrintBitmap(hPrintDC, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false, true)) goto fail; } } } } } #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->EndDoc(); END_LOG; return true; fail: if (hDC) Bitmap.DeleteDC(hDC); if (phDC) Pattern->DeleteDC(phDC); Printer()->EndDoc(); END_LOG; return false; } #else //--------------------------------------------------------------------------- bool __fastcall SendToPrinter(TTexpiaBitmap *Pattern, double dpi, String title, int page, int method) { BEGIN_LOG("Common"); HDC hPrintDC, hDC = NULL, phDC = NULL; TRect Src, Dst; int WidthRes, HeightRes, x, y, PosWidth, PosHeight; TSize Area, n, s; RGBQUAD rgb[256]; TTexpiaBitmap Bitmap; Printer()->Title = title; Printer()->Copies = page; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); //ÀåÄ¡°íÀ¯Á¤º¸¸¦ ±¸ÇÔ. LOGPIXELSX=È­¸éÆø¹æÇâÀ¸·Î ·ÎÁöÄà ÀÎÄ¡´ç Çȼ¿ °³¼ö. -k3dogs HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; //HORXRES=½ºÅ©¸°ÀÇ Æø(Çȼ¿ ´ÜÀ§). Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if ((phDC = Pattern->CreateDC()) == NULL) goto fail; if (Pattern->BitsPerPixel == 8) { GetDIBColorTable(phDC, 0, 256, rgb); } if (method == 2) { //Ãʱ⠹öÀü... À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â ¹æ¹ýÀÌ¿ë. Dst.Left = 0; Dst.Top = 0; if (Pattern->BitsPerPixel == 8) { SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; // if (Pattern->BitsPerPixel == 8) { // SetDIBColorTable(Printer()->Canvas->Handle, 0, 256, rgb); // } Dst.Right = s.cx * WidthRes / dpi; Dst.Bottom = s.cy * HeightRes / dpi; Src.Right = Src.Left + s.cx; Src.Bottom = Src.Top + s.cy; // Printer()->Canvas->CopyMode = cmSrcCopy; // Printer()->Canvas->CopyRect(Dst, Pattern->Canvas, Src); //which is right? SetStretchBltMode(Printer()->Canvas->Handle, COLORONCOLOR); StretchBlt(Printer()->Canvas->Handle, Dst.Left, Dst.Top, Dst.Right, Dst.Bottom, phDC, Src.Left, Src.Top, Src.Right-Src.Left, Src.Bottom-Src.Top, SRCCOPY); } } } else { //ÇÁ¸°ÅÍ ±âÁ¾¿¡ µû¶ó¼­ À©µµ¿ì¿¡¼­ Áö¿øÇÏ´Â if (Pattern->BitsPerPixel == 8) { //ÇÔ¼ö¸¸À¸·Î ÇÁ¸°Æ®Çϱ⿡´Â ¹®Á¦°¡ ¹ß»ýÇÏ¿© Ãß°¡ if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) goto fail; } else { if (!Bitmap.Create(Area.cx, Area.cy, Pattern->BitsPerPixel)) goto fail; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { if (!Bitmap.Resize(s.cx, s.cy, clWhite)) goto fail; } if ((hDC = Bitmap.CreateDC()) == NULL) goto fail; if (!BitBlt(hDC, 0, 0, s.cx, s.cy, phDC, Src.Left, Src.Top, SRCCOPY)) goto fail; Bitmap.DeleteDC(hDC); hDC = NULL; if (method) { // LEADTOOLS V13 -> 15 : L_PrintBitmapExt() -> L_PrintBitmap() - by monkman (2007.05.04) if (!L_PrintBitmap(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false)) goto fail; } else { if (!L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false)) goto fail; } } } } Pattern->DeleteDC(phDC); #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->EndDoc(); END_LOG; return true; fail: if (hDC) Bitmap.DeleteDC(hDC); if (phDC) Pattern->DeleteDC(phDC); Printer()->EndDoc(); END_LOG; return false; } #endif //--------------------------------------------------------------------------- /* bool __fastcall SendToPrinter(Graphics::TBitmap *Pattern, int dpi, String title, int page) { HDC hPrintDC = NULL, hDC = NULL; TRect Src, Dst; int WidthRes, HeightRes, x, y; TSize Area, n, s; RGBQUAD rgb[256]; BITMAPHANDLE Bitmap; Printer()->Title = title; Printer()->Copies = page; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * dpi / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * dpi / HeightRes; // // Epson Color Stylus Ex, 1200 ¶Ç´Â HP Color LaserJet 4500¿¡¼­ // Area.cx, Area.cyÀÇ size¸¦ ÁÙ¿©¼­ testÇØ º¼°Í. // n.cx = ((Pattern->Width - 1) / Area.cx) + 1; n.cy = ((Pattern->Height - 1) / Area.cy) + 1; if (Pattern->PixelFormat == pf8bit) { GetDIBColorTable(Pattern->Canvas->Handle, 0, 256, rgb); } switch (Pattern->PixelFormat) { case pf8bit: if (!Bitmap.Create(Area.cx, Area.cy, 8, rgb)) return false; break; case pf15bit: if (!Bitmap.Create(Area.cx, Area.cy, 16)) return false; break; case pf24bit: if (!Bitmap.Create(Area.cx, Area.cy, 24)) return false; break; } for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = Pattern->Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)) Printer()->NewPage(); Src.Left = x * Area.cx; s.cx = Pattern->Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != Bitmap.Width || s.cy != Bitmap.Height) { Bitmap.Resize(s.cx, s.cy, clWhite); } hDC = Bitmap.CreateDC(); BitBlt(hDC, 0, 0, s.cx, s.cy, Pattern->Canvas->Handle, Src.Left, Src.Top, SRCCOPY); Bitmap.DeleteDC(hDC); L_PrintBitmapFast(hPrintDC, Bitmap.Handle, 1, 1, s.cx * WidthRes / dpi, s.cy * HeightRes / dpi, false); } } Printer()->EndDoc(); return true; } */ //--------------------------------------------------------------------------- void __fastcall LoadFont(TIniFile *IniFile, TFont *Font, String Section) { BEGIN_LOG("Common"); TRegIniFile *RegIniFile = NULL; String fontname; fontname = IniFile->ReadString(Section, "Name", DefaultFontName); #ifndef LOCK_USB TIniFile *CommonIniFile = new TIniFile(AppDataBin + "\\Configuration.ini"); bool bExistIniFile = false; if(FileExists(AppDataBin + "\\Configuration.ini")) bExistIniFile = true; if (CommonIniFile && bExistIniFile) { Font->Name = CommonIniFile->ReadString("Common", "DefaultFontName", fontname); } else { RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw if (RegIniFile) { Font->Name = RegIniFile->ReadString("Common", "DefaultFontName", fontname); delete RegIniFile; } } if (CommonIniFile) delete CommonIniFile; #else TIniFile *CommonIniFile = new TIniFile(AppDataBin + "\\Configuration.ini"); if (CommonIniFile) { Font->Name = CommonIniFile->ReadString("Common", "DefaultFontName", fontname); delete CommonIniFile; } #endif CommonIniFile = NULL; RegIniFile = NULL; END_LOG; } //--------------------------------------------------------------------- void __fastcall SaveFont(TIniFile *IniFile, TFont *Font, String Section) { /* TRegIniFile *RegIniFile; IniFile->WriteString(Section, "Name", Font->Name); #ifndef LOCK_USB RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw if (RegIniFile) { RegIniFile->WriteString("Common", "DefaultFontName", Font->Name); } delete RegIniFile; #else TIniFile *CommonIniFile = new TIniFile(AppDataBin + "\\Configuration.ini"); CommonIniFile->WriteString("Common", "DefaultFontName", Font->Name); delete CommonIniFile; #endif */ BEGIN_LOG("Common"); TIniFile *CommonIniFile = new TIniFile(AppDataBin + "\\Configuration.ini"); CommonIniFile->WriteString("Common", "DefaultFontName", Font->Name); delete CommonIniFile; END_LOG; } //--------------------------------------------------------------------- void __fastcall SetSmallFont(TFont *Font) { if (SmallFont) Font->Name = SmallFont->Name; Font->Size = 8; } //--------------------------------------------------------------------------- String __fastcall GetColorName(TColorData *cd) { switch (cd->Kind) { case 0: if (cd->Page==0) return Format("%d-%d-%d", OPENARRAY(TVarRec, (255-cd->RGB.rgbRed, 255-cd->RGB.rgbGreen, 255-cd->RGB.rgbBlue))); else return PrinterColor->PN2Code(cd->Page, cd->Number); case 1: ////////////k3dogs 20001211 return Pantone1000->PN2Code(cd->Page, cd->Number); // case 2: // return PantoneTextile->PN2Code(cd->Page, cd->Number); case 3: return StandardColor->PN2Code(cd->Page, cd->Number); case 4: return TextileColor->PN2Code(cd->Page, cd->Number); case 5: //20050518 by lhskys pantone Color return PantoneTextile->PN2Code(cd->Page, cd->Number); case 6: return (char*)cd->additionalColorData->GetData(TAG_PANTONE_COLOR);//cd->PantoneColor; //080408 default: return cd->ColorName; } } //--------------------------------------------------------------------------- String __fastcall GetTexpiaVersion() { String Version = "None"; TIniFile *IniFile = NULL; #ifndef LOCK_USB IniFile = new TIniFile(AppDataBin + "\\Configuration.ini"); bool bExistIniFile = false; if(FileExists(AppDataBin + "\\Configuration.ini")) bExistIniFile = true; if (IniFile && bExistIniFile) { Version = IniFile->ReadString("Common", "Version", "None"); } else { TRegIniFile *RegIniFile = new TRegIniFile(RegFilename); RegIniFile->RootKey = HKEY_LOCAL_MACHINE; RegIniFile->OpenKey(RegFilename + "\\",true); // yw if (RegIniFile) { Version = RegIniFile->ReadString("Common", "Version", "None"); delete RegIniFile; } } #else IniFile = new TIniFile(AppDataBin + "\\Configuration.ini"); Version = IniFile->ReadString("Common", "Version", "None"); #endif if (IniFile) delete IniFile; return Version; } //--------------------------------------------------------------------------- TGrid __fastcall StrToGrid(String str) { Char *tok = L")x ", *s, *p; TGrid g; s = _tcsdup(str.c_str()); p = _tcstok(s, tok); if (_tcscmp(p, L"Cm")==0) g.Unit = uCm; else if (_tcscmp(p, L"Inch")==0) g.Unit = uInch; else g.Unit = uDot; p = _tcstok(NULL, tok); g.X = std::_ttof(p); p = _tcstok(NULL, tok); g.Y = std::_ttof(p); free(s); return g; } //--------------------------------------------------------------------------- String __fastcall GridToStr(TUnit u, double x, double y) { Char *unit[3] = { L"Dot", L"Inch", L"Cm" }; return Format("%s) %f x %f", OPENARRAY(TVarRec, (unit[(int)u], x, y))); } //--------------------------------------------------------------------------- bool __fastcall IsFocused(TWinControl *WControl, String ControlType, String ControlName) { // 2005 Vector Upgrade =-= [ Begin ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- // ÇØ´ç ControlÀÇ ÀÚ½Ä Control Áß¿¡ Focus°¡ ÀÖ´ÂÁö¸¦ Á¶»çÇÑ´Ù - by monkman(2005.03.02) TWinControl *FocusControl = NULL; String FindControlName = ""; bool Focused = false; if (ControlName.IsEmpty()) { // ControlNameÀÌ ÁÖ¾îÁöÁö ¾Ê¾ÒÀ» °æ¿ì for (int i = 0; i < WControl->ComponentCount; i++) { // ÇØ´ç Control¾È¿¡ ¸ðµç ÀÚ½Ä ControlÀ» ã¾ÆÁ¶»ç // ControlTypeÀÌ ¾ø´Ù¸é ¸ðµÎ Á¶»ç, ÀÖ´Ù¸é ÇØ´çµÇ´Â ControlÀÇ Type¸¸ ã¾Æ Á¶»ç if (!ControlType.IsEmpty() && CompareStr(WControl->Components[i]->ClassName(), ControlType)) continue; FindControlName = WControl->Components[i]->Name; FocusControl = dynamic_cast(WControl->FindComponent(FindControlName)); if (FocusControl) { Focused = FocusControl->Focused(); // ÇØ´ç Control¿¡ Focus°¡ ÀÖ´ÂÁö } if (Focused) break; // Focus°¡ ÀÖ´Ù¸é ¹Ù·Î ReturnÀÌ µÇµµ·Ï ÇÑ´Ù } } else { FocusControl = dynamic_cast(WControl->FindComponent(ControlName)); // Control NameÀÌ ÁÖ¾îÁ³´Ù¸é Á÷Á¢ ¹Ù·Î ã´Â´Ù if (FocusControl) { Focused = FocusControl->Focused(); } } return Focused; // =-=-=-=-=-=-=-=-=-=-=-= [ End ] =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- } //--------------------------------------------------------------------------- void __fastcall SubStrReplace(String &StrSrc, String StrFind, String StrReplace) { // Sparrow's Tip¿¡¼­ °¡Á®¿Â ¼Ò½º - by monkman (2005.04.14) // String³»ÀÇ ¸ðµç ¹®ÀÚ¿¡ ´ëÇØ ƯÁ¤ ¹®ÀÚµéÀ» ±³Ã¼ÇÏ´Â ÇÔ¼ö // »ç¿ë ¿¹ : StringReplace(Src, "-", "_"); String StrNext; int nIndex = StrSrc.Pos(StrFind); if (nIndex > 0) { StrNext = StrSrc.SubString(nIndex + StrFind.Length(), StrSrc.Length() - (nIndex + StrFind.Length()-1)); SubStrReplace(StrNext, StrFind, StrReplace); StrSrc = StrSrc.SubString(1, nIndex - 1) + StrReplace + StrNext; } } //--------------------------------------------------------------------------- void __fastcall MakeWaterMark(TTexpiaBitmap *WaterMark) { BEGIN_LOG("Common"); HDC dcWater = WaterMark->CreateDC(); gdp::Graphics graphics(dcWater); gdp::Image image(L"C:\\Pattern\\texpro_g.bmp"); gdp::TextureBrush textureBrush(&image); textureBrush.RotateTransform(330, gdp::MatrixOrderAppend); // then rotate graphics.FillRectangle(&textureBrush, 0, 0, WaterMark->Width, WaterMark->Height); WaterMark->SaveToFile("C:\\water.bmp", FILE_BMP); WaterMark->DeleteDC(dcWater); END_LOG; } //--------------------------------------------------------------------------- void __fastcall MakeWaterMarkToBitmap(TUnionBitmap *Pattern) { BEGIN_LOG("Common"); RGBQUAD rgb[256]; FILEINFO FileInfo; TTexpiaBitmap *WaterMark = NULL; WaterMark = new TTexpiaBitmap; WaterMark->Create(Pattern->Width, Pattern->Height, Pattern->BitsPerPixel); MakeWaterMark(WaterMark); HDC dcWater = WaterMark->CreateDC(); Pattern->UnionBitBlt(dcWater, 0, 0, WaterMark->Width, WaterMark->Height, 0, 0, SRCINVERT, true); WaterMark->DeleteDC(dcWater); delete WaterMark; END_LOG; } //--------------------------------------------------------------------------- void __fastcall GetAvailableFontFamilyName(Char *name) { gdp::InstalledFontCollection collection; int count = collection.GetFamilyCount(); int numFamilies; gdp::FontFamily *allfontFamilies; gdp::FontFamily *fontFamilies; fontFamilies = new gdp::FontFamily[count]; collection.GetFamilies(count, fontFamilies, &numFamilies); bool hasTahoma = false, hasArial = false; Char familyName[100], tempName[100]; int fcount = 0; for (int i = 0; i < count; i++){ BOOL isAvailable = fontFamilies[i].IsAvailable(); if (isAvailable){ fontFamilies[i].GetFamilyName(familyName); if (fcount == 0) _tcscpy(tempName, familyName); if (_tcscmp(familyName, L"Tahoma") == 0){ hasTahoma = true; break; } else if (_tcscmp(familyName, L"Arial") == 0){ hasArial = true; } fcount++; } } if (hasTahoma){ _tcscpy(name, L"Tahoma"); } else if (hasArial){ _tcscpy(name, L"Arial"); } else { _tcscpy(name, tempName); } } //--------------------------------------------------------------------------- void __fastcall PaintWaterMark(HDC dcDst, int px, int py, int vw, int vh, float zoomIn, float zoomOut, float angle, bool bAntiAlias) { BEGIN_LOG("Common"); // TFont *CanvasFont = MainImageForm->iMainImage->Canvas->Font; gdp::Graphics graphics(dcDst); float fontSize = (100*zoomIn)/zoomOut; Char WaterMarkFontName[100]; GetAvailableFontFamilyName(WaterMarkFontName); gdp::FontFamily fontFamily(WaterMarkFontName); gdp::Font font(&fontFamily, fontSize, gdp::FontStyleBold, gdp::UnitPixel); gdp::PointF origin(0.0f, 0.0f); gdp::SolidBrush solidBrush(gdp::Color(192, 0, 255, 255)); gdp::StringFormat fontFormat; fontFormat.SetFormatFlags(gdp::StringFormatFlagsNoClip); gdp::Matrix matrix; float w = vw; float h = vh; // float cx = w/2; // float cy = h/2; matrix.Rotate(angle, gdp::MatrixOrderAppend); graphics.SetTransform(&matrix); if (bAntiAlias) graphics.SetTextRenderingHint(gdp::TextRenderingHintAntiAlias); Char string[] = L"texpro trial"; float maxlen = sqrt(w*w + h*h); gdp::RectF layoutRect; layoutRect.Width = fontSize*10; layoutRect.Height = fontSize*3; float posx = 0, posy = 0; int linecount = 0; for (posy = h - maxlen; posy < maxlen; posy += layoutRect.Height){ layoutRect.Y = posy; for (posx = w - maxlen - linecount*layoutRect.Width/2; posx < maxlen; posx += layoutRect.Width){ layoutRect.X = posx; graphics.DrawString(string, -1, &font, layoutRect, &fontFormat, &solidBrush); } linecount++; } END_LOG; } //--------------------------------------------------------------------------- bool __fastcall PrinterAvailable() { if (Printer() && Printer()->Printers->Count > 0) { try { if (Printer()->Handle){ return true; } } catch (EPrinter&) { return false; } return true; } return false; } //--------------------------------------------------------------------------- bool __fastcall DocSheetSendToPrinter(TPDocSheet *Sheet, int page, bool bCenter, int language) { BEGIN_LOG("Common"); HDC hPrintDC, hDC = NULL, phDC = NULL; TRect Src, Dst; int WidthRes, HeightRes, x, y, i, sx, sy; TSize Area, n, s; TTexpiaBitmap dBitmap, tBitmap; TPDocElement *ep; TPDocViewStatus vs; Printer()->Title = Sheet->Title; Printer()->Copies = page; Printer()->Orientation = Sheet->Orientation; Printer()->BeginDoc(); hPrintDC = Printer()->Handle; WidthRes = GetDeviceCaps(hPrintDC, LOGPIXELSX); HeightRes = GetDeviceCaps(hPrintDC, LOGPIXELSY); Area.cx = GetDeviceCaps(hPrintDC, HORZRES) * Sheet->DotsPerInch / WidthRes; Area.cy = GetDeviceCaps(hPrintDC, VERTRES) * Sheet->DotsPerInch / HeightRes; n.cx = ((Sheet->Bitmap->Width - 1) / Area.cx) + 1; n.cy = ((Sheet->Bitmap->Height - 1) / Area.cy) + 1; if (!tBitmap.Create(Sheet->Bitmap->Width, Sheet->Bitmap->Height, Sheet->Bitmap->BitsPerPixel)) goto fail; if ((phDC = tBitmap.CreateDC()) == NULL) goto fail; if ((hDC = Sheet->Bitmap->CreateDC()) == NULL) goto fail; BitBlt(phDC, 0, 0, tBitmap.Width, tBitmap.Height, hDC, 0, 0, SRCCOPY); Sheet->Bitmap->DeleteDC(hDC); hDC = NULL; //============================ for (i=0; iElement->Count; i++) { ep = (TPDocElement *)Sheet->Element->Items[i]; ep->PaintReport((TPDocObject *)ep, phDC, vs, true, false, language); } //============================ // PaintData(phDC, true); //============================ if (!dBitmap.Create(Area.cx, Area.cy, Sheet->Bitmap->BitsPerPixel)) goto fail; for (y = 0; y < n.cy; y++) { Src.Top = y * Area.cy; s.cy = tBitmap.Height - Src.Top; if (s.cy > Area.cy) s.cy = Area.cy; for (x = 0; x < n.cx; x++) { if ((x > 0) || (y > 0)){ #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->NewPage(); } Src.Left = x * Area.cx; s.cx = tBitmap.Width - Src.Left; if (s.cx > Area.cx) s.cx = Area.cx; if (s.cx != dBitmap.Width || s.cy != dBitmap.Height) { if (!dBitmap.Resize(s.cx, s.cy, clWhite)) goto fail; } if ((hDC = dBitmap.CreateDC()) == NULL) goto fail; if (!BitBlt(hDC, 0, 0, s.cx, s.cy, phDC, Src.Left, Src.Top, SRCCOPY)) goto fail; dBitmap.DeleteDC(hDC); hDC = NULL; if (bCenter) { sx = 0; sy = 0; } else { sx = 1; sy = 1; } if (!L_PrintBitmap(hPrintDC, dBitmap.Handle, sx, sy, s.cx * WidthRes / Sheet->DotsPerInch, s.cy * HeightRes / Sheet->DotsPerInch, false)) goto fail; } } tBitmap.DeleteDC(phDC); #ifdef TRIAL PaintWaterMark(hPrintDC, 0, 0, Area.cx, Area.cy, 1, 1, random(2) ? random(30)+10 : random(30)+320); #endif Printer()->EndDoc(); END_LOG; return true; fail: if (hDC) dBitmap.DeleteDC(hDC); if (phDC) tBitmap.DeleteDC(phDC); Printer()->EndDoc(); END_LOG; return false; } //--------------------------------------------------------------------------- void __fastcall RunRearrange(bool undo, int *Code, int *CodeColor) { BEGIN_LOG(""); RECT rt; if (MainImageForm->iMainImage->LayerList->Count > 1) { rt = Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height); if (undo) MainImageForm->UndoSave(UK_REARRANGE, rt); if (!RunRearrange_layer(Code, CodeColor) && undo){ MainImageForm->Undo->RemoveLast(); }else{ MainImageForm->iMainImage->MakeBeforeBitmap(); //by linuxjun for layer rearrange } } else { rt = Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height); if (undo) MainImageForm->UndoSave(UK_ALL, rt); if (!RunRearrange_none(Code) && undo) MainImageForm->Undo->RemoveLast(); } END_LOG; } //--------------------------------------------------------------------------- bool __fastcall RunRearrange_none(int *InCode) { BEGIN_LOG(""); int *Code = NULL; if (InCode == NULL){ Code = new int[256]; } else { Code = InCode; } int ColorCount[256]; int i, j, n, x, y, count; Byte *Scan; TList *List = NULL; sColorArrange *pOrder = NULL; TChoiceColor *ChoiceColor = NULL; RGBQUAD rgb[256]; if (MainImageForm->Palette->UseColor>2) { if ((ChoiceColor = new TChoiceColor) == NULL) goto fail; if ((List = new TList) == NULL) goto fail; for (i=0; i<=255; i++) { Code[i] = -1; ColorCount[i] = 0; } if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) goto fail; for (y=0; yiMainImage->uBitmap->Height; y++) { Scan = MainImageForm->iMainImage->uBitmap->GetScanLine(y); for (x=0; xiMainImage->uBitmap->Width; x++) { n = Scan[x]; ColorCount[n]++; //k3dogs 20010131 } } MainImageForm->iMainImage->uBitmap->StopScanLine(); i = 2; while (i<252) { if (ColorCount[i]) { j = find(ColorCount[i], List); if ((pOrder = (sColorArrange *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(sColorArrange))) == NULL) goto fail; pOrder->no = i; pOrder->spread = 0; pOrder->count = ColorCount[i]; if (jCount) List->Insert(j, pOrder); else List->Add(pOrder); } i = i+1; } for (i=0; iCount; i++) { pOrder = (sColorArrange *)List->Items[i]; Code[pOrder->no] = ChoiceColor->Count+1; ChoiceColor->Add(MainImageForm->Palette, pOrder->no); } if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) goto fail; for (y=0; yiMainImage->uBitmap->Height; y++) { Scan = MainImageForm->iMainImage->uBitmap->GetScanLine(y); for (x=0; xiMainImage->uBitmap->Width; x++) { n = Scan[x]; if (n>1) Scan[x] = Code[n]+1; //k3dogs 20010131 } MainImageForm->iMainImage->uBitmap->PutScanLine(y); } MainImageForm->iMainImage->uBitmap->StopScanLine(); for (i=0; iCount; i++) { MainImageForm->Palette->ColorData[i+2] = ChoiceColor->ColorMap[i]; } if (List->Count) MainImageForm->Palette->UseColor = List->Count+1; else MainImageForm->Palette->UseColor = 1; //2; //shin 061013 while (List->Count> 0) { pOrder = (sColorArrange *)List->First(); HeapFree(GetProcessHeap(), 0, pOrder); List->Remove(pOrder); } delete List; List = NULL; delete ChoiceColor; ChoiceColor = NULL; } if (InCode == NULL){ delete[] Code; } MainImageForm->Palette->ToRGBQUAD(rgb, 256); MainImageForm->iMainImage->uBitmap->PutColors(0, 256, rgb); PaletteForm->DIB256Palette->ChoiceIndex = 2; //shin 061013 1? 2? END_LOG; return true; fail: if (List) { while (List->Count>0) { pOrder = (sColorArrange *)List->First(); HeapFree(GetProcessHeap(), 0, pOrder); List->Remove(pOrder); } delete List; } MainImageForm->iMainImage->uBitmap->StopScanLine(); if (ChoiceColor) delete ChoiceColor; if (InCode == NULL){ delete[] Code; } EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; return false; } //--------------------------------------------------------------------------- bool __fastcall RunRearrange(TUnionBitmap *Bitmap, TPalette *Palette) { BEGIN_LOG(""); int *Code = NULL; Code = new int[256]; int ColorCount[256]; int i, j, n, x, y, count; Byte *Scan; TList *List = NULL; sColorArrange *pOrder = NULL; TChoiceColor *ChoiceColor = NULL; RGBQUAD rgb[256]; if ((ChoiceColor = new TChoiceColor) == NULL) goto fail; if ((List = new TList) == NULL) goto fail; for (i=0; i<=255; i++) { Code[i] = -1; ColorCount[i] = 0; } if (!Bitmap->StartScanLine()) goto fail; for (y=0; y < Bitmap->Height; y++) { Scan = Bitmap->GetScanLine(y); for (x=0; x < Bitmap->Width; x++) { n = Scan[x]; ColorCount[n]++; } } Bitmap->StopScanLine(); i = 2; while (i<252) { if (ColorCount[i]) { j = find(ColorCount[i], List); if ((pOrder = (sColorArrange *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(sColorArrange))) == NULL) goto fail; pOrder->no = i; pOrder->spread = 0; pOrder->count = ColorCount[i]; if (jCount) List->Insert(j, pOrder); else List->Add(pOrder); } i = i+1; } for (i=0; iCount; i++) { pOrder = (sColorArrange *)List->Items[i]; Code[pOrder->no] = ChoiceColor->Count+1; ChoiceColor->Add(Palette, pOrder->no); } if (!Bitmap->StartScanLine()) goto fail; for (y=0; y < Bitmap->Height; y++) { Scan = Bitmap->GetScanLine(y); for (x=0; x < Bitmap->Width; x++) { n = Scan[x]; if (n>1) Scan[x] = Code[n]+1; } Bitmap->PutScanLine(y); } Bitmap->StopScanLine(); for (i=0; iCount; i++) { Palette->ColorData[i+2] = ChoiceColor->ColorMap[i]; } if (List->Count) Palette->UseColor = List->Count+1; else Palette->UseColor = 1; //2; //shin 061013 while (List->Count> 0) { pOrder = (sColorArrange *)List->First(); HeapFree(GetProcessHeap(), 0, pOrder); List->Remove(pOrder); } delete List; List = NULL; delete ChoiceColor; ChoiceColor = NULL; delete[] Code; Palette->ToRGBQUAD(rgb, 256); Bitmap->PutColors(0, 256, rgb); END_LOG; return true; fail: if (List) { while (List->Count>0) { pOrder = (sColorArrange *)List->First(); HeapFree(GetProcessHeap(), 0, pOrder); List->Remove(pOrder); } delete List; } MainImageForm->iMainImage->uBitmap->StopScanLine(); if (ChoiceColor) delete ChoiceColor; if (Code) delete[] Code; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; return false; } //--------------------------------------------------------------------------- bool __fastcall RunRearrange_layer(int *InCode, int *InCodeColor) { BEGIN_LOG(""); int *Code = NULL, *CodeColor = NULL; if (InCode == NULL){ Code = new int[256]; } else { Code = InCode; } if (InCodeColor == NULL){ CodeColor = new int[256]; } else { CodeColor = InCodeColor; } int ColorCount[256]; int i, j, n, x, y, count; Byte *Scan; TList *List = NULL; sColorArrange *pOrder = NULL; TChoiceColor *ChoiceColor = NULL; RGBQUAD rgb[256]; TUnionBitmap *Bitmap; // convert by celberus if (MainImageForm->Palette->UseColor>2) { if ((ChoiceColor = new TChoiceColor) == NULL) goto fail; if ((List = new TList) == NULL) goto fail; for (i=0; i<=255; i++) { Code[i] = -1; ColorCount[i] = 0; } ///////////////////////////////////k3dogs 20010131 Make Colors, which have same RGB, to indicate same palette TColorData *first, *second; int p, q, r; for (r=0; r<256; r++) CodeColor[r] = 0; for (p=2; p<252; p++) { if (CodeColor[p]) continue; first = MainImageForm->Palette->ColorData[p]; for (q=p+1; q<256; q++) { if (CodeColor[q]) continue; second = MainImageForm->Palette->ColorData[q]; if ((first->RGB.rgbBlue == second->RGB.rgbBlue) && (first->RGB.rgbGreen == second->RGB.rgbGreen) && (first->RGB.rgbRed == second->RGB.rgbRed)) CodeColor[q] = p; } } /////////////////////////////////// count = MainImageForm->iMainImage->LayerList->Count; for (i = 0; i < count; i++) { Bitmap = MainImageForm->iMainImage->GetLayerBitmap(i); if (!Bitmap->StartScanLine()) goto fail; for (y=0; y < Bitmap->Height; y++) { Scan = Bitmap->GetScanLine(y); for (x=0; x < Bitmap->Width; x++) { n = Scan[x]; //ColorCount[n]++; //k3dogs 20010131 if (CodeColor[n] == 0) ColorCount[n]++;// else ColorCount[ CodeColor[n] ]++; // } } Bitmap->StopScanLine(); } i = 2; while (i<252) { if (ColorCount[i]) { j = find(ColorCount[i], List); if ((pOrder = (sColorArrange *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(sColorArrange))) == NULL) goto fail; pOrder->no = i; pOrder->spread = 0; pOrder->count = ColorCount[i]; if (jCount) List->Insert(j, pOrder); else List->Add(pOrder); } i = i+1; } for (i=0; iCount; i++) { pOrder = (sColorArrange *)List->Items[i]; Code[pOrder->no] = ChoiceColor->Count+1; ChoiceColor->Add(MainImageForm->Palette, pOrder->no); } for (i = 0; i < count; i++) { Bitmap = MainImageForm->iMainImage->GetLayerBitmap(i); if (!Bitmap->StartScanLine()) goto fail; for (y=0; y < Bitmap->Height; y++) { Scan = Bitmap->GetScanLine(y); for (x=0; x < Bitmap->Width; x++) { n = Scan[x]; //if (n>1) Scan[x] = Code[n]+1; //k3dogs 20010131 if (n>1) { if (CodeColor[n] == 0) Scan[x] = Code[n]+1; // else Scan[x] = Code[ CodeColor[n] ] + 1; // } } Bitmap->PutScanLine(y); } Bitmap->StopScanLine(); MainImageForm->iMainImage->SetLayerBitmap(i); } for (i=0; iCount; i++) { MainImageForm->Palette->ColorData[i+2] = ChoiceColor->ColorMap[i]; } MainImageForm->Palette->UseColor = List->Count+1; while (List->Count>0) { pOrder = (sColorArrange *)List->First(); HeapFree(GetProcessHeap(), 0, pOrder); List->Remove(pOrder); } delete List; List = NULL; delete ChoiceColor; ChoiceColor = NULL; } if (InCode == NULL){ delete[] Code; } if (InCodeColor == NULL){ delete[] CodeColor; } MainImageForm->Palette->ToRGBQUAD(rgb, 256); MainImageForm->iMainImage->RearrangeColors(rgb); PaletteForm->DIB256Palette->ChoiceIndex = 2; END_LOG; return true; fail: if (List) { while (List->Count>0) { pOrder = (sColorArrange *)List->First(); HeapFree(GetProcessHeap(), 0, pOrder); List->Remove(pOrder); } delete List; } MainImageForm->iMainImage->uBitmap->StopScanLine(); if (ChoiceColor) delete ChoiceColor; if (InCode == NULL){ delete[] Code; } if (InCodeColor == NULL){ delete[] CodeColor; } EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; return false; } //--------------------------------------------------------------------------- int __fastcall find(int current, TList *List) { int k, p, count; sColorArrange *pOrder; k = 0; while (kCount) { pOrder = (sColorArrange *)List->Items[k]; count = pOrder->count; p = k; if (pOrder->spread) { while (true) { k = k+1; pOrder = (sColorArrange *)List->Items[k]; count = count+pOrder->count; if (k+1Count) { pOrder = (sColorArrange *)List->Items[k+1]; if (pOrder->spread==0 || pOrder->spread==1) break; } else break; } } k = k+1; if (current>count) return p; } return List->Count; } //--------------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////////////////// TWinControl *g_FocusControl; /** @brief ÀÎÀÚ·Î ¹ÞÀº ÄÁÆ®·ÑÀÌ ¹®ÀÚ ÀÔ·ÂÀÌ °¡´ÉÇÑ ÄÁÆ®·ÑÀÎÁö Á¶»çÇÑ´Ù @param WinControl : ¹®ÀÚ ÀÔ·ÂÀÌ °¡´ÉÇÑÁö Á¶»çÇϱâ À§ÇÑ ´ë»ó ÄÁÆ®·Ñ @return bool : ¹®ÀÚ ÀÔ·ÂÀÌ °¡´ÉÇÑ °æ¿ì true, ºÒ°¡´ÉÇÒ °æ¿ì false */ bool __fastcall IsEditableControl(TWinControl *AWinControl) { TCustomEdit *customEdit = dynamic_cast(AWinControl); if (customEdit && customEdit->ReadOnly == false) return true; // TEdit *Edit = dynamic_cast(AWinControl); // if (Edit && Edit->ReadOnly == false) // return true; // TMaskEdit *MaskEdit = dynamic_cast(AWinControl); // if (MaskEdit && MaskEdit->ReadOnly == false) // return true; // TLabeledEdit *LabeledEdit = dynamic_cast(AWinControl); // if (LabeledEdit && LabeledEdit->ReadOnly == false) // return true; // TButtonedEdit *ButtonedEdit = dynamic_cast(AWinControl); // if (ButtonedEdit && ButtonedEdit->ReadOnly == false) // return true; // TRzEdit *RzEdit = dynamic_cast(AWinControl); // if (RzEdit && RzEdit->ReadOnly == false) // return true; // TRzMaskEdit *RzMaskEdit = dynamic_cast(AWinControl); // if (RzMaskEdit && RzMaskEdit->ReadOnly == false) // return true; // TRzSpinEdit *RzSpinEdit = dynamic_cast(AWinControl); // if (RzSpinEdit && RzSpinEdit->ReadOnly == false) // return true; // TRzNumericEdit *RzNumericEdit = dynamic_cast(AWinControl); // if (RzNumericEdit && RzNumericEdit->ReadOnly == false) // return true; // TRzExpandEdit *RzExpandEdit = dynamic_cast(AWinControl); // if (RzExpandEdit && RzExpandEdit->ReadOnly == false) // return true; // TNumEdit *numEdit = dynamic_cast(AWinControl); // if (numEdit && numEdit->ReadOnly == false) // return true; // TMemo *Memo = dynamic_cast(AWinControl); // if (Memo && Memo->ReadOnly == false) // return true; // TRzMemo *RzMemo = dynamic_cast(AWinControl); // if (RzMemo && RzMemo->ReadOnly == false) // return true; // TRichEdit *RichEdit = dynamic_cast(AWinControl); // if (RichEdit && RichEdit->ReadOnly == false) // return true; // TRzRichEdit *RzRichEdit = dynamic_cast(AWinControl); // if (RzRichEdit && RzRichEdit->ReadOnly == false) // return true; // TRzDateTimeEdit *RzDateTimeEdit = dynamic_cast(AWinControl); // if (RzDateTimeEdit && RzDateTimeEdit->ReadOnly == false) // return true; TComboBox *ComboBox = dynamic_cast(AWinControl); if (ComboBox && ComboBox->Style != csDropDownList) return true; TRzComboBox *RzComboBox = dynamic_cast(AWinControl); if (RzComboBox && RzComboBox->Style != csDropDownList) return true; TCustomComboBoxEx *customComboBoxEx = dynamic_cast(AWinControl); if (customComboBoxEx && customComboBoxEx->Style != csExDropDownList) return true; // TComboBoxEx *ComboBoxEx = dynamic_cast(AWinControl); // if (ComboBoxEx && ComboBoxEx->Style != csExDropDownList) // return true; TDrawGrid *DrawGrid = dynamic_cast(AWinControl); if (DrawGrid && DrawGrid->Options.Contains(goEditing) == true) return true; // TStringGrid *StringGrid = dynamic_cast(AWinControl); // if (StringGrid && StringGrid->Options.Contains(goEditing) == true // && StringGrid->EditorMode == true) // return true; // TRzStringGrid *RzStringGrid = dynamic_cast(AWinControl); // if (RzStringGrid && RzStringGrid->Options.Contains(goEditing) == true // && RzStringGrid->EditorMode == true) // return true; TRzShellTree *rzShellTree = dynamic_cast(AWinControl); if (rzShellTree) return true; return false; } //--------------------------------------------------------------------------- /** @brief ÀÎÀÚ·Î ¹ÞÀº ÄÁÆ®·ÑÀÌ SelectAllÀÌ °¡´ÉÇÑ ControlÀ̸é SelectAll ½ÃŲ´Ù - by monkman (2010.07.07) @param Sender : SelectAll °¡´ÉÇÑÁö Á¶»çÇϱâ À§ÇÑ ´ë»ó ÄÁÆ®·Ñ @return bool : SelectAllÀÌ °¡´ÉÇϸé true, ºÒ°¡´ÉÇϸé false */ bool __fastcall SetFocusAndSelectAll(TObject *Sender) { TCustomEdit *customEdit = dynamic_cast(Sender); if (customEdit && customEdit->ReadOnly == false) { customEdit->SetFocus(); customEdit->SelectAll(); return true; } // TEdit *Edit = dynamic_cast(Sender); // if (Edit && Edit->ReadOnly == false) { // Edit->SetFocus(); // Edit->SelectAll(); // return true; // } // TMemo *Memo = dynamic_cast(Sender); // if (Memo && Memo->ReadOnly == false) { // Memo->SetFocus(); // Memo->SelectAll(); // return true; // } // TMaskEdit *MaskEdit = dynamic_cast(Sender); // if (MaskEdit && MaskEdit->ReadOnly == false) { // MaskEdit->SetFocus(); // MaskEdit->SelectAll(); // return true; // } // TLabeledEdit *LabeledEdit = dynamic_cast(Sender); // if (LabeledEdit && LabeledEdit->ReadOnly == false) { // LabeledEdit->SetFocus(); // LabeledEdit->SelectAll(); // return true; // } // TButtonedEdit *ButtonedEdit = dynamic_cast(Sender); // if (ButtonedEdit && ButtonedEdit->ReadOnly == false) { // ButtonedEdit->SetFocus(); // ButtonedEdit->SelectAll(); // return true; // } // TRichEdit *RichEdit = dynamic_cast(Sender); // if (RichEdit && RichEdit->ReadOnly == false) { // RichEdit->SetFocus(); // RichEdit->SelectAll(); // return true; // } // TRzEdit *RzEdit = dynamic_cast(Sender); // if (RzEdit && RzEdit->ReadOnly == false) { // RzEdit->SetFocus(); // RzEdit->SelectAll(); // return true; // } // TRzMaskEdit *RzMaskEdit = dynamic_cast(Sender); // if (RzMaskEdit && RzMaskEdit->ReadOnly == false) { // RzMaskEdit->SetFocus(); // RzMaskEdit->SelectAll(); // return true; // } // TRzDateTimeEdit *RzDateTimeEdit = dynamic_cast(Sender); // if (RzDateTimeEdit && RzDateTimeEdit->ReadOnly == false) { // RzDateTimeEdit->SetFocus(); // RzDateTimeEdit->SelectAll(); // return true; // } // TRzSpinEdit *RzSpinEdit = dynamic_cast(Sender); // if (RzSpinEdit && RzSpinEdit->ReadOnly == false) { // RzSpinEdit->SetFocus(); // RzSpinEdit->SelectAll(); // return true; // } // TRzNumericEdit *RzNumericEdit = dynamic_cast(Sender); // if (RzNumericEdit && RzNumericEdit->ReadOnly == false) { // RzNumericEdit->SetFocus(); // RzNumericEdit->SelectAll(); // return true; // } // TRzExpandEdit *RzExpandEdit = dynamic_cast(Sender); // if (RzExpandEdit && RzExpandEdit->ReadOnly == false) { // RzExpandEdit->SetFocus(); // RzExpandEdit->SelectAll(); // return true; // } // TRzMemo *RzMemo = dynamic_cast(Sender); // if (RzMemo && RzMemo->ReadOnly == false) { // RzMemo->SetFocus(); // RzMemo->SelectAll(); // return true; // } // TRzRichEdit *RzRichEdit = dynamic_cast(Sender); // if (RzRichEdit && RzRichEdit->ReadOnly == false) { // RzRichEdit->SetFocus(); // RzRichEdit->SelectAll(); // return true; // } // TNumEdit *numEdit = dynamic_cast(Sender); // if (numEdit && numEdit->ReadOnly == false) { // numEdit->SetFocus(); // numEdit->SelectAll(); // return true; // } TComboBox *ComboBox = dynamic_cast(Sender); if (ComboBox && ComboBox->Style != csDropDownList) { ComboBox->SetFocus(); ComboBox->SelectAll(); return true; } TRzComboBox *RzComboBox = dynamic_cast(Sender); if (RzComboBox && RzComboBox->Style != csDropDownList) { RzComboBox->SetFocus(); RzComboBox->SelectAll(); return true; } TCustomComboBoxEx *customComboBoxEx = dynamic_cast(Sender); if (customComboBoxEx && customComboBoxEx->Style != csExDropDownList) { customComboBoxEx->SetFocus(); customComboBoxEx->SelectAll(); return true; } // TComboBoxEx *ComboBoxEx = dynamic_cast(Sender); // if (ComboBoxEx && ComboBoxEx->Style != csDropDownList) { // ComboBoxEx->SetFocus(); // ComboBoxEx->SelectAll(); // return true; // } return false; } //--------------------------------------------------------------------------- // ÀԷµǴø ÇѱÛÀ» ¸¶¹«¸® Áþ±â À§ÇÔ - by monkman (2010.07.28) void __fastcall EditFinish(TWinControl *AWinControl) { TCustomEdit *customEdit = dynamic_cast(AWinControl); if (customEdit && customEdit->ReadOnly == false) { // UNICODE IME ¹ö±× ó¸® - by monkman (2010.09.08) Application->ProcessMessages(); } } //--------------------------------------------------------------------------- void __fastcall Copy_From_LOGFONTA_To_LOGFONTW(LOGFONTA logfontA, LOGFONTW &logfontW) { logfontW.lfHeight = logfontA.lfHeight; logfontW.lfWidth = logfontA.lfWidth; logfontW.lfEscapement = logfontA.lfEscapement; logfontW.lfOrientation = logfontA.lfOrientation; logfontW.lfWeight = logfontA.lfWeight; logfontW.lfItalic = logfontA.lfItalic; logfontW.lfUnderline = logfontA.lfUnderline; logfontW.lfStrikeOut = logfontA.lfStrikeOut; logfontW.lfCharSet = logfontA.lfCharSet; logfontW.lfOutPrecision = logfontA.lfOutPrecision; logfontW.lfClipPrecision = logfontA.lfClipPrecision; logfontW.lfQuality = logfontA.lfQuality; logfontW.lfPitchAndFamily = logfontA.lfPitchAndFamily; AnsiString aFaceName = logfontA.lfFaceName; String wFaceName = (String)aFaceName; _tcscpy(logfontW.lfFaceName, wFaceName.c_str()); } //--------------------------------------------------------------------------- // handle¿¡ ÇØ´çÇÏ´Â TWinControl ã±â TWinControl* __fastcall FindWinControl(HWND handle) { TWinControl *result = NULL; // handleÀÌ WinControl ³»ºÎ¿¡ ÀÖ´Â WinControlÀÇ HWND ÀÎ °æ¿ì // FindControl()·Î WinControlÀÌ Ã£¾ÆÁöÁö ¾Ê¾Æ¼­ Parent¸¦ Á¶»çÇϵµ·Ï ¹Ýº¹½ÃÅ´ while (handle) { result= FindControl(handle); if (result) return result; handle = GetParent(handle); } return NULL; } //--------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////////////////