//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "YarnScan_F.h" #include "Common.h" #include "Exception.h" #include "YarnTable_F.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "lttwn_bc.lib" #pragma link "TPImage" #pragma link "TPSelectImage" #pragma link "TPSpin" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_YARNSCAN StringTable[0] #define IDS_FUNCTION StringTable[1] #define IDS_SCAN StringTable[2] #define IDS_SCANSETUP StringTable[3] #define IDS_TABLE StringTable[4] #define IDS_YARNDATA StringTable[5] #define IDS_CENTER StringTable[6] #define IDS_THICK StringTable[7] #define IDS_COLORFILE StringTable[8] #define IDS_FILTERVALUE StringTable[9] #define IDS_FILTERVIEW StringTable[10] #define IDS_ZOOMIN StringTable[11] #define IDS_ZOOMOUT StringTable[12] //--------------------------------------------------------------------------- TYarnScanForm *YarnScanForm; //--------------------------------------------------------------------------- enum SItem {S_NONE, S_CENTER, S_LENGTH, S_THICK } Item; //--------------------------------------------------------------------------- __fastcall TYarnScanForm::TYarnScanForm(TComponent* Owner) : TForm(Owner) { hWnd = ((TWinControl *) Owner)->Handle; //=============================================================== StringTable.Create(DirectoryItem, Language, "YarnScan"); SetSmallFont(Font); SetSmallFont(lbValue->Font); Caption = IDS_YARNSCAN; GroupBox1->Caption = IDS_FUNCTION; sbScan->Hint = IDS_SCAN; sbSetup->Hint = IDS_SCANSETUP; sbSave->Hint = IDS_COMMON_SAVEAS; //IDS_SAVEFILE; sbGrid->Hint = IDS_COMMON_GRID; sbTable->Hint = IDS_TABLE; GroupBox2->Caption = IDS_COMMON_POSITION; GroupBox3->Caption = IDS_YARNDATA; Label1->Caption = IDS_CENTER; Label2->Caption = IDS_COMMON_LENGTH; Label3->Caption = IDS_THICK; GroupBox4->Caption = IDS_COLORFILE; Label6->Caption = IDS_FILTERVALUE; sbFilterView->Hint = IDS_FILTERVIEW; Zoom->Caption = IDS_COMMON_ZOOM; sbZoomIn->Hint = IDS_ZOOMIN; sbZoomOut->Hint = IDS_ZOOMOUT; //=============================================================== } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::FormCreate(TObject *Sender) { TIniFile *IniFile = new TIniFile(AppDataItem+"\\YarnScan.ini"); if (IniFile) { Left = IniFile->ReadInteger("Form", "Left", (Screen->Width-Width)>>1); Top = IniFile->ReadInteger("Form", "Top", (Screen->Height-Height)>>1); delete IniFile; } if (Image->Bitmap->Create(Image->Width, Image->Height, 16) == false) goto fail; Image->Bitmap->FillRect(Rect(0, 0, Image->Width, Image->Height), clWhite); YarnTableForm->OnCloseForm = CloseFileForm; TEMP = NULL; Item = S_NONE; FUnit = uDot; return; fail: PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::FormDestroy(TObject *Sender) { TIniFile *IniFile = new TIniFile(AppDataItem+"\\YarnScan.ini"); if (IniFile) { if (Left<0) Left = 10; if (Top<0) Top = 10; IniFile->WriteInteger("Form", "Left", Left); IniFile->WriteInteger("Form", "Top", Top); delete IniFile; } if (TEMP) { TEMP->unlock(); delete TEMP; } } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::sbScanClick(TObject *Sender) { TTexpiaBitmap *tb = Image->Bitmap; BITMAPHANDLE hBitmap; int nRet, w, h; HDC sDC = NULL, dDC = NULL; InitData(); if ((nRet = L_InitBitmap(&hBitmap, 0, 0, 16)) < SUCCESS) goto fail; nRet = L_TwainAcquire(Handle, &hBitmap); if (nRet == SUCCESS && hBitmap.Flags.Allocated) { tb->ResizeStretch(hBitmap.Width, hBitmap.Height); if ((sDC = L_CreateLeadDC(&hBitmap)) == NULL) goto fail; if ((dDC = tb->CreateDC()) == NULL) goto fail; BitBlt(dDC, 0, 0, hBitmap.Width, hBitmap.Height, sDC, 0, 0, SRCCOPY); tb->DeleteDC(dDC); L_DeleteLeadDC(sDC); Item = S_CENTER; CopyToTemp(); } L_FreeBitmap(&hBitmap); ViewLight(); ScrollBarEnabled(); Image->Repaint(); return; fail: if (dDC) tb->DeleteDC(dDC); if (sDC) L_DeleteLeadDC(sDC); if (nRet == SUCCESS) L_FreeBitmap(&hBitmap); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::sbSetupClick(TObject *Sender) { int k = L_TwainSelect(Handle); if (k != SUCCESS && k != ERROR_TWAIN_CANCEL) MessageDlg(IDS_MESSAGE_ERRORDEVICE, mtError, TMsgDlgButtons()<Down) { sbFilterView->Down = false; sbFilterViewClick(sbFilterView); } if (FYarnData.Thick && FYarnData.Length) { YarnTableForm->Visible = true; YarnTableForm->BringToFront(); sbTable->Down = true; SaveAs(); } } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::sbTableClick(TObject *Sender) { YarnTableForm->Visible = sbTable->Down; if (sbTable->Down) YarnTableForm->BringToFront(); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::sbGridClick(TObject *Sender) { Image->Grid = sbGrid->Down; } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::LengthClick(TObject *Sender) { Item = S_LENGTH; ViewLight(); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::CenterClick(TObject *Sender) { Item = S_CENTER; ViewLight(); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::ThickClick(TObject *Sender) { Item = S_THICK; ViewLight(); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::sbUnitClick(TObject *Sender) { if (FUnit == uDot) { sbUnit->Caption = "Inch"; FUnit = uInch; stLength->Caption = Format("%.2f", OPENARRAY(TVarRec,(FYarnData.Length / 160.0))); stThick->Caption = Format("%.2f", OPENARRAY(TVarRec,(FYarnData.Thick / 160.0))); } else if (FUnit == uInch) { sbUnit->Caption = "Cm"; FUnit = uCm; stLength->Caption = Format("%.2f", OPENARRAY(TVarRec,(FYarnData.Length * 2.54 / 160.0))); stThick->Caption = Format("%.2f", OPENARRAY(TVarRec,(FYarnData.Thick * 2.54 / 160.0))); } else { sbUnit->Caption = "Dot"; FUnit = uDot; stLength->Caption = Format("%d", OPENARRAY(TVarRec,(FYarnData.Length))); stThick->Caption = Format("%d", OPENARRAY(TVarRec,(FYarnData.Thick))); } } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::sbZoomClick(TObject *Sender) { TSpeedButton *sb = (TSpeedButton *) Sender; if (sb->Tag) { switch (Image->ZoomIn) { case 1: switch (Image->ZoomOut) { case 16: Image->SetZoom(1, 8); ZoomText->Caption = "1/8"; break; case 8: Image->SetZoom(1, 4); ZoomText->Caption = "1/4"; break; case 4: Image->SetZoom(1, 2); ZoomText->Caption = "1/2"; break; case 2: Image->SetZoom(1, 1); ZoomText->Caption = "1"; break; case 1: Image->SetZoom(2, 1); ZoomText->Caption = "2"; break; } break; case 2: Image->SetZoom(4, 1); ZoomText->Caption = "4"; break; case 4: Image->SetZoom(8, 1); ZoomText->Caption = "8"; break; case 8: Image->SetZoom(16, 1); ZoomText->Caption = "16"; break; } } else { switch (Image->ZoomOut) { case 1: switch (Image->ZoomIn) { case 16: Image->SetZoom(8, 1); ZoomText->Caption = "8"; break; case 8: Image->SetZoom(4, 1); ZoomText->Caption = "4"; break; case 4: Image->SetZoom(2, 1); ZoomText->Caption = "2"; break; case 2: Image->SetZoom(1, 1); ZoomText->Caption = "1"; break; case 1: Image->SetZoom(1, 2); ZoomText->Caption = "1/2"; break; } break; case 2: Image->SetZoom(1, 4); ZoomText->Caption = "1/4"; break; case 4: Image->SetZoom(1, 8); ZoomText->Caption = "1/8"; break; case 8: Image->SetZoom(1, 16); ZoomText->Caption = "1/16"; break; } } ScrollBarEnabled(); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::sbFilterViewClick(TObject *Sender) { double ravg, gavg, bavg; int x, y, delta, limit = spFilter->Value * 3; Byte r, g, b; WORD value, *DP, *SP, *T = NULL; if (TEMP) { if (sbFilterView->Down) { if (FYarnData.Length && FYarnData.Thick) { CalculateData(); T = TEMP->lock(); if (T == NULL) goto fail; if (Image->Bitmap->StartScanLine() == false) goto fail; RGBAverage(ravg, gavg, bavg); for (y = start.y; y < end.y; y++) { DP = (WORD *) Image->Bitmap->GetScanLine(y); SP = TEMP->pointer(0, y); for (x = start.x; x < end.x; x++) { value = SP[x]; b = ((value & 0x1F) << 3) | ((value & 0x1F) >> 2); value >>= 5; g = ((value & 0x1F) << 3) | ((value & 0x1F) >> 2); value >>= 5; r = ((value & 0x1F) << 3) | ((value & 0x1F) >> 2); delta = (r-ravg)+(g-gavg)+(b-bavg); if (delta > -limit && delta < limit) DP[x] = ~SP[x]; else DP[x] = SP[x]; } Image->Bitmap->PutScanLine(y); } Image->Bitmap->StopScanLine(); TEMP->unlock(); } } else { T = TEMP->lock(); if (T == NULL) goto fail; if (Image->Bitmap->StartScanLine() == false) goto fail; for (y = start.y; y < end.y; y++) { DP = (WORD *) Image->Bitmap->GetScanLine(y) + start.x; SP = TEMP->pointer(start.x, y); memcpy(DP, SP, sizeof(WORD) * (end.x - start.x)); Image->Bitmap->PutScanLine(y); } Image->Bitmap->StopScanLine(); TEMP->unlock(); } Image->Repaint(); } return; fail: if (T) TEMP->unlock(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::spFilterClick(TObject *Sender) { spFilter->SetFocus(); spFilter->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::ScrollBarVScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { Image->PositionY = ScrollBarV->Position * ((double) Image->ZoomOut / Image->ZoomIn); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::ScrollBarHScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { Image->PositionX = ScrollBarH->Position * ((double) Image->ZoomOut / Image->ZoomIn); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::ImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { X = (X *((double)Image->ZoomOut / Image->ZoomIn)) + Image->PositionX; Y = (Y *((double)Image->ZoomOut / Image->ZoomIn)) + Image->PositionY; double length; if (Item == S_LENGTH) { if (step > 0) { step = 0; if (IsDraw) { DrawLine(); IsDraw = false; } lbValue->Visible = false; if (X < 0) X = 0; if (X > Image->Bitmap->Width) X = Image->Bitmap->Width; second.x = X; second.y = Y; length = CalculateLength(); FYarnData.Length = length; if (FUnit == uInch) length = length / 160.0; else if (FUnit == uCm) length = length * 2.54 / 160; stLength->Caption = Format("%.2f", OPENARRAY(TVarRec, (length))); Item = S_NONE; ViewLight(); } else { step = 1; start.x = X; first.x = X; first.y = Y; second.x = X; second.y = Y; DrawLine(); IsDraw = true; lbValue->Visible = true; lbValue->Caption = "0"; } } else if (Item == S_THICK) { if (IsDraw) { DrawHorizon(); IsDraw = false; } length = (abs(center - Y)) * 2; if (length > 80) length = 80; FYarnData.Thick = length; if (FUnit == uInch) length = length / 160.0; else if (FUnit == uCm) length = length * 2.54 / 160; stThick->Caption = Format("%.2f", OPENARRAY(TVarRec, (length))); lbValue->Visible = false; Item = S_NONE; ViewLight(); } else if (Item == S_CENTER) { if(IsDraw) { DrawLine(); IsDraw = false; } center = Y; stCenter->Caption = Y; lbValue->Visible = false; Item = S_NONE; ViewLight(); } } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::ImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { double length; int limitY; if (X > Image->Width - lbValue->Width) lbValue->Left = Image->Width - lbValue->Width; else lbValue->Left = X; if (Y < lbValue->Height) lbValue->Top = Y + MenuPanel->Height + 10; else lbValue->Top = Y + MenuPanel->Height - 20; X = (X *((double)Image->ZoomOut / Image->ZoomIn)) + Image->PositionX; Y = (Y *((double)Image->ZoomOut / Image->ZoomIn)) + Image->PositionY; if (Item == S_CENTER) { if (IsDraw) DrawLine(); first.x = 0; first.y = Y; second.x = Image->Bitmap->Width - 1; second.y = Y; DrawLine(); IsDraw = true; lbValue->Caption = Format("%d", OPENARRAY(TVarRec, (Y))); lbValue->Visible = true; } else if (Item == S_LENGTH) { if (step > 0) { if (IsDraw) DrawLine(); if (X < 0) X = 0; if (X > Image->Bitmap->Width) X = Image->Bitmap->Width; second.x = X; second.y = Y; DrawLine(); IsDraw = true; length = CalculateLength(); if (FUnit == uInch) length = length / 160.0; else if (FUnit == uCm) length = length * 2.54 / 160; lbValue->Caption = Format("%.2f", OPENARRAY(TVarRec, (length))); } } else if (Item == S_THICK) { if (IsDraw) DrawHorizon(); limitY = abs(center - Y); if (limitY > 40) Y = center - 40; first.x = 0; first.y = Y; second.x = Image->Bitmap->Width - 1; second.y = Y; DrawHorizon(); IsDraw = true; length = (abs(center - Y)) * 2; if (FUnit == uInch) length = length / 160.0; else if (FUnit == uCm) length = length * 2.54 / 160; lbValue->Caption = Format("%.2f", OPENARRAY(TVarRec, (length))); lbValue->Visible = true; } if (X <= Image->Bitmap->Width && Y <= Image->Bitmap->Height) { stPositionX->Caption = Format("%d", OPENARRAY(TVarRec,(X))); stPositionY->Caption = Format("%d", OPENARRAY(TVarRec,(Y))); } lbValue->Repaint(); } //--------------------------------------------------------------------------- //// Private Methods /////////////////////////////////////////////////////// //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::InitData() { FYarnData.Length = 0; FYarnData.Width = 80; FYarnData.Thick = 0; stCenter->Caption = "0"; stLength->Caption = "0"; stThick->Caption = "0"; Image->SetZoom(1, 1); ZoomText->Caption = "1"; ScrollBarH->Position = 0; ScrollBarV->Position = 0; } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::ScrollBarEnabled() { int zw, zh; zw = Image->Bitmap->Width * ((double) Image->ZoomIn / Image->ZoomOut); zh = Image->Bitmap->Height * ((double) Image->ZoomIn / Image->ZoomOut); if (Image->Width < zw) { ScrollBarH->Enabled = true; ScrollBarH->Max = zw - Image->Width; } else ScrollBarH->Enabled = false; if (Image->Height < zh) { ScrollBarV->Enabled = true; ScrollBarV->Max = zh - Image->Height; } else ScrollBarV->Enabled = false; } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::ViewLight() { TLabel *lb; for (int i = 1; i <= 3; i++) { lb = (TLabel *) FindComponent("Label" + AnsiString(i)); if (Item == i) lb->Font->Color = clRed; else lb->Font->Color = clWindowText; } } //--------------------------------------------------------------------------- int __fastcall TYarnScanForm::CalculateLength() { int dx, dy; dx = first.x - second.x; dy = first.y - second.y; return sqrt(dx * dx + dy * dy); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::DrawLine() { HDC hDC = NULL; HPEN hOldPen; int nDrawMode; hDC = Image->Bitmap->CreateDC(); if (hDC == NULL) {EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return;} hOldPen = SelectObject(hDC, GetStockObject(WHITE_PEN)); nDrawMode = GetROP2(hDC); SetROP2(hDC, R2_XORPEN); MoveToEx(hDC, first.x, first.y, NULL); LineTo(hDC, second.x, second.y); SetROP2(hDC, nDrawMode); SelectObject(hDC, hOldPen); Image->Bitmap->DeleteDC(hDC); Image->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::DrawHorizon() { HDC hDC = NULL; HPEN hOldPen; int nDrawMode; hDC = Image->Bitmap->CreateDC(); if (hDC == NULL) {EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return;} hOldPen = SelectObject(hDC, GetStockObject(WHITE_PEN)); nDrawMode = GetROP2(hDC); SetROP2(hDC, R2_XORPEN); MoveToEx(hDC, first.x, first.y, NULL); LineTo(hDC, second.x, second.y); int len = (center - first.y) * 2; MoveToEx(hDC, first.x, first.y + len, NULL); LineTo(hDC, second.x, second.y + len); SetROP2(hDC, nDrawMode); SelectObject(hDC, hOldPen); Image->Bitmap->DeleteDC(hDC); Image->Repaint(); } //--------------------------------------------------------------------------- AnsiString __fastcall TYarnScanForm::FileNameExt(AnsiString fn) { PChar s; int FileNameLength, last1, last2, last3, last4; char FileIndex1, FileIndex2, FileIndex3, FileIndex4; //=============================================================== FileNameLength = fn.Length(); if(FileNameLength > 4){ last1 = FileNameLength-3; last2 = FileNameLength-2; last3 = FileNameLength-1; last4 = FileNameLength; FileIndex1 = '.'; FileIndex2 = 'j'; FileIndex3 = 'q'; FileIndex4 = 'd'; if((FileIndex1 == fn[last1])&&(FileIndex2 == fn[last2]) && (FileIndex3 == fn[last3])&&(FileIndex4 == fn[last4])){ s = "PASS"; }else s=NULL; }else s=NULL; //=============================================================== // char *s = AnsiStrScan(fn.c_str(), '.'); if (s==NULL) return fn + ".yan"; else return fn; } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::ScanYarnSave(AnsiString fn) { int x, y, xx, yy, size, delta, limit = spFilter->Value * 3; Byte r, g, b; double ravg, gavg, bavg; WORD *SP, *DP, value; FYarnData.Map = NULL; size = FYarnData.Length * FYarnData.Width; CalculateData(); if (!Image->Bitmap->StartScanLine()) goto fail; if ((FYarnData.Map = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WORD)*size)) == NULL) goto fail; RGBAverage(ravg, gavg, bavg); for (yy = 0, y = start.y; yy < FYarnData.Width; yy++, y++) { DP = (WORD *) FYarnData.Map + yy * FYarnData.Length; if (y < end.y) { SP = (WORD *) Image->Bitmap->GetScanLine(y); for (xx = 0, x = start.x; xx < FYarnData.Length; x++, xx++, DP++) { value = SP[x]; b = ((value & 0x1F) << 3) | ((value & 0x1F) >> 2); value >>= 5; g = ((value & 0x1F) << 3) | ((value & 0x1F) >> 2); value >>= 5; r = ((value & 0x1F) << 3) | ((value & 0x1F) >> 2); delta = (r-ravg)+(g-gavg)+(b-bavg); if (delta > -limit && delta < limit) *DP = 0x8000; else *DP = SP[x]; } } else { for (xx = 0; xx < FYarnData.Length; xx++, DP++) *DP = 0x8000; } } Image->Bitmap->StopScanLine(); FYarnData.DPI = 160; FYarnData.Ratio = YarnRatio; FYarnData.Dyed = true; FYarnData.Infor.Detail.TYC = 1; if (FYarnData.SaveToFile(fn) != EC_NONE) goto fail; HeapFree(GetProcessHeap(), 0, FYarnData.Map); FYarnData.Map = NULL; return; fail: if (FYarnData.Map) { HeapFree(GetProcessHeap(), 0, FYarnData.Map); FYarnData.Map = NULL; } Image->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::RGBAverage(double &r, double &g, double &b) { int red, green, blue, cnt, x; WORD *IP, value; IP = (WORD *) Image->Bitmap->GetScanLine(start.y); red = 0; green = 0; blue = 0; for (x = start.x, cnt = -1; x < end.x; x++, cnt++) { value = IP[x]; blue += ((value & 0x1F) << 3) | ((value & 0x1F) >> 2); value >>= 5; green += ((value & 0x1F) << 3) | ((value & 0x1F) >> 2); value >>= 5; red += ((value & 0x1F) << 3) | ((value & 0x1F) >> 2); } r = (double) red / cnt; g = (double) green / cnt; b = (double) blue / cnt; } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::CopyToTemp() { int x, y; WORD *DP, *SP, *T = NULL; if (TEMP) { TEMP->unlock(); delete TEMP; TEMP = NULL; } TEMP = new TPMemoryArea (Image->Bitmap->Width, Image->Bitmap->Height); if (TEMP == NULL) goto fail; T = TEMP->lock(); if (T == NULL) goto fail; if (Image->Bitmap->StartScanLine() == false) goto fail; for (y = 0; y < Image->Bitmap->Height; y++) { SP = (WORD *)Image->Bitmap->GetScanLine(y); DP = TEMP->pointer(0, y); memcpy(DP, SP, sizeof(WORD) * Image->Bitmap->Width); } Image->Bitmap->StopScanLine(); TEMP->unlock(); return; fail: Image->Bitmap->StopScanLine(); if (T) TEMP->unlock(); if (TEMP) { TEMP->unlock(); delete TEMP; TEMP = NULL; } EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::SaveAs() { AnsiString fn = "Noname.yan"; if (InputQuery(IDS_COMMON_SAVEAS, IDS_COMMON_INPUTNAME, fn)) { fn = FileNameExt(fn); if (!FileExists(fn)) { ScanYarnSave(fn); YarnTableForm->FileListBox->Update(); } else { EXCEPTION_MESSAGE_OK(EC_FILE_EXIST_ALREADY); SaveAs(); } } } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::CalculateData() { start.y = (center - (FYarnData.Width / 2)); end.x = start.x + FYarnData.Length; end.y = start.y + FYarnData.Width; if (start.x < 0) start.x = 0; if (start.y < 0) start.y = 0; if (end.x > Image->Bitmap->Width) end.x = Image->Bitmap->Width; if (end.y > Image->Bitmap->Height) end.y = Image->Bitmap->Height; } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::CloseFileForm() { sbTable->Down = false; } //--------------------------------------------------------------------------- void __fastcall TYarnScanForm::spFilterChange(TObject *Sender) { if (spFilter->Value < spFilter->MinValue) spFilter->Value = spFilter->MinValue; else if (spFilter->Value > spFilter->MaxValue) spFilter->Value = spFilter->MaxValue; } //---------------------------------------------------------------------------