//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "Fill_F.h" #include "FullView.h" #include "MainImage.h" #include "Rotation.h" #include "Palette.h" #include "PenManager.h" #include "TPSelectImage.h" #ifndef KNIT #include "CaptureEdit.h" #endif //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "Selector" #pragma link "TPSpin" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_FROMSINGLE StringTable[0] #define IDS_TOSINGLE StringTable[1] #define IDS_FROMMULTI StringTable[2] #define IDS_TONORMALPAT StringTable[3] #define IDS_TOMULTI StringTable[4] #define IDS_TOROTATEPAT StringTable[5] #define IDS_AIR StringTable[6] #define IDS_DENSITY StringTable[7] #define IDS_NOZZLE StringTable[8] #define IDS_DEGREE StringTable[9] #define IDS_BEFOREDEGREE StringTable[10] #define R 0 #define G 1 #define B 2 //--------------------------------------------------------------------------- TFillForm *FillForm; static COLORREF clFillData; //--------------------------------------------------------------------------- __fastcall TFillForm::TFillForm(TComponent* Owner) : TForm(Owner) { //=========================================== StringTable.Create(DirectoryBin, Language, "Fill"); SetSmallFont(Font); SetSmallFont(lDensity->Font); SetSmallFont(lNozzle->Font); SetSmallFont(Label1->Font); sbFSingle->Caption = IDS_FROMSINGLE; sbTSingle->Caption = IDS_TOSINGLE; sbFMulti->Caption = IDS_FROMMULTI; sbTNPattern->Caption = IDS_TONORMALPAT; sbTMulti->Caption = IDS_TOMULTI; sbTRPattern->Caption = IDS_TOROTATEPAT; rgAir->Caption = IDS_AIR; rgAir->Items->Strings[0] = IDS_COMMON_BUTTONNO; rgAir->Items->Strings[1] = IDS_COMMON_BUTTONYES; lDensity->Caption = IDS_DENSITY; lNozzle->Caption = IDS_NOZZLE; Label1->Caption = IDS_DEGREE; sbBeforeDeg->Hint = IDS_BEFOREDEGREE; sbNew->Hint = IDS_COMMON_NEW; sbAll->Hint = IDS_COMMON_ALL; sbBlock->Hint = IDS_COMMON_BLOCKCOLOR; sbDelete->Hint = IDS_COMMON_INSERTCOLOR; sbBefore->Hint = IDS_COMMON_BEFORECOLOR; lbType->Caption = IDS_COMMON_REPEAT; cbRepeatType->Items->Clear(); cbRepeatType->Items->Add(IDS_COMMON_NORMAL); cbRepeatType->Items->Add(IDS_COMMON_HDVER); cbRepeatType->Items->Add(IDS_COMMON_HDHOR); cbRepeatType->Text = IDS_COMMON_NORMAL; //=========================================== } //--------------------------------------------------------------------------- void __fastcall TFillForm::FormCreate(TObject *Sender) { // BeforeTheta = 0; rgAir->ItemIndex = 0; } //--------------------------------------------------------------------------- void __fastcall TFillForm::FunctionClick(TObject *Sender) { TSpeedButton *s; HDC vDC = NULL; int ec = EC_NONE; TPSelectImage *FillImage = MainImageForm->iSelectImage; TPItemImage *Image = MainImageForm->iMainImage; if (IsRDraw) Rotate_Rect(); FillImage->Visible = false; s = (TSpeedButton *)Sender; if (s == sbFSingle) { changefrom = TFF_SINGLE; changeto = TFT_NONE; if (Image->Bitmap->BitsPerPixel==8) { Selector->Initial(); sbTMulti->Enabled = false; } sbTSingle->Down = false; sbTMulti->Down = false; sbTNPattern->Down = false; sbTRPattern->Down = false; TSPanel->Visible = false; PatternPanel->Visible = false; MultiPanel->Visible = false; SSPanel->Visible = true; } else if (s == sbFMulti) { changefrom = TFF_MULTI; if (Image->Bitmap->BitsPerPixel==8) { Selector->Initial(); sbTMulti->Enabled = true; } changeto = TFT_NONE; sbTSingle->Down = false; sbTMulti->Down = false; sbTNPattern->Down = false; sbTRPattern->Down = false; TSPanel->Visible = false; PatternPanel->Visible = false; SSPanel->Visible = false; MultiPanel->Visible = true; } else if (s == sbTSingle) { changeto = TFT_SINGLE; PatternPanel->Visible = false; TSPanel->Visible = true; if (Image->Bitmap->BitsPerPixel==8) { FTarget = PaletteForm->DIB256Palette->ChoiceIndex; TSColor->Brush->Color = MainImageForm->Palette->Color[FTarget]; } else { FTarget = PaletteForm->DIB256Palette->GetFGCOLORREF(24); TSColor->Brush->Color = (TColor) FTarget; } } else if (s == sbTMulti) { changeto = TFT_MULTI; PatternPanel->Visible = false; TSPanel->Visible = true; if (Image->Bitmap->BitsPerPixel==8) { FTarget = PaletteForm->DIB256Palette->ChoiceIndex; TSColor->Brush->Color = MainImageForm->Palette->Color[FTarget]; if (mul_fill_sw == 1) mul_fill_sw = 0; if (mul_fill_sw == 0) { mul_fill_sw = 1; } memset(ctable, 0, sizeof(ctable)); colorptr = PaletteForm->DIB256Palette->UseColor; if (Selector->Count + colorptr > MAX_COLOR) { if (mul_fill_sw == 1) mul_fill_sw = 0; } } else { FTarget = PaletteForm->DIB256Palette->GetFGCOLORREF(24); TSColor->Brush->Color = (TColor) FTarget; } } else if ((s == sbTNPattern) || (s == sbTRPattern)) { if (s == sbTNPattern) { changeto = TFT_NORMALP; } else if (s == sbTRPattern) { changeto = TFT_ROTATEP; sw = false; } TSPanel->Visible = false; PatternPanel->Visible = true; FillImage->Width = 0; FillImage->Height = 0; FillImage->PositionX = 0; FillImage->PositionY = 0; cbPattern->Items->Clear(); if (Image->Bitmap->BitsPerPixel==8) { cbPattern->Enabled = false; MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (!(viewp->Create(window.size.x, window.size.y, Image->Bitmap->BitsPerPixel, rgb))) { ec = EC_MEMORY_LACK; goto fail; } viewp->CopyFromRect(Image->Bitmap, window.s.x, window.s.y, SRCCOPY); PatternImage->Picture->Bitmap->PixelFormat = pf8bit; PatternImage->Picture->Bitmap->Width = PatternImage->Width; PatternImage->Picture->Bitmap->Height = PatternImage->Height; SetDIBColorTable(PatternImage->Picture->Bitmap->Canvas->Handle, 0, 256, rgb); if ((vDC = viewp->CreateDC()) == NULL) {ec = EC_RESOURCE_LACK; goto fail;} SetStretchBltMode(vDC, COLORONCOLOR); StretchBlt(PatternImage->Picture->Bitmap->Canvas->Handle, 0, 0, PatternImage->Width, PatternImage->Height, vDC, 0, 0, window.size.x, window.size.y, SRCCOPY); viewp->DeleteDC(vDC); MakeFillImage(0); } else { #ifndef KNIT for (int i=0; iCount; i++) { cbPattern->Items->Add(Format("Capture %d", OPENARRAY(TVarRec, (i+1)))); } if (CaptureData->Count <= captureindex) captureindex = CaptureData->Count ? CaptureData->Count - 1 : 0; cbPattern->ItemIndex = captureindex; cbPatternChange(cbPattern); #endif } if(s == sbTNPattern) { //draw mousepoint center of the PatternImage MousePointPlace = 5; DrawMousePoint(MousePointPlace); } } if(s == sbTNPattern) { ClientHeight = 308; Parent->Height = ParentHeight+ClientHeight; RepeatView(); } else { ClientHeight = 252; Parent->Height = ParentHeight+ClientHeight; } if (s == sbTRPattern) { spDeg->Enabled = true; Label1->Enabled = true; sbBeforeDeg->Enabled = true; } else { spDeg->Enabled = false; Label1->Enabled = false; sbBeforeDeg->Enabled = false; } step = 0; rstep = 0; IsRDraw = false; PatternImage->Repaint(); MainImageForm->iMainImage->Repaint(); return; fail: if (viewp) viewp->Destroy(); EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TFillForm::cbPatternChange(TObject *Sender) { #ifndef KNIT HDC vDC = NULL; TCaptureData *cd = (TCaptureData *)CaptureData->Items[cbPattern->ItemIndex]; window.size.x = cd->Bitmap->Width; window.size.y = cd->Bitmap->Height; PatternImage->Picture->Bitmap->PixelFormat = pf24bit; PatternImage->Picture->Bitmap->Width = PatternImage->Width; PatternImage->Picture->Bitmap->Height = PatternImage->Height; if ((vDC = cd->Bitmap->CreateDC()) == NULL) goto fail; SetStretchBltMode(vDC, COLORONCOLOR); StretchBlt(PatternImage->Picture->Bitmap->Canvas->Handle, 0, 0, PatternImage->Width, PatternImage->Height, vDC, 0, 0, window.size.x, window.size.y, SRCCOPY); cd->Bitmap->DeleteDC(vDC); PatternImage->Repaint(); DrawMousePoint(MousePointPlace); /////////////////////////////////////////////////////////////// MakeFillImage(0); captureindex = cbPattern->ItemIndex; #endif return; fail: EXCEPTION_MESSAGE_OK(EC_RESOURCE_LACK); } //--------------------------------------------------------------------------- void __fastcall TFillForm::spEditClick(TObject *Sender) { TPSpinEdit *sp = (TPSpinEdit *)Sender; sp->SetFocus(); sp->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TFillForm::spDensityChange(TObject *Sender) { if (spDensity->Text.Length()>0) { density = spDensity->Value; } } //--------------------------------------------------------------------------- void __fastcall TFillForm::spNozzleChange(TObject *Sender) { if (spNozzle->Text.Length()>0) { nozzle = spNozzle->Value; } } //--------------------------------------------------------------------------- void __fastcall TFillForm::rgAirClick(TObject *Sender) { if (air) air = false; else air = true; lDensity->Enabled = air; lNozzle->Enabled = air; spDensity->Enabled = air; spNozzle->Enabled = air; } //--------------------------------------------------------------------------- void __fastcall TFillForm::sbNewClick(TObject *Sender) { TSpeedButton *s; TCursor cursor; s = (TSpeedButton *)Sender; if (s == sbNew) { Selector->Initial(); } else if (s == sbAll) { cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->WorkArea->Mask) MainImageForm->SearchWorkAreaColor(Selector->ChoiceColor); else MainImageForm->SearchWholeColor(Selector->ChoiceColor); Selector->Invalid(); Screen->Cursor = cursor; } else if (s == sbBlock) { if (sbBlock->Down) sbBlock->Hint = IDS_COMMON_ONECOLOR; else sbBlock->Hint = IDS_COMMON_BLOCKCOLOR; } else if (s == sbDelete) { if (sbDelete->Down) sbDelete->Hint = IDS_COMMON_DELETECOLOR; else sbDelete->Hint = IDS_COMMON_INSERTCOLOR; } } //--------------------------------------------------------------------------- void __fastcall TFillForm::sbBeforeClick(TObject *Sender) { Selector->LoadFromFile(DirectoryItem+"\\Fill.Ini", "Multi"); } //--------------------------------------------------------------------------- void __fastcall TFillForm::sbBeforeDegClick(TObject *Sender) { TPSelectImage *FillImage = MainImageForm->iSelectImage; TCursor oldcur = Screen->Cursor; Screen->Cursor = crHourGlass; FillImage->Visible = false; Theta = BeforeTheta; int deg = RadToDeg(Theta); spDeg->Value = deg; rstep = 2; if (patternfill_image_rotate()) { MakeFillImage(deg); } Screen->Cursor = oldcur; MainImageForm->iMainImage->Repaint(); } //--------------------------------------------------------------------------- COLORREF __fastcall TFillForm::SearchFillColor(TTexpiaBitmap *sBitmap) { int x, y, i, j; Byte *sl; Byte rgb[3][256]; int r, g, b; COLORREF crrf; memset(rgb, 0, 256 * 3); if (!(sBitmap->StartScanLine())) goto fail; for (y = 0; y < sBitmap->Height; y++) { sl = sBitmap->GetScanLine(y); for (x = 0; x < sBitmap->Width; x++, sl += 3) { GetPixel24(sl, crrf); r = crrf & 0x00000011; g = (crrf>>8) & 0x000011; b = (crrf>>16) & 0x0011; rgb[0][r] = 1; rgb[1][g] = 1; rgb[2][b] = 1; } } sBitmap->StopScanLine(); for (i = 0; i < 3; i++) { for (j = 0; j < 256; j++) { if (rgb[i][j] == 0) return 0x00000000 | (j<<(8*i)); } } return 0; fail: sBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return 0; } //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- void __fastcall TFillForm::Rotate_Rect(void) { MainImageForm->DrawLineLocate(Point(sx[0], sy[0]), Point(sx[2], sy[2])); MainImageForm->DrawLineLocate(Point(sx[2], sy[2]), Point(sx[3], sy[3])); MainImageForm->DrawLineLocate(Point(sx[3], sy[3]), Point(sx[1], sy[1])); MainImageForm->DrawLineLocate(Point(sx[1], sy[1]), Point(sx[0], sy[0])); MainImageForm->DrawLineLocate(Point(ArrowX[0], ArrowY[0]), Point(ArrowX[1], ArrowY[1])); MainImageForm->DrawLineLocate(Point(ArrowX[1], ArrowY[1]), Point(ArrowX[2], ArrowY[2])); MainImageForm->DrawLineLocate(Point(ArrowX[2], ArrowY[2]), Point(ArrowX[0], ArrowY[0])); MainImageForm->DrawLineLocate(Point(ArrowX[3], ArrowY[3]), Point(ArrowX[4], ArrowY[4])); } //--------------------------------------------------------------------------- void __fastcall TFillForm::Convert_CLTheta(int X, int Y) { int tx, ty; tx = rotatepoint.x - X; ty = rotatepoint.y - Y; if (ty == 0) { if (tx < 0) Theta = 3*M_PI /2.0; else Theta = M_PI / 2.0; } else { Theta = atan((Extended)tx / ty); if (ty < 0) Theta += M_PI; else if (tx < 0) Theta += 2 * M_PI; } } //--------------------------------------------------------------------------- void __fastcall TFillForm::Trans_Data(int X, int Y) { TRotation *Trans = NULL; int LX, LY; LX = window.size.x / 2; LY = window.size.y / 2; if ((Trans = new TRotation) == NULL) { EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return; } Convert_CLTheta(X, Y); Trans->translation(-rotatepoint.x, -rotatepoint.y); Trans->rotation(-Theta); Trans->convert(rotatepoint.x - LX, rotatepoint.y - LY, sx[0], sy[0]); sx[0] = sx[0] + rotatepoint.x; sy[0] = sy[0] + rotatepoint.y; Trans->convert(rotatepoint.x - LX, rotatepoint.y + LY, sx[1], sy[1]); sx[1] = sx[1] + rotatepoint.x; sy[1] = sy[1] + rotatepoint.y; Trans->convert(rotatepoint.x + LX, rotatepoint.y - LY, sx[2], sy[2]); sx[2] = sx[2] + rotatepoint.x; sy[2] = sy[2] + rotatepoint.y; Trans->convert(rotatepoint.x + LX, rotatepoint.y + LY, sx[3], sy[3]); sx[3] = sx[3] + rotatepoint.x; sy[3] = sy[3] + rotatepoint.y; Trans->convert(ArrowX[0], ArrowY[0]); ArrowX[0] = ArrowX[0] + rotatepoint.x; ArrowY[0] = ArrowY[0] + rotatepoint.y; Trans->convert(ArrowX[1], ArrowY[1]); ArrowX[1] = ArrowX[1] + rotatepoint.x; ArrowY[1] = ArrowY[1] + rotatepoint.y; Trans->convert(ArrowX[2], ArrowY[2]); ArrowX[2] = ArrowX[2] + rotatepoint.x; ArrowY[2] = ArrowY[2] + rotatepoint.y; Trans->convert(ArrowX[3], ArrowY[3]); ArrowX[3] = ArrowX[3] + rotatepoint.x; ArrowY[3] = ArrowY[3] + rotatepoint.y; max_x = sx[0]; min_x = max_x; max_y = sy[0]; min_y = max_y; delete Trans; } //--------------------------------------------------------------------------- bool __fastcall TFillForm::patternfill_image_rotate(int X, int Y) { TRotation *Trans = NULL; Extended dx, dy, px, py; int LX, LY, xx, yy, i, j; Byte *IP, *WP, *MP, *RP; TPItemImage *Image = MainImageForm->iMainImage; if (IsRDraw) Rotate_Rect(); // µ¹¾Æ°¡´Â »ç°¢ÇüÀ» ±×¸®´Â ÇÁ·Î½ÃÀú RotateArea = Point(max_x - min_x + 1, max_y - min_y + 1); if ((Trans = new TRotation) == NULL) goto fail; LX = window.size.x / 2; LY = window.size.y / 2; if (!sbBeforeDeg->Down) { if (!sw) Convert_CLTheta(X, Y); } Trans->translation(-rotatepoint.x, -rotatepoint.y); Trans->rotation(Theta); if (!(window.Bitmap->Create(RotateArea.x, RotateArea.y, 8, rgb))) goto fail; if (!(window.Mask->Create(RotateArea.x, RotateArea.y, 8, rgb))) goto fail; if (!(RotateBuf->Create(RotateArea.x, RotateArea.y, 8, rgb))) goto fail; if (!(Image->Bitmap->StartScanLine())) goto fail; if (!(window.Bitmap->StartScanLine())) goto fail; if (!(window.Mask->StartScanLine())) goto fail; if (!(RotateBuf->StartScanLine())) goto fail; for (i = min_y; i <= max_y; i++) { RP = RotateBuf->GetScanLine(i - min_y); WP = window.Bitmap->GetScanLine(i - min_y); MP = window.Mask->GetScanLine(i - min_y); for (j = min_x; j <= max_x; j++) { RP[j - (int)min_x] = 0xFF; Trans->convert(j, i, dx, dy); py = dy + LY; yy = floor(py); yy += window.s.y; if ((window.s.y <= yy) && (window.e.y > yy)) { px = dx + LX; xx = floor(px); xx += window.s.x; if ((window.s.x <= xx) && (window.e.x > xx)) { IP = Image->Bitmap->GetScanLine(yy); WP[j - (int)min_x] = IP[xx]; MP[j - (int)min_x] = 0x00; } else { WP[j - (int)min_x] = 0x00; MP[j - (int)min_x] = 0xFF; } } else { WP[j - (int)min_x] = 0x00; MP[j - (int)min_x] = 0xFF; } } RotateBuf->PutScanLine(i - min_y); window.Bitmap->PutScanLine(i - min_y); window.Mask->PutScanLine(i - min_y); } Image->Bitmap->StopScanLine(); window.Bitmap->StopScanLine(); window.Mask->StopScanLine(); RotateBuf->StopScanLine(); delete Trans; return true; fail: RotateBuf->Destroy(); window.Mask->Destroy(); window.Bitmap->Destroy(); if (Trans) delete Trans; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return false; } //--------------------------------------------------------------------------- void __fastcall TFillForm::multifill_color_making(TTexpiaBitmap *undo) { Byte c, uc; int gray[256]; int i, j; short lig, main_lig, sub_lig, diff_lig; double h, l, s, hue, sat; int frequency[256]; int max; TCursor OldCursor; RGBQUAD rgb[256]; Byte *UP; TPItemImage *Image = MainImageForm->iMainImage; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; MainImageForm->Palette->RGB2HLS(PaletteForm->DIB256Palette->ChoiceIndex, hue, l, sat); main_lig = l * 100; for (i = 0; i < MAX_COLOR; i++) { frequency[i] = 0; } for (i = 0; i < undo->Height; i++) { UP = undo->GetScanLine(i); for (j = 0; j < undo->Width; j++) { uc = UP[j]; if (Selector->Number[uc] < 255) frequency[uc]++; } } max = 0; j = 0; for (i = 0; i < MAX_COLOR; i++) { if (Selector->Number[i] < 255) { if (frequency[i] > max) { max = frequency[i]; j = i; } } } MainImageForm->Palette->RGB2HLS(j, h, l, s); sub_lig = l * 100; diff_lig = main_lig - sub_lig; memset(gray, 0, sizeof(gray)); for (i = 0; i < MAX_COLOR; i++) { if (Selector->Number[i] < 255) { MainImageForm->Palette->RGB2HLS(i, h, l, s); lig = l * 100; gray[i] = lig + diff_lig; if (gray[i] < 0) gray[i] = 0; else if (gray[i] > 100) gray[i] = 100; } } for (i = 0; i < MAX_COLOR; i++) { if ((Selector->Number[i] < 255) && ((gray[i] & 0x8000) == 0)) { if (ctable[i] == 0) { colorptr++; c = colorptr; if (c < MAX_COLOR) { if (c == PaletteForm->DIB256Palette->ChoiceIndex) { colorptr++; c = colorptr; } ctable[i] = c; gray[i] = gray[i] | 0x8000; } for (j = i + 1; j < MAX_COLOR; j++) { if (Selector->Number[j] < 255) { if ((gray[i] & 0x007F) == gray[j]) { if ((gray[j] & 0x8000) == 0) { ctable[j] = ctable[i]; } } } } } } } for (i = 0; i< MAX_COLOR; i++) { if (Selector->Number[i] < 255) { MainImageForm->Palette->HLS2RGB(ctable[i], hue, (gray[i] & 0x7FFF) / 100.0, sat); } } if (colorptr > PaletteForm->DIB256Palette->UseColor) PaletteForm->DIB256Palette->UseColor = colorptr; PaletteForm->DIB256Palette->SetPalette(MainImageForm->Palette); MainImageForm->Palette->ToRGBQUAD(rgb, 256); Image->Bitmap->PutColors(0, 256, rgb); Screen->Cursor = OldCursor; } //--------------------------------------------------------------------------- bool __fastcall TFillForm::fill_read_8(Byte *p, int x) { return Selector->Number[*(p+x)]<255; } //---------------------------------------------------------------------------- void __fastcall TFillForm::fill_save_8(Byte *p, int x) { *(p+x) = 255; } //--------------------------------------------------------------------------- void __fastcall TFillForm::normal_8(TFillData &fd, TFillFunc ff) { TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); for (int x=fd.rcBound.Left; xBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle1_8(TFillData &fd, TFillFunc ff) { TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); for (int x=fd.rcBound.Left; xBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle2_8(TFillData &fd, TFillFunc ff) { TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); if (y+1GetScanLineN(y+1, 1); fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); } for (int x=fd.rcBound.Left; xBitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle3_8(TFillData &fd, TFillFunc ff) { TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); if (y+1GetScanLineN(y+1, 1); fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); } for (int x=fd.rcBound.Left; xBitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle4_8(TFillData &fd, TFillFunc ff) { TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); if (y+1GetScanLineN(y+1, 1); fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); } if (y+2GetScanLineN(y+2, 2); fd.P[2] = Image->Bitmap->GetScanLineN(y+2, 2); } for (int x=fd.rcBound.Left; xBitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); if (y+2Bitmap->PutScanLineN(y+2, 2); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle5_8(TFillData &fd, TFillFunc ff) { TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); if (y+1GetScanLineN(y+1, 1); fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); } if (y+2GetScanLineN(y+2, 2); fd.P[2] = Image->Bitmap->GetScanLineN(y+2, 2); } for (int x=fd.rcBound.Left; xBitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y + 1, 1); if (y+2Bitmap->PutScanLineN(y + 2, 2); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::normalmask_8(TFillData &fd, TFillFunc ff) { Byte *P = 0; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); P = Image->Mask->GetScanLine(y); for (int x=fd.rcBound.Left; xMaskPixel; } } Image->Mask->PutScanLine(y); Image->Bitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask1_8(TFillData &fd, TFillFunc ff) { Byte *P = 0; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); P = Image->Mask->GetScanLine(y); for (int x=fd.rcBound.Left; xMaskPixel; } } } Image->Mask->PutScanLine(y); Image->Bitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask2_8(TFillData &fd, TFillFunc ff) { Byte *P[2]; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); P[0] = Image->Mask->GetScanLine(y); if (y+1GetScanLineN(y+1, 1); fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); P[1] = Image->Mask->GetScanLineN(y+1, 1); } for (int x=fd.rcBound.Left; xMaskPixel; if (x&1) { if ((x+1MaskPixel; } } else { if ((y+1MaskPixel; } } } } } Image->Mask->PutScanLine(y); if (y+1Mask->PutScanLineN(y+1, 1); Image->Bitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask3_8(TFillData &fd, TFillFunc ff) { Byte *P[2]; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); P[0] = Image->Mask->GetScanLine(y); if (y+1GetScanLineN(y+1, 1); fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); P[1] = Image->Mask->GetScanLineN(y+1, 1); } for (int x=fd.rcBound.Left; xMaskPixel; if ((x+1MaskPixel; } if ((y+1MaskPixel; } if ((x+1MaskPixel; } } } } Image->Mask->PutScanLine(y); if (y+1Mask->PutScanLineN(y+1, 1); Image->Bitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask4_8(TFillData &fd, TFillFunc ff) { Byte *P[3]; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); P[0] = Image->Mask->GetScanLine(y); if (y+1GetScanLineN(y+1, 1); fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); P[1] = Image->Mask->GetScanLineN(y+1, 1); } if (y+2GetScanLineN(y+2, 2); fd.P[2] = Image->Bitmap->GetScanLineN(y+2, 2); P[2] = Image->Mask->GetScanLineN(y+2, 2); } for (int x=fd.rcBound.Left; xMaskPixel; if (x&1) { if ((x+2MaskPixel; } if ((x+2MaskPixel; } } else { if ((y+2MaskPixel; } if ((y+2MaskPixel; } } if ((x+1MaskPixel; } if ((y+1MaskPixel; } if ((x+1MaskPixel; } } } } Image->Mask->PutScanLine(y); if (y+1Mask->PutScanLineN(y+1, 1); if (y+2Mask->PutScanLineN(y+2, 2); Image->Bitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); if (y+2Bitmap->PutScanLineN(y+2, 2); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask5_8(TFillData &fd, TFillFunc ff) { TPItemImage *Image = MainImageForm->iMainImage; Byte *P[3]; for (int y=fd.rcBound.Top; yGetScanLine(y); fd.P[0] = Image->Bitmap->GetScanLine(y); P[0] = Image->Mask->GetScanLine(y); if (y+1GetScanLineN(y+1, 1); fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); P[1] = Image->Mask->GetScanLineN(y+1, 1); } if (y+2GetScanLineN(y+2, 2); fd.P[2] = Image->Bitmap->GetScanLineN(y+2, 2); P[2] = Image->Mask->GetScanLineN(y+2, 2); } for (int x=fd.rcBound.Left; xMaskPixel; if ((x+2MaskPixel; } if ((x+2MaskPixel; } if ((x+2MaskPixel; } if ((y+2MaskPixel; } if ((y+2MaskPixel; } if ((x+1MaskPixel; } if ((y+1MaskPixel; } if ((x+1MaskPixel; } } } } Image->Mask->PutScanLine(y); if (y+1Mask->PutScanLineN(y + 1, 1); if (y+2Mask->PutScanLineN(y + 2, 2); Image->Bitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y + 1, 1); if (y+2Bitmap->PutScanLineN(y + 2, 2); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::funcToMulti_8(TFillData &fd, int n, int x, int y) { clFillData = ctable[fd.U[n][x]]; } //--------------------------------------------------------------------------- void __fastcall TFillForm::funcNormalPattern_8(TFillData &fd, int n, int x, int y) { Byte *SP; int px, py, r; int ex, ey; if (RepeatItem == 0) { if (y-fd.ey<0) { py = window.size.y+(y-fd.ey)%window.size.y; if (py>=window.size.y) py = 0; } else { py = (y-fd.ey)%window.size.y; } if (x-fd.ex<0) { px = window.size.x+(x-fd.ex)%window.size.x; if (px>=window.size.x) px = 0; } else { px = (x-fd.ex)%window.size.x; } } else if (RepeatItem == 1) { // Half Drop Vertical if (x-fd.ex<0) { px = window.size.x+(x-fd.ex)%window.size.x; if (px>=window.size.x) px = 0; r = ((fd.ex - x) / window.size.x) + 1; ey = fd.ey - r*half; } else { px = (x-fd.ex)%window.size.x; r = (x - fd.ex) / window.size.x; ey = fd.ey + r*half; } if (y-ey<0) { py = window.size.y+(y-ey)%window.size.y; if (py>=window.size.y) py = 0; } else { py = (y-ey)%window.size.y; } } else { // Half Drop Horizontal if (y-fd.ey<0) { py = window.size.y+(y-fd.ey)%window.size.y; if (py>=window.size.y) py = 0; r = ((fd.ey - y) / window.size.y) + 1; ex = fd.ex - r*half; } else { py = (y-fd.ey)%window.size.y; r = (y - fd.ey) / window.size.y; ex = fd.ex + r*half; } if (x-ex<0) { px = window.size.x+(x-ex)%window.size.x; if (px>=window.size.x) px = 0; } else { px = (x-ex)%window.size.x; } } SP = viewp->GetScanLine(py); clFillData = SP[px]; switch (FullViewForm->Super) { case sNormal: if (clFillData==fd.clBack) clFillData = fd.U[n][x]; break; case sGauze : case sOverlap : if (clFillData==fd.clBack || ((x+y)&1)) clFillData = fd.U[n][x]; break; } } //--------------------------------------------------------------------------- void __fastcall TFillForm::funcRotatePattern_8(TFillData &fd, int n, int x, int y) { int gap, gapx, gapy; Byte *SP; Extended xc, xs, yc, ys; if (RotateRepro==1) { /* ys = (fillstart.y-y)*fd.st; yc = (fillstart.y-y)*fd.ct; xs = (fillstart.x-x)*fd.st; xc = (fillstart.x-x)*fd.ct; gap = (int)(-yc+xs-fd.ey)%SetPattern.cx; if (gap<0) { gapy = SetPattern.cy+gap; } else { gapy = gap; } gap = (int)(-xc-ys-fd.ex)%SetPattern.cx; if (gap<0) { gapx = SetPattern.cx+gap; } else { gapx = gap; } SP = RotateBuf->GetScanLine(gapy); clFillData = SP[gapx]; */ } else { ys = (fillstart.y-y)*fd.st; yc = (fillstart.y-y)*fd.ct; xs = (fillstart.x-x)*fd.st; xc = (fillstart.x-x)*fd.ct; gap = (int)(-yc+xs-fd.ey)%window.size.y; if (gap<0) { gapy = window.size.y+gap; } else { gapy = gap; } gap = (int)(-xc-ys-fd.ex)%window.size.x; if (gap<0) { gapx = window.size.x+gap; } else { gapx = gap; } SP = fd.undo->GetScanLineN(window.s.y+gapy, 0); clFillData = SP[window.s.x+gapx]; } switch (FullViewForm->Super) { case sNormal: if (clFillData==fd.clBack) clFillData = fd.U[n][x]; break; case sGauze: case sOverlap: if ((clFillData==fd.clBack) || ((x+y)&1)) clFillData = fd.U[n][x]; break; } } //--------------------------------------------------------------------------- bool __fastcall TFillForm::fill_read_24(Byte *p, int x) { COLORREF c; p += 3*x; GetPixel24(p, c); return c==clFillFrom; } //--------------------------------------------------------------------------- #define GETMASK (*mp&mm) #define GETMASK0(n) (*mp[n]&mm) #define GETMASK1(n) (mm>1 ? *mp[n]&(mm>>1) : *(mp[n]+1)&0x80) #define GETMASK2(n) (mm>2 ? *mp[n]&(mm>>2) : *(mp[n]+1)&(mm<<6)) #define RESETMASK *mp &= ~mm #define RESETMASK0(n) *mp[n] &= ~mm #define RESETMASK1(n) if (mm>1) *mp[n] &= ~(mm>>1); else *(mp[n]+1) &= ~0x80 #define RESETMASK2(n) if (mm>2) *mp[n] &= ~(mm>>2); else *(mp[n]+1) &= ~(mm<<6) //--------------------------------------------------------------------------- void __fastcall TFillForm::normal_24(TFillData &fd, TFillFunc ff) { Byte *pp, *mp, mm; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yBitmap->GetScanLine(y); pp = fd.P[0]+3*fd.rcBound.Left; fd.U[0] = fd.undo->GetScanLine(y); fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp = fd.M[0]+(fd.ptMask.x>>3); mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; x>= 1; } Image->Bitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle1_24(TFillData &fd, TFillFunc ff) { Byte *pp, *up, *mp, mm; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yBitmap->GetScanLine(y); pp = fd.P[0]+3*fd.rcBound.Left; fd.U[0] = fd.undo->GetScanLine(y); up = fd.U[0]+3*fd.rcBound.Left; fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp = fd.M[0]+(fd.ptMask.x>>3); mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; x>= 1; } Image->Bitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle2_24(TFillData &fd, TFillFunc ff) { Byte *pp1, *pp2, *up1, *up2, *mp[2], mm, *p; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); up1 = fd.U[0]+3*fd.rcBound.Left; fd.P[0] = Image->Bitmap->GetScanLine(y); pp1 = fd.P[0]+3*fd.rcBound.Left; fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp[0] = fd.M[0]+(fd.ptMask.x>>3); if (y+1GetScanLineN(y+1, 1); up2 = fd.U[1]+3*fd.rcBound.Left; fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); pp2 = fd.P[1]+3*fd.rcBound.Left; fd.M[1] = fd.Mask->ScanLine(y+1-fd.ptMask.y); mp[1] = fd.M[1]+(fd.ptMask.x>>3); } mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; x>= 1; } Image->Bitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle3_24(TFillData &fd, TFillFunc ff) { Byte *pp1, *pp2, *up1, *up2, *mp[2], mm, *p; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); up1 = fd.U[0]+3*fd.rcBound.Left; fd.P[0] = Image->Bitmap->GetScanLine(y); pp1 = fd.P[0]+3*fd.rcBound.Left; fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp[0] = fd.M[0]+(fd.ptMask.x>>3); if (y+1GetScanLineN(y+1, 1); up2 = fd.U[1]+3*fd.rcBound.Left; fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); pp2 = fd.P[1]+3*fd.rcBound.Left; fd.M[1] = fd.Mask->ScanLine(y+1-fd.ptMask.y); mp[1] = fd.M[1]+(fd.ptMask.x>>3); } mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; x>= 1; } Image->Bitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle4_24(TFillData &fd, TFillFunc ff) { Byte *pp1, *pp2, *pp3, *up1, *up2, *up3, *mp[3], mm, *p; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); up1 = fd.U[0]+3*fd.rcBound.Left; fd.P[0] = Image->Bitmap->GetScanLine(y); pp1 = fd.P[0]+3*fd.rcBound.Left; fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp[0] = fd.M[0]+(fd.ptMask.x>>3); if (y+1GetScanLineN(y+1, 1); up2 = fd.U[1]+3*fd.rcBound.Left; fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); pp2 = fd.P[1]+3*fd.rcBound.Left; fd.M[1] = fd.Mask->ScanLine(y+1-fd.ptMask.y); mp[1] = fd.M[1]+(fd.ptMask.x>>3); } if (y+1GetScanLineN(y+2, 2); up3 = fd.U[2]+3*fd.rcBound.Left; fd.P[2] = Image->Bitmap->GetScanLineN(y+2, 2); pp3 = fd.P[2]+3*fd.rcBound.Left; fd.M[2] = fd.Mask->ScanLine(y+2-fd.ptMask.y); mp[2] = fd.M[2]+(fd.ptMask.x>>3); } mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; x>= 1; } Image->Bitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); } if (y+2Bitmap->PutScanLineN(y+2, 2); } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzle5_24(TFillData &fd, TFillFunc ff) { Byte *pp1, *pp2, *pp3, *up1, *up2, *up3, *mp[3], mm, *p; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yGetScanLine(y); up1 = fd.U[0]+3*fd.rcBound.Left; fd.P[0] = Image->Bitmap->GetScanLine(y); pp1 = fd.P[0]+3*fd.rcBound.Left; fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp[0] = fd.M[0]+(fd.ptMask.x>>3); if (y+1GetScanLineN(y+1, 1); up2 = fd.U[1]+3*fd.rcBound.Left; fd.P[1] = Image->Bitmap->GetScanLineN(y+1, 1); pp2 = fd.P[1]+3*fd.rcBound.Left; fd.M[1] = fd.Mask->ScanLine(y+1-fd.ptMask.y); mp[1] = fd.M[1]+(fd.ptMask.x>>3); } if (y+1GetScanLineN(y+2, 2); up3 = fd.U[2]+3*fd.rcBound.Left; fd.P[2] = Image->Bitmap->GetScanLineN(y+2, 2); pp3 = fd.P[2]+3*fd.rcBound.Left; fd.M[2] = fd.Mask->ScanLine(y+2-fd.ptMask.y); mp[2] = fd.M[2]+(fd.ptMask.x>>3); } mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; x>= 1; } Image->Bitmap->PutScanLine(y); if (y+1Bitmap->PutScanLineN(y+1, 1); } if (y+2Bitmap->PutScanLineN(y+2, 2); } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::normalmask_24(TFillData &fd, TFillFunc ff) { Byte *pp, pm, *mp, mm; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yMask->GetScanLine(y)+(fd.rcBound.Left>>3); fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp = fd.M[0]+(fd.ptMask.x>>3); pm = 0x80>>(fd.rcBound.Left&7); mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; xMaskPixel) *pp |= pm; else *pp &= ~pm; RESETMASK; } if (pm==1) { pp++; pm = 0x80; } else pm >>= 1; if (mm==1) { mp++; mm = 0x80; } else mm >>= 1; } Image->Mask->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask1_24(TFillData &fd, TFillFunc ff) { Byte *pp, pm, *mp, mm; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yMask->GetScanLine(y)+(fd.rcBound.Left>>3); fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp = fd.M[0]+(fd.ptMask.x>>3); pm = 0x80>>(fd.rcBound.Left&7); mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; xMaskPixel) *pp |= pm; else *pp &= ~pm; RESETMASK; } } if (pm==1) { pp++; pm = 0x80; } else pm >>= 1; if (mm==1) { mp++; mm = 0x80; } else mm >>= 1; } Image->Mask->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask2_24(TFillData &fd, TFillFunc ff) { Byte *pp[2], pm, *mp[2], mm; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yMask->GetScanLine(y)+(fd.rcBound.Left>>3); fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp[0] = fd.M[0]+(fd.ptMask.x>>3); if (y+1Mask->GetScanLineN(y+1, 1)+(fd.rcBound.Left>>3); fd.M[1] = fd.Mask->ScanLine(y+1-fd.ptMask.y); mp[1] = fd.M[1]+(fd.ptMask.x>>3); } pm = 0x80>>(fd.rcBound.Left&7); mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; xMaskPixel) *pp[0] |= pm; else *pp[0] &= ~pm; RESETMASK0(0); if (x&1) { if (x+11) { if (MainImageForm->MaskPixel) *pp[0] |= pm>>1; else *pp[0] &= ~(pm>>1); } else { if (MainImageForm->MaskPixel) *(pp[0]+1) |= 0x80; else *(pp[0]+1) &= 0x7F; } RESETMASK1(0); } } else { if (y+1MaskPixel) *pp[1] |= pm; else *pp[1] &= ~pm; RESETMASK0(1); } } } } if (pm==1) { pp[0]++; pp[1]++; pm = 0x80; } else pm >>= 1; if (mm==1) { mp[0]++; mp[1]++; mm = 0x80; } else mm >>= 1; } Image->Mask->PutScanLine(y); if (y+1Mask->PutScanLineN(y+1, 1); } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask3_24(TFillData &fd, TFillFunc ff) { Byte *pp[2], pm, *mp[2], mm; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yMask->GetScanLine(y)+(fd.rcBound.Left>>3); fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp[0] = fd.M[0]+(fd.ptMask.x>>3); if (y+1Mask->GetScanLineN(y+1, 1)+(fd.rcBound.Left>>3); fd.M[1] = fd.Mask->ScanLine(y+1-fd.ptMask.y); mp[1] = fd.M[1]+(fd.ptMask.x>>3); } pm = 0x80>>(fd.rcBound.Left&7); mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; xMaskPixel) *pp[0] |= pm; else *pp[0] &= ~pm; RESETMASK0(0); if (x+11) { if (MainImageForm->MaskPixel) *pp[0] |= pm>>1; else *pp[0] &= ~(pm>>1); } else { if (MainImageForm->MaskPixel) *(pp[0]+1) |= 0x80; else *(pp[0]+1) &= 0x7F; } RESETMASK1(0); } if (y+1MaskPixel) *pp[1] |= pm; else *pp[1] &= ~pm; RESETMASK0(1); } if (x+11) { if (MainImageForm->MaskPixel) *pp[1] |= pm>>1; else *pp[1] &= ~(pm>>1); } else { if (MainImageForm->MaskPixel) *(pp[1]+1) |= 0x80; else *(pp[1]+1) &= 0x7F; } RESETMASK1(1); } } } if (pm==1) { pp[0]++; pp[1]++; pm = 0x80; } else pm >>= 1; if (mm==1) { mp[0]++; mp[1]++; mm = 0x80; } else mm >>= 1; } Image->Mask->PutScanLine(y); if (y+1Mask->PutScanLineN(y+1, 1); } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask4_24(TFillData &fd, TFillFunc ff) { Byte *pp[3], pm, *mp[3], mm; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yMask->GetScanLine(y)+(fd.rcBound.Left>>3); fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp[0] = fd.M[0]+(fd.ptMask.x>>3); if (y+1Mask->GetScanLineN(y+1, 1)+(fd.rcBound.Left>>3); fd.M[1] = fd.Mask->ScanLine(y+1-fd.ptMask.y); mp[1] = fd.M[1]+(fd.ptMask.x>>3); } if (y+1Mask->GetScanLineN(y+2, 2)+(fd.rcBound.Left>>3); fd.M[2] = fd.Mask->ScanLine(y+2-fd.ptMask.y); mp[2] = fd.M[2]+(fd.ptMask.x>>3); } pm = 0x80>>(fd.rcBound.Left&7); mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; xMaskPixel) *pp[0] |= pm; else *pp[0] &= ~pm; RESETMASK0(0); if (x&1) { if (x+22) { if (MainImageForm->MaskPixel) *pp[0] |= pm>>2; else *pp[0] &= ~(pm>>2); } else { if (MainImageForm->MaskPixel) *(pp[0]+1) |= 0x80>>(2-pm); else *(pp[0]+1) &= ~(0x80>>(2-pm)); } RESETMASK2(0); } if (x+22) { if (MainImageForm->MaskPixel) *pp[1] |= pm>>2; else *pp[1] &= ~(pm>>2); } else { if (MainImageForm->MaskPixel) *(pp[1]+1) |= 0x80>>(2-pm); else *(pp[1]+1) &= ~(0x80>>(2-pm)); } RESETMASK2(1); } } else { if (y+2MaskPixel) *pp[2] |= pm; else *pp[2] &= ~pm; RESETMASK0(2); } if (y+21) { if (MainImageForm->MaskPixel) *pp[2] |= pm>>1; else *pp[2] &= ~(pm>>1); } else { if (MainImageForm->MaskPixel) *(pp[2]+1) |= 0x80; else *(pp[2]+1) &= 0x7F; } RESETMASK1(2); } } if (x+11) { if (MainImageForm->MaskPixel) *pp[0] |= pm>>1; else *pp[0] &= ~(pm>>1); } else { if (MainImageForm->MaskPixel) *(pp[0]+1) |= 0x80; else *(pp[0]+1) &= 0x7F; } RESETMASK1(0); } if (y+1MaskPixel) *pp[1] |= pm; else *pp[1] &= ~pm; RESETMASK0(1); } if (x+11) { if (MainImageForm->MaskPixel) *pp[1] |= pm>>1; else *pp[1] &= ~(pm>>1); } else { if (MainImageForm->MaskPixel) *(pp[1]+1) |= 0x80; else *(pp[1]+1) &= 0x7F; } RESETMASK1(1); } } } if (pm==1) { pp[0]++; pp[1]++; pp[2]++; pm = 0x80; } else pm >>= 1; if (mm==1) { mp[0]++; mp[1]++; mp[2]++; mm = 0x80; } else mm >>= 1; } Image->Mask->PutScanLine(y); if (y+1Mask->PutScanLineN(y+1, 1); } if (y+2Mask->PutScanLineN(y+2, 2); } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::nozzlemask5_24(TFillData &fd, TFillFunc ff) { Byte *pp[3], pm, *mp[3], mm; TPItemImage *Image = MainImageForm->iMainImage; for (int y=fd.rcBound.Top; yMask->GetScanLine(y)+(fd.rcBound.Left>>3); fd.M[0] = fd.Mask->ScanLine(y-fd.ptMask.y); mp[0] = fd.M[0]+(fd.ptMask.x>>3); if (y+1Mask->GetScanLineN(y+1, 1)+(fd.rcBound.Left>>3); fd.M[1] = fd.Mask->ScanLine(y+1-fd.ptMask.y); mp[1] = fd.M[1]+(fd.ptMask.x>>3); } if (y+1Mask->GetScanLineN(y+2, 2)+(fd.rcBound.Left>>3); fd.M[2] = fd.Mask->ScanLine(y+2-fd.ptMask.y); mp[2] = fd.M[2]+(fd.ptMask.x>>3); } pm = 0x80>>(fd.rcBound.Left&7); mm = 0x80>>(fd.ptMask.x&7); for (int x=fd.rcBound.Left; xMaskPixel) *pp[0] |= pm; else *pp[0] &= ~pm; RESETMASK0(0); if (x+22) { if (MainImageForm->MaskPixel) *pp[2] |= pm>>2; else *pp[2] &= ~(pm>>2); } else { if (MainImageForm->MaskPixel) *(pp[2]+1) |= 0x80>>(2-pm); else *(pp[2]+1) &= ~(0x80>>(2-pm)); } RESETMASK2(2); } if (x+22) { if (MainImageForm->MaskPixel) *pp[0] |= pm>>2; else *pp[0] &= ~(pm>>2); } else { if (MainImageForm->MaskPixel) *(pp[0]+1) |= 0x80>>(2-pm); else *(pp[0]+1) &= ~(0x80>>(2-pm)); } RESETMASK2(0); } if (x+22) { if (MainImageForm->MaskPixel) *pp[1] |= pm>>2; else *pp[1] &= ~(pm>>2); } else { if (MainImageForm->MaskPixel) *(pp[1]+1) |= 0x80>>(2-pm); else *(pp[1]+1) &= ~(0x80>>(2-pm)); } RESETMASK2(1); } if (y+2MaskPixel) *pp[2] |= pm; else *pp[2] &= ~pm; RESETMASK0(2); } if (y+21) { if (MainImageForm->MaskPixel) *pp[2] |= pm>>1; else *pp[2] &= ~(pm>>1); } else { if (MainImageForm->MaskPixel) *(pp[2]+1) |= 0x80; else *(pp[2]+1) &= 0x7F; } RESETMASK1(2); } if (x+11) { if (MainImageForm->MaskPixel) *pp[0] |= pm>>1; else *pp[0] &= ~(pm>>1); } else { if (MainImageForm->MaskPixel) *(pp[0]+1) |= 0x80; else *(pp[0]+1) &= 0x7F; } RESETMASK1(0); } if (y+1MaskPixel) *pp[1] |= pm; else *pp[1] &= ~pm; RESETMASK0(1); } if (x+11) { if (MainImageForm->MaskPixel) *pp[1] |= pm>>1; else *pp[1] &= ~(pm>>1); } else { if (MainImageForm->MaskPixel) *(pp[1]+1) |= 0x80; else *(pp[1]+1) &= 0x7F; } RESETMASK1(1); } } } if (pm==1) { pp[0]++; pp[1]++; pp[2]++; pm = 0x80; } else pm >>= 1; if (mm==1) { mp[0]++; mp[1]++; mp[2]++; mm = 0x80; } else mm >>= 1; } Image->Mask->PutScanLine(y); if (y+1Mask->PutScanLineN(y+1, 1); } if (y+2Mask->PutScanLineN(y+2, 2); } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::funcToMulti_24(TFillData &fd, int n, int x, int y) { COLORREF c; double h, l, s; Byte *pp = fd.U[n]+3*x; GetPixel24(pp, c); TColor2HLS((TColor) c, h, l, s); h += fd.h; if (h<0) h += 360.0; else if (h>=360.0) h -= 360.0; l += fd.l; if (l<0) l = 0.0; else if (l>=1.0) l = 1.0; s += fd.s; if (s<0) s = 0.0; else if (s>=1.0) s = 1.0; clFillData = HLS2TColor(h, l, s); } //--------------------------------------------------------------------------- void __fastcall TFillForm::funcNormalPattern_24(TFillData &fd, int n, int x, int y) { Byte *pp, *up; int px, py, ex, ey, r; if (RepeatItem == 0) { if (y-fd.ey<0) { py = window.size.y+(y-fd.ey)%window.size.y; if (py>=window.size.y) py = 0; } else { py = (y-fd.ey)%window.size.y; } if (x-fd.ex<0) { px = window.size.x+(x-fd.ex)%window.size.x; if (px>=window.size.x) px = 0; } else { px = (x-fd.ex)%window.size.x; } } else if (RepeatItem == 1) { // Half Drop Vertical if (x-fd.ex<0) { px = window.size.x+(x-fd.ex)%window.size.x; if (px>=window.size.x) px = 0; r = ((fd.ex - x) / window.size.x) + 1; ey = fd.ey - r*half; } else { px = (x-fd.ex)%window.size.x; r = (x - fd.ex) / window.size.x; ey = fd.ey + r*half; } if (y-ey<0) { py = window.size.y+(y-ey)%window.size.y; if (py>=window.size.y) py = 0; } else { py = (y-ey)%window.size.y; } } else { // Half Drop Horizontal if (y-fd.ey<0) { py = window.size.y+(y-fd.ey)%window.size.y; if (py>=window.size.y) py = 0; r = ((fd.ey - y) / window.size.y) + 1; ex = fd.ex - r*half; } else { py = (y-fd.ey)%window.size.y; r = (y - fd.ey) / window.size.y; ex = fd.ex + r*half; } if (x-ex<0) { px = window.size.x+(x-ex)%window.size.x; if (px>=window.size.x) px = 0; } else { px = (x-ex)%window.size.x; } } pp = fd.Pattern->GetScanLine(py); pp += 3*px; GetPixel24(pp, clFillData); switch (FullViewForm->Super) { case sNormal: if (clFillData==fd.clBack) { up = fd.U[n]+3*x; GetPixel24(up, clFillData); } break; case sGauze : case sOverlap : if ((clFillData==fd.clBack) || ((x+y)&1)) { up = fd.U[n]+3*x; GetPixel24(up, clFillData); } break; } } //--------------------------------------------------------------------------- void __fastcall TFillForm::funcRotatePattern_24(TFillData &fd, int n, int x, int y) { int gap, gapx, gapy; Byte *pp, *up; Extended xc, xs, yc, ys; if (RotateRepro==1) { /* ys = (fillstart.y-y)*fd.st; yc = (fillstart.y-y)*fd.ct; xs = (fillstart.x-x)*fd.st; xc = (fillstart.x-x)*fd.ct; gap = (int)(-yc+xs-fd.ey)%SetPattern.cy; if (gap<0) { gapy = SetPattern.cy+gap; } else { gapy = gap; } gap = (int)(-xc-ys-fd.ex)%SetPattern.cx; if (gap<0) { gapx = SetPattern.cx+gap; } else { gapx = gap; } SP = RotateBuf->GetScanLine(gapy); clFillData = SP[gapx]; */ } else { ys = (fillstart.y-y)*fd.st; yc = (fillstart.y-y)*fd.ct; xs = (fillstart.x-x)*fd.st; xc = (fillstart.x-x)*fd.ct; gap = (int)(-yc+xs-fd.ey)%window.size.y; if (gap<0) { gapy = window.size.y+gap; } else { gapy = gap; } gap = (int)(-xc-ys-fd.ex)%window.size.x; if (gap<0) { gapx = window.size.x+gap; } else { gapx = gap; } pp = fd.Pattern->GetScanLine(gapy)+3*gapx; GetPixel24(pp, clFillData); } switch (FullViewForm->Super) { case sNormal: if (clFillData==fd.clBack) { up = fd.U[n]+3*x; GetPixel24(up, clFillData); } break; case sGauze: case sOverlap: if ((clFillData==fd.clBack) || ((x+y)&1)) { up = fd.U[n]+3*x; GetPixel24(up, clFillData); } break; } } //--------------------------------------------------------------------------- void __fastcall TFillForm::Color_Fill(void) { TRect rect; TFillData FillData; TUndoData *ud = NULL; int ec = EC_NONE; TPItemImage *Image = MainImageForm->iMainImage; #ifndef KNIT TCaptureData *cd; #endif TCursor OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; FillData.Mask = NULL; FillData.size = Point(Image->Bitmap->Width, Image->Bitmap->Height); if (Image->Bitmap->BitsPerPixel==8) { FillData.clBack = (Byte) PaletteForm->DIB256Palette->GetBGCOLORREF(8); Image->Bitmap->FloodFill(fillstart, fill_read_8, fill_save_8, FillData.rcBound); if ((ud = Undo->Last) == NULL) { ec = EC_UNDO_NONE; goto fail; } FillData.undo = ud->Bitmap; if (!(Image->Bitmap->StartScanLineN(3))) { ec = EC_MEMORY_LACK; goto fail; } if (PenManagerForm->sbMask->Down) { if (!( Image->Mask->StartScanLineN(3))) { ec = EC_MEMORY_LACK; goto fail; } } if (!(FillData.undo->StartScanLineN(3))) { ec = EC_MEMORY_LACK; goto fail; } if (changeto==TFT_SINGLE) { clFillData = clFillTo; if (PenManagerForm->sbMask->Down) { if (air==false) normalmask_8(FillData, NULL); else { switch (nozzle) { case 1: nozzlemask1_8(FillData, NULL); break; case 2: nozzlemask2_8(FillData, NULL); break; case 3: nozzlemask3_8(FillData, NULL); break; case 4: nozzlemask4_8(FillData, NULL); break; case 5: nozzlemask5_8(FillData, NULL); break; } } } else { if (air==false) normal_8(FillData, NULL); else { switch (nozzle) { case 1: nozzle1_8(FillData, NULL); break; case 2: nozzle2_8(FillData, NULL); break; case 3: nozzle3_8(FillData, NULL); break; case 4: nozzle4_8(FillData, NULL); break; case 5: nozzle5_8(FillData, NULL); break; } } } } else if (changeto==TFT_MULTI) { Byte f = PaletteForm->DIB256Palette->ChoiceIndex; if ((mul_rgb.rgbRed!=MainImageForm->Palette->ColorData[f]->RGB.rgbRed) || (mul_rgb.rgbGreen!=MainImageForm->Palette->ColorData[f]->RGB.rgbGreen) || (mul_rgb.rgbBlue!=MainImageForm->Palette->ColorData[f]->RGB.rgbBlue)) { memset(ctable, 0, sizeof(ctable)); multifill_color_making(FillData.undo); mul_rgb = MainImageForm->Palette->ColorData[f]->RGB; } if (PenManagerForm->sbMask->Down) { if (air==false) normalmask_8(FillData, funcToMulti_8); else { switch (nozzle) { case 1: nozzlemask1_8(FillData, funcToMulti_8); break; case 2: nozzlemask2_8(FillData, funcToMulti_8); break; case 3: nozzlemask3_8(FillData, funcToMulti_8); break; case 4: nozzlemask4_8(FillData, funcToMulti_8); break; case 5: nozzlemask5_8(FillData, funcToMulti_8); break; } } } else { if (air==false) normal_8(FillData, funcToMulti_8); else { switch (nozzle) { case 1: nozzle1_8(FillData, funcToMulti_8); break; case 2: nozzle2_8(FillData, funcToMulti_8); break; case 3: nozzle3_8(FillData, funcToMulti_8); break; case 4: nozzle4_8(FillData, funcToMulti_8); break; case 5: nozzle5_8(FillData, funcToMulti_8); break; } } } } else if (changeto==TFT_NORMALP) { if (!(viewp->StartScanLine())) { ec = EC_MEMORY_LACK; goto fail; } FillData.ex = pfpos.x; FillData.ey = pfpos.y; half = spRange->Value; if (PenManagerForm->sbMask->Down) { if (air==false) normalmask_8(FillData, funcNormalPattern_8); else { switch (nozzle) { case 1: nozzlemask1_8(FillData, funcNormalPattern_8); break; case 2: nozzlemask2_8(FillData, funcNormalPattern_8); break; case 3: nozzlemask3_8(FillData, funcNormalPattern_8); break; case 4: nozzlemask4_8(FillData, funcNormalPattern_8); break; case 5: nozzlemask5_8(FillData, funcNormalPattern_8); break; } } } else { if (air==false) normal_8(FillData, funcNormalPattern_8); else { switch (nozzle) { case 1: nozzle1_8(FillData, funcNormalPattern_8); break; case 2: nozzle2_8(FillData, funcNormalPattern_8); break; case 3: nozzle3_8(FillData, funcNormalPattern_8); break; case 4: nozzle4_8(FillData, funcNormalPattern_8); break; case 5: nozzle5_8(FillData, funcNormalPattern_8); break; } } } viewp->StopScanLine(); } else if (changeto==TFT_ROTATEP) { if (!(RotateBuf->StartScanLine())) { ec = EC_MEMORY_LACK; goto fail; } if (RotateRepro == 1) { FillData.ex = SetPattern.cx/2.0; FillData.ey = SetPattern.cy/2.0; } else { FillData.ex = window.size.x/2.0; FillData.ey = window.size.y/2.0; } Theta = 2*M_PI-Theta; FillData.ct = cos(Theta); FillData.st = sin(Theta); if (PenManagerForm->sbMask->Down) { if (air==false) normalmask_8(FillData, funcRotatePattern_8); else { switch (nozzle) { case 1: nozzlemask1_8(FillData, funcRotatePattern_8); break; case 2: nozzlemask2_8(FillData, funcRotatePattern_8); break; case 3: nozzlemask3_8(FillData, funcRotatePattern_8); break; case 4: nozzlemask4_8(FillData, funcRotatePattern_8); break; case 5: nozzlemask5_8(FillData, funcRotatePattern_8); break; } } } else { if (air==false) normal_8(FillData, funcRotatePattern_8); else { switch (nozzle) { case 1: nozzle1_8(FillData, funcRotatePattern_8); break; case 2: nozzle2_8(FillData, funcRotatePattern_8); break; case 3: nozzle3_8(FillData, funcRotatePattern_8); break; case 4: nozzle4_8(FillData, funcRotatePattern_8); break; case 5: nozzle5_8(FillData, funcRotatePattern_8); break; } } } RotateBuf->StopScanLine(); } FillData.undo->StopScanLine(); if (PenManagerForm->sbMask->Down) Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); } else { #ifndef KNIT FillData.clBack = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if ((FillData.Mask = new TPBitmap) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if (MainImageForm->WorkArea->Mask && L_IsPtInBitmapRgn(Image->Bitmap->Handle, fillstart.y, fillstart.x)) { FillData.rcBound = MainImageForm->WorkArea->Range; if (!FillData.Mask->Create(FillData.rcBound.Right-FillData.rcBound.Left, FillData.rcBound.Bottom-FillData.rcBound.Top, 1)) { ec = EC_MEMORY_LACK; goto fail; } if ((FillData.Mask->Lock()) == NULL) { ec = EC_MEMORY_LACK; goto fail; } MainImageForm->WorkArea->Mask->SaveToMemory(FillData.Mask->ScanLine(), FillData.Mask->BytesPerLine); FillData.ptMask = Point(0, MainImageForm->WorkArea->Range.top); if ((ud = Undo->Last) == NULL) { ec = EC_UNDO_NONE; goto fail; } FillData.undo = ud->Bitmap; if (!(Image->Bitmap->StartScanLineN(3))) { ec = EC_MEMORY_LACK; goto fail; } if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLineN(3))) { ec = EC_MEMORY_LACK; goto fail; } } if (!(FillData.undo->StartScanLineN(3))) { ec = EC_MEMORY_LACK; goto fail; } if (changeto==TFT_SINGLE) { clFillData = clFillTo; if (PenManagerForm->sbMask->Down) { if (air==false) normalmask_24(FillData, NULL); else { switch (nozzle) { case 1: nozzlemask1_24(FillData, NULL); break; case 2: nozzlemask2_24(FillData, NULL); break; case 3: nozzlemask3_24(FillData, NULL); break; case 4: nozzlemask4_24(FillData, NULL); break; case 5: nozzlemask5_24(FillData, NULL); break; } } } else { if (air==false) normal_24(FillData, NULL); else { switch (nozzle) { case 1: nozzle1_24(FillData, NULL); break; case 2: nozzle2_24(FillData, NULL); break; case 3: nozzle3_24(FillData, NULL); break; case 4: nozzle4_24(FillData, NULL); break; case 5: nozzle5_24(FillData, NULL); break; } } } } else if (changeto==TFT_MULTI) { Byte *pp, *mp, mm; COLORREF c; double h, l, s, th = 0.0, tl = 0.0, ts = 0.0; int total = 0; for (int y=FillData.rcBound.Top; yBitmap->GetScanLine(y)+3*FillData.rcBound.Left; mp = FillData.Mask->ScanLine(y-FillData.rcBound.Top); mm = 0x80; for (int x=FillData.rcBound.Left; x1) mm >>= 1; else { mp++; mm = 0x80; } } } th /= total; tl /= total; ts /= total; c = PaletteForm->DIB256Palette->GetFGCOLORREF(24); TColor2HLS((TColor) c, h, l, s); FillData.h = h-th; FillData.l = l-tl; FillData.s = s-ts; if (air==false) normal_24(FillData, funcToMulti_24); else { switch (nozzle) { case 1: nozzle1_24(FillData, funcToMulti_24); break; case 2: nozzle2_24(FillData, funcToMulti_24); break; case 3: nozzle3_24(FillData, funcToMulti_24); break; case 4: nozzle4_24(FillData, funcToMulti_24); break; case 5: nozzle5_24(FillData, funcToMulti_24); break; } } } else if (changeto==TFT_NORMALP) { cd = (TCaptureData *)CaptureData->Items[cbPattern->ItemIndex]; FillData.Pattern = cd->Bitmap; if (!(FillData.Pattern->StartScanLine())) { ec = EC_MEMORY_LACK; goto fail; } FillData.ex = pfpos.x; FillData.ey = pfpos.y; half = spRange->Value; if (air==false) normal_24(FillData, funcNormalPattern_24); else { switch (nozzle) { case 1: nozzle1_24(FillData, funcNormalPattern_24); break; case 2: nozzle2_24(FillData, funcNormalPattern_24); break; case 3: nozzle3_24(FillData, funcNormalPattern_24); break; case 4: nozzle4_24(FillData, funcNormalPattern_24); break; case 5: nozzle5_24(FillData, funcNormalPattern_24); break; } } FillData.Pattern->StopScanLine(); } else if (changeto==TFT_ROTATEP) { cd = (TCaptureData *)CaptureData->Items[cbPattern->ItemIndex]; FillData.Pattern = cd->Bitmap; if (!(FillData.Pattern->StartScanLine())) { ec = EC_MEMORY_LACK; goto fail; } if (!(RotateBuf->StartScanLine())) { ec = EC_MEMORY_LACK; goto fail; } if (RotateRepro == 1) { FillData.ex = SetPattern.cx/2.0; FillData.ey = SetPattern.cy/2.0; } else { FillData.ex = window.size.x/2.0; FillData.ey = window.size.y/2.0; } Theta = 2*M_PI-Theta; FillData.ct = cos(Theta); FillData.st = sin(Theta); if (air==false) normal_24(FillData, funcRotatePattern_24); else { switch (nozzle) { case 1: nozzle1_24(FillData, funcRotatePattern_24); break; case 2: nozzle2_24(FillData, funcRotatePattern_24); break; case 3: nozzle3_24(FillData, funcRotatePattern_24); break; case 4: nozzle4_24(FillData, funcRotatePattern_24); break; case 5: nozzle5_24(FillData, funcRotatePattern_24); break; } } RotateBuf->StopScanLine(); FillData.Pattern->StopScanLine(); } FillData.undo->StopScanLine(); if (PenManagerForm->sbMask->Down) Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); } else { clFillFrom = Image->Bitmap->GetPixelColor(fillstart.x, fillstart.y); if (!Image->Bitmap->FloodFillMask(fillstart, fill_read_24, NULL, FillData.rcBound, FillData.Mask)) { ec = EC_MEMORY_LACK; goto fail; } FillData.ptMask = Point(FillData.rcBound.Left, 0); ud = Undo->Last; if (ud==NULL) { ec = EC_UNDO_NONE; goto fail; } FillData.undo = ud->Bitmap; if (!(Image->Bitmap->StartScanLineN(3))) { ec = EC_MEMORY_LACK; goto fail; } if (PenManagerForm->sbMask->Down) { if (!(Image->Mask->StartScanLineN(3))) { ec = EC_MEMORY_LACK; goto fail; } } if (!(FillData.undo->StartScanLineN(3))) { ec = EC_MEMORY_LACK; goto fail; } if ((FillData.Mask->Lock()) == NULL) { ec = EC_MEMORY_LACK; goto fail; } if (changeto==TFT_SINGLE) { clFillData = clFillTo; if (PenManagerForm->sbMask->Down) { if (air==false) normalmask_24(FillData, NULL); else { switch (nozzle) { case 1: nozzlemask1_24(FillData, NULL); break; case 2: nozzlemask2_24(FillData, NULL); break; case 3: nozzlemask3_24(FillData, NULL); break; case 4: nozzlemask4_24(FillData, NULL); break; case 5: nozzlemask5_24(FillData, NULL); break; } } } else { if (air==false) normal_24(FillData, NULL); else { switch (nozzle) { case 1: nozzle1_24(FillData, NULL); break; case 2: nozzle2_24(FillData, NULL); break; case 3: nozzle3_24(FillData, NULL); break; case 4: nozzle4_24(FillData, NULL); break; case 5: nozzle5_24(FillData, NULL); break; } } } } else if (changeto==TFT_NORMALP) { cd = (TCaptureData *)CaptureData->Items[cbPattern->ItemIndex]; FillData.Pattern = cd->Bitmap; if (!(FillData.Pattern->StartScanLine())) { ec = EC_MEMORY_LACK; goto fail; } FillData.ex = pfpos.x; FillData.ey = pfpos.y; half = spRange->Value; if (air==false) normal_24(FillData, funcNormalPattern_24); else { switch (nozzle) { case 1: nozzle1_24(FillData, funcNormalPattern_24); break; case 2: nozzle2_24(FillData, funcNormalPattern_24); break; case 3: nozzle3_24(FillData, funcNormalPattern_24); break; case 4: nozzle4_24(FillData, funcNormalPattern_24); break; case 5: nozzle5_24(FillData, funcNormalPattern_24); break; } } FillData.Pattern->StopScanLine(); } else if (changeto==TFT_ROTATEP) { cd = (TCaptureData *)CaptureData->Items[cbPattern->ItemIndex]; FillData.Pattern = cd->Bitmap; if (!(FillData.Pattern->StartScanLine())) { ec = EC_MEMORY_LACK; goto fail; } if (!(RotateBuf->StartScanLine())) { ec = EC_MEMORY_LACK; goto fail; } if (RotateRepro == 1) { FillData.ex = SetPattern.cx/2.0; FillData.ey = SetPattern.cy/2.0; } else { FillData.ex = window.size.x/2.0; FillData.ey = window.size.y/2.0; } Theta = 2*M_PI-Theta; FillData.ct = cos(Theta); FillData.st = sin(Theta); if (air==false) normal_24(FillData, funcRotatePattern_24); else { switch (nozzle) { case 1: nozzle1_24(FillData, funcRotatePattern_24); break; case 2: nozzle2_24(FillData, funcRotatePattern_24); break; case 3: nozzle3_24(FillData, funcRotatePattern_24); break; case 4: nozzle4_24(FillData, funcRotatePattern_24); break; case 5: nozzle5_24(FillData, funcRotatePattern_24); break; } } RotateBuf->StopScanLine(); FillData.Pattern->StopScanLine(); } FillData.undo->StopScanLine(); if (PenManagerForm->sbMask->Down) Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); } delete FillData.Mask; #endif } ::RepaintImage(); Screen->Cursor = OldCursor; return; fail: FillData.undo->StopScanLine(); if (PenManagerForm->sbMask->Down) Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); #ifndef KNIT if (FillData.Mask) { if (changeto==TFT_ROTATEP) { if( FillData.Pattern) FillData.Pattern->StopScanLine(); } FillData.Mask->Unlock(); delete FillData.Mask; } #endif Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TFillForm::CommonMouseMove(int X, int Y) { TPSelectImage *FillImage = MainImageForm->iSelectImage; TPItemImage *Image = MainImageForm->iMainImage; TPoint size = Point(FillImage->Bitmap->Width, FillImage->Bitmap->Height); if (X < 0) X = 0; else if (X > Image->Bitmap->Width - FillImage->Bitmap->Width) X = Image->Bitmap->Width - FillImage->Bitmap->Width; if (Y < 0) Y = 0; else if (Y > Image->Bitmap->Height - FillImage->Bitmap->Height) Y = Image->Bitmap->Height - FillImage->Bitmap->Height; if (FillImage->Width == MainImageForm->Panel->Width) { FillImage->Left = 0; FillImage->PositionX = Image->PositionX - X; } else { FillImage->Left = Image->BitmapToCanvasX(X); FillImage->PositionX = 0; } if (FillImage->Height == MainImageForm->Panel->Height) { FillImage->Top = 0; FillImage->PositionY = Image->PositionY - Y; } else { FillImage->Top = Image->BitmapToCanvasY(Y); FillImage->PositionY = 0; } if (FillImage->Width == MainImageForm->Panel->Width) { FillRect.Left = Image->PositionX - FillImage->PositionX; } else { FillRect.Left = Image->CanvasToBitmapX(FillImage->Left); } if (FillImage->Height == MainImageForm->Panel->Height) { FillRect.Top = Image->PositionY - FillImage->PositionY; } else { FillRect.Top = Image->CanvasToBitmapY(FillImage->Top); } FillRect.Right = FillRect.Left + size.x; FillRect.Bottom = FillRect.Top + size.y; if (FillImage->Bitmap->Width>MainImageForm->Panel->Width*FillImage->ZoomOut/FillImage->ZoomIn) { FillImage->Width = MainImageForm->Panel->Width; } else { FillImage->Width = FillImage->Bitmap->Width*FillImage->ZoomIn/FillImage->ZoomOut; } if (FillImage->Bitmap->Height>MainImageForm->Panel->Height*FillImage->ZoomOut/FillImage->ZoomIn) { FillImage->Height = MainImageForm->Panel->Height; } else { FillImage->Height = FillImage->Bitmap->Height*FillImage->ZoomIn/FillImage->ZoomOut; } HDC backDC = NULL, imageDC = NULL, maskDC = NULL, fillDC = NULL, bitmapDC = NULL; if ((backDC = window.Back->CreateDC()) == NULL) goto fail; if ((imageDC = Image->Bitmap->CreateDC()) == NULL) goto fail; BitBlt(backDC, 0, 0, size.x, size.y, imageDC, FillRect.Left, FillRect.Top, SRCCOPY); Image->Bitmap->DeleteDC(imageDC); imageDC = NULL; if ((maskDC = window.Mask->CreateDC()) == NULL) goto fail; BitBlt(backDC, 0, 0, size.x, size.y, maskDC, 0, 0, SRCAND); window.Mask->DeleteDC(maskDC); maskDC = NULL; if ((fillDC = FillImage->Bitmap->CreateDC()) == NULL) goto fail; if ((bitmapDC = window.Bitmap->CreateDC()) == NULL) goto fail; BitBlt(fillDC, 0, 0, size.x, size.y, bitmapDC, 0, 0, SRCCOPY); window.Bitmap->DeleteDC(bitmapDC); BitBlt(fillDC, 0, 0, size.x, size.y, backDC, 0, 0, SRCPAINT); FillImage->Bitmap->DeleteDC(fillDC); window.Back->DeleteDC(backDC); FillImage->Visible = true; #ifdef KNIT FillImage->SetPosition(0, 0); #endif MainImageForm->iMainImage->Update(); return; fail: if (backDC) { if (fillDC) { if (bitmapDC) window.Bitmap->DeleteDC(bitmapDC); FillImage->Bitmap->DeleteDC(fillDC); } if (maskDC) window.Mask->DeleteDC(maskDC); if (imageDC) Image->Bitmap->DeleteDC(imageDC); window.Back->DeleteDC(backDC); } EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TFillForm::MakeFillImage(int deg) { int i, j; Byte *IP, *WP, *MP, mm; COLORREF crrf, fcol, bgc; TPoint size; deg = 360 - deg; TTexpiaBitmap *TempBitmap = NULL; TPSelectImage *FillImage = MainImageForm->iSelectImage; TPItemImage *Image = MainImageForm->iMainImage; if ((TempBitmap = new TTexpiaBitmap) == NULL) goto fail; if (Image->Bitmap->BitsPerPixel == 8) { if (!(TempBitmap->Create(window.size.x, window.size.y, 8, rgb))) goto fail; TempBitmap->CopyFromRect(Image->Bitmap, window.s.x, window.s.y, SRCCOPY); TempBitmap->Rotate(deg*100, true, PALETTEINDEX(0)); size = Point(TempBitmap->Width, TempBitmap->Height); FillImage->Width = size.x; FillImage->Height = size.y; if (!(FillImage->Bitmap->Create(size.x, size.y, 8, rgb))) goto fail; FillImage->SetPosition(0, 0); if (!(window.Bitmap->Create(size.x, size.y, 8, rgb))) goto fail; if (!(window.Mask->Create(size.x, size.y, 8, rgb))) goto fail; if (!(window.Back->Create(size.x, size.y, 8, rgb))) goto fail; if (!(TempBitmap->StartScanLine())) goto fail; if (!(window.Bitmap->StartScanLine())) goto fail; if (!(window.Mask->StartScanLine())) goto fail; #if defined(TEXTILE) if (FullViewForm->Super == sOff) { for (i=0; iHeight; i++) { IP = TempBitmap->GetScanLine(i); WP = window.Bitmap->GetScanLine(i); MP = window.Mask->GetScanLine(i); for (j=0; jWidth; j++, IP++, WP++, MP++) { if (*IP) { if ((j+i) % 3) { *WP = *IP; *MP = 0; } else { *WP = 0; *MP = 0xFF; } } else { *WP = 0; *MP = 0xFF; } } window.Bitmap->PutScanLine(i); window.Mask->PutScanLine(i); } } else { for (i=0; iHeight; i++) { IP = TempBitmap->GetScanLine(i); WP = window.Bitmap->GetScanLine(i); MP = window.Mask->GetScanLine(i); for (j=0; jWidth; j++, IP++, WP++, MP++) { if (*IP > 1) { if ((j+i) % 3) { *WP = *IP; *MP = 0; } else { *WP = 0; *MP = 0xFF; } } else { *WP = 0; *MP = 0xFF; } } window.Bitmap->PutScanLine(i); window.Mask->PutScanLine(i); } } #elif defined (KNIT) if (FullViewForm->Super == sOff) { for (i=0; iHeight; i++) { IP = TempBitmap->GetScanLine(i); WP = window.Bitmap->GetScanLine(i); MP = window.Mask->GetScanLine(i); for (j=0; jWidth; j++, IP++, WP++, MP++) { *WP = *IP; if (*IP) *MP = 0; else *MP = 0xFF; } window.Mask->PutScanLine(i); window.Bitmap->PutScanLine(i); } } else { for (i=0; iHeight; i++) { IP = TempBitmap->GetScanLine(i); WP = window.Bitmap->GetScanLine(i); MP = window.Mask->GetScanLine(i); for (j=0; jWidth; j++, IP++, WP++, MP++) { if (*IP > 1) { *WP = *IP; *MP = 0; } else { *WP = 0; *MP = 0xFF; } } window.Mask->PutScanLine(i); window.Bitmap->PutScanLine(i); } } #endif window.Mask->StopScanLine(); window.Bitmap->StopScanLine(); TempBitmap->StopScanLine(); } else { #ifndef KNIT TCaptureData *cd = (TCaptureData *)CaptureData->Items[cbPattern->ItemIndex]; window.size.x = cd->Bitmap->Width; window.size.y = cd->Bitmap->Height; if (!(TempBitmap->Create(window.size.x, window.size.y, 24))) goto fail; TempBitmap->Copy(cd->Bitmap, SRCCOPY); crrf = SearchFillColor(TempBitmap); TempBitmap->Rotate(deg*100, true, crrf); size = Point(TempBitmap->Width, TempBitmap->Height); if (!(FillImage->Bitmap->Create(size.x, size.y, 24))) goto fail; if (!(window.Bitmap->Create(size.x, size.y, 24))) goto fail; if (!(window.Mask->Create(size.x, size.y, 1))) goto fail; if (!(window.Back->Create(size.x, size.y, 24))) goto fail; if (!(TempBitmap->StartScanLine())) goto fail; if (!(window.Bitmap->StartScanLine())) goto fail; if (!(window.Mask->StartScanLine())) goto fail; if (FullViewForm->Super == sOff) { for (int i=0; i < size.y; i++) { IP = TempBitmap->GetScanLine(i); WP = window.Bitmap->GetScanLine(i); MP = window.Mask->GetScanLine(i); *MP = 0; mm = 0x80; for (int j=0; j< size.x; j++, IP+=3, WP+=3) { GetPixel24(IP, fcol); if (fcol != crrf) { if ((j+i) % 3) { CopyPixel24(WP, IP); } else { SetPixel24(WP, 0); *MP |= mm; } } else { SetPixel24(WP, 0); *MP |= mm; } if (mm>1) mm >>= 1; else { MP++; *MP = 0; mm = 0x80; } } window.Bitmap->PutScanLine(i); window.Mask->PutScanLine(i); } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (int i=0; i < size.y; i++) { IP = TempBitmap->GetScanLine(i); WP = window.Bitmap->GetScanLine(i); MP = window.Mask->GetScanLine(i); *MP = 0; mm = 0x80; for (int j=0; j< size.x; j++, IP+=3, WP+=3) { GetPixel24(IP, fcol); if (fcol != crrf && fcol != bgc) { if ((j+i) % 3) { CopyPixel24(WP, IP); } else { SetPixel24(WP, 0); *MP |= mm; } } else { SetPixel24(WP, 0); *MP |= mm; } if (mm>1) mm >>= 1; else { MP++; *MP = 0; mm = 0x80; } } window.Bitmap->PutScanLine(i); window.Mask->PutScanLine(i); } } window.Mask->StopScanLine(); window.Bitmap->StopScanLine(); TempBitmap->StopScanLine(); #endif } delete TempBitmap; TempBitmap = NULL; return; fail: window.Mask->StopScanLine(); window.Bitmap->StopScanLine(); TempBitmap->StopScanLine(); if (TempBitmap) delete TempBitmap; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TFillForm::InitForm() { TPItemImage *Image = MainImageForm->iMainImage; ParentHeight = Parent->Height+20; ClientHeight = 252; Parent->Height = ParentHeight+ClientHeight; window.s.x = MainImageForm->WorkArea->Range.left; window.s.y = MainImageForm->WorkArea->Range.top; window.e.x = MainImageForm->WorkArea->Range.right; window.e.y = MainImageForm->WorkArea->Range.bottom; window.size.x = window.e.x - window.s.x; window.size.y = window.e.y - window.s.y; FillRect.Left = window.s.x; FillRect.Top = window.s.y; FillRect.Right = window.e.x; FillRect.Bottom = window.e.y; changefrom = TFF_SINGLE; changeto = TFT_SINGLE; air = rgAir->ItemIndex ? true : false; density = 3; nozzle = 1; spDensity->Value = density; spNozzle->Value = nozzle; if (Image->Bitmap->BitsPerPixel==8) { Selector->SetPalette(MainImageForm->Palette); FTarget = PaletteForm->DIB256Palette->ChoiceIndex; TSColor->Brush->Color = MainImageForm->Palette->Color[FTarget]; sbFMulti->Enabled = true; sbTNPattern->Enabled = MainImageForm->WorkArea->Mask!=NULL; sbTRPattern->Enabled = MainImageForm->WorkArea->Mask!=NULL; sbTMulti->Enabled = false; MainImageForm->Palette->ToRGBQUAD(rgb, 256); } else { #ifndef KNIT FTarget = PaletteForm->DIB256Palette->GetFGCOLORREF(24); TSColor->Brush->Color = (TColor) FTarget; sbFMulti->Enabled = false; sbTNPattern->Enabled = CaptureData->Count>0; sbTRPattern->Enabled = CaptureData->Count>0; sbTMulti->Enabled = MainImageForm->WorkArea->Mask!=NULL; #endif } sbFSingle->Down = true; sbTSingle->Down = true; MultiPanel->Visible = false; PatternPanel->Visible = false; SSPanel->Visible = true; TSPanel->Visible = true; viewp = NULL; RotateBuf = NULL; window.Bitmap = NULL; window.Back = NULL; window.Mask = NULL; #ifdef TPDEBUG if ((viewp = new TTexpiaBitmap) == NULL) SHOWDEBUG; if ((RotateBuf = new TTexpiaBitmap) == NULL) SHOWDEBUG; if ((window.Bitmap = new TTexpiaBitmap) == NULL) SHOWDEBUG; if ((window.Back = new TTexpiaBitmap) == NULL) SHOWDEBUG; if ((window.Mask = new TTexpiaBitmap) == NULL) SHOWDEBUG; #else viewp = new TTexpiaBitmap; RotateBuf = new TTexpiaBitmap; window.Bitmap = new TTexpiaBitmap; window.Back = new TTexpiaBitmap; window.Mask = new TTexpiaBitmap; #endif RepeatPanel->SendToBack(); RepeatItem = 0; sbBeforeDeg->Down = false; spDeg->Value = 0; captureindex = 0; IsRDraw = false; ReadIni(); } //--------------------------------------------------------------------------- void __fastcall TFillForm::ExitForm(void) { TPSelectImage *FillImage = MainImageForm->iSelectImage; TPItemImage *Image = MainImageForm->iMainImage; if (IsRDraw) Rotate_Rect(); IsRDraw = false; if (step == 1) MainImageForm->iMainImage->Repaint(); if (window.Back) { delete window.Back; window.Back = 0; } if (window.Mask) { delete window.Mask; window.Mask = 0; } if (window.Bitmap) { delete window.Bitmap; window.Bitmap = 0; } if (RotateBuf) { delete RotateBuf; RotateBuf = 0; } if (viewp) { delete viewp; viewp = 0; } FillImage->Bitmap->Destroy(); FillImage->Visible = false; if (Image->Bitmap->BitsPerPixel==8) { Selector->SaveToFile(DirectoryItem+"\\Fill.Ini", "Multi"); } WriteIni(); } //--------------------------------------------------------------------------- void __fastcall TFillForm::ReadIni() { TIniFile *FillIni = new TIniFile(DirectoryItem + "\\Fill.ini"); int TempDeg = FillIni->ReadInteger("Rotate", "BeforeDeg", 0); BeforeTheta = DegToRad((Extended) TempDeg); delete FillIni; } //--------------------------------------------------------------------------- void __fastcall TFillForm::WriteIni() { TIniFile *FillIni = new TIniFile(DirectoryItem + "\\Fill.ini"); int TempDeg = RadToDeg(BeforeTheta); FillIni->WriteInteger("Rotate", "BeforeDeg", TempDeg); delete FillIni; } //--------------------------------------------------------------------------- void __fastcall TFillForm::SelectColor(int Value) { TPItemImage *Image = MainImageForm->iMainImage; if (changeto == TFT_SINGLE || changeto == TFT_MULTI) { if (Image->Bitmap->BitsPerPixel==8) { FTarget = Value; TSColor->Brush->Color = MainImageForm->Palette->Color[FTarget]; } else { FTarget = MainImageForm->Palette->Color[Value]; TSColor->Brush->Color = (TColor) FTarget; } } else if (changeto == TFT_NONE) { if (changefrom == TFF_MULTI) { Selector->AddColor(Value); } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::FillMouseDown(TMouseButton Button, TShiftState Shift, int X, int Y) { RECT r; int ix, iy; TPItemImage *Image = MainImageForm->iMainImage; if (changeto == TFT_SINGLE) { if (changefrom == TFF_SINGLE) { if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { FTarget = Image->Bitmap->GetPixelColor(X, Y); if (Image->Bitmap->BitsPerPixel==8) { TSColor->Brush->Color = MainImageForm->Palette->Color[FTarget]; } else { TSColor->Brush->Color = (TColor) FTarget; } } else if (Button == mbLeft) { MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_PATTERN|UK_MASK : UK_PATTERN, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height)); FSource = Image->Bitmap->GetPixelColor(X, Y); if (Image->Bitmap->BitsPerPixel==8) { Selector->Initial(); Selector->AddColor(FSource); SSColor->Brush->Color = MainImageForm->Palette->Color[FSource]; } else { SSColor->Brush->Color =(TColor) FSource; } clFillTo = FTarget; fillstart = Point(X, Y); Color_Fill(); } } else if (changefrom == TFF_MULTI) { if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { FTarget = Image->Bitmap->GetPixelColor(X, Y); if (Image->Bitmap->BitsPerPixel==8) { TSColor->Brush->Color = MainImageForm->Palette->Color[FTarget]; } else { TSColor->Brush->Color = (TColor) FTarget; } } else if (Button == mbLeft) { MainImageForm->UndoSave(PenManagerForm->sbMask->Down ? UK_PATTERN|UK_MASK : UK_PATTERN, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height)); clFillTo = FTarget; fillstart = Point(X, Y); Color_Fill(); } } } else if (changeto == TFT_MULTI) { if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { FTarget = Image->Bitmap->GetPixelColor(X, Y); if (Image->Bitmap->BitsPerPixel==8) { TSColor->Brush->Color = MainImageForm->Palette->Color[FTarget]; } else { TSColor->Brush->Color = (TColor) FTarget; } } else if (Button == mbLeft) { MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height)); fillstart = Point(X, Y); Byte f = PaletteForm->DIB256Palette->ChoiceIndex; if ((Selector->Count + colorptr >= MAX_COLOR) && ((mul_rgb.rgbRed != MainImageForm->Palette->ColorData[f]->RGB.rgbRed) || (mul_rgb.rgbGreen != MainImageForm->Palette->ColorData[f]->RGB.rgbGreen) || (mul_rgb.rgbBlue != MainImageForm->Palette->ColorData[f]->RGB.rgbBlue))) { if (mul_fill_sw == 1) mul_fill_sw = 0; EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); } else { Color_Fill(); } } } else if (changeto == TFT_NORMALP) { if (Button == mbLeft) { if (changefrom == TFF_SINGLE) { MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height)); FSource = Image->Bitmap->GetPixelColor(X, Y); if (Image->Bitmap->BitsPerPixel==8) { Selector->Initial(); Selector->AddColor(FSource); SSColor->Brush->Color = MainImageForm->Palette->Color[FSource]; } else { SSColor->Brush->Color = (TColor) FSource; } switch (MousePointPlace) { case 1: pfpos = Point(X, Y); break; case 2: pfpos = Point(X - window.size.x, Y); break; case 3: pfpos = Point(X, Y - window.size.y); break; case 4: pfpos = Point(X - window.size.x, Y - window.size.y); break; case 5: pfpos = Point(X - window.size.x / 2.0, Y - window.size.y / 2.0); } fillstart = Point(X, Y); Color_Fill(); } else if (changefrom == TFF_MULTI) { MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height)); switch (MousePointPlace) { case 1: pfpos = Point(X, Y); break; case 2: pfpos = Point(X - window.size.x, Y); break; case 3: pfpos = Point(X, Y - window.size.y); break; case 4: pfpos = Point(X - window.size.x, Y - window.size.y); break; case 5: pfpos = Point(X - window.size.x / 2.0, Y - window.size.y / 2.0); } fillstart = Point(X, Y); Color_Fill(); } } } else if (changeto == TFT_ROTATEP) { rstep = 2; if (patternfill_image_rotate(X, Y)) { MakeFillImage(RadToDeg(Theta)); } } else if (changeto == TFT_NONE) { if (changefrom == TFF_MULTI) { if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { if (sbBlock->Down) { if (sbDelete->Down) { Selector->DeleteColor(Image->Bitmap->GetPixelColor(X, Y)); } else { Selector->AddColor(Image->Bitmap->GetPixelColor(X, Y)); } } else { if (step == 0) { Temp.left = X; Temp.top = Y; Temp.bottom = Temp.top; Temp.right = Temp.left; MainImageForm->DrawRectangleLocate(Temp); IsDraw = true; step = 1; } else if (step == 1) { Temp.right = X; Temp.bottom = Y; MainImageForm->DrawRectangleLocate(Temp); if (Temp.left > Temp.right) { r.left = Temp.right; r.right = Temp.left; } else { r.left = Temp.left; r.right = Temp.right; } if (Temp.top > Temp.bottom) { r.top = Temp.bottom; r.bottom = Temp.top; } else { r.top = Temp.top; r.bottom = Temp.bottom; } if (sbDelete->Down) { for (iy = r.top; iy < r.bottom; iy++) { for (ix = r.left; ix < r.right; ix++) { Selector->DeleteColor(Image->Bitmap->GetPixelColor(ix, iy)); } } } else { for (iy = r.top; iy < r.bottom; iy++) { for (ix = r.left; ix < r.right; ix++) { Selector->AddColor(Image->Bitmap->GetPixelColor(ix, iy)); } } } IsDraw = false; step = 0; } } } } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::FillMouseMove(int X, int Y) { int ArrowXX, ArrowYY, i; TPSelectImage *FillImage = MainImageForm->iSelectImage; TPItemImage *Image = MainImageForm->iMainImage; if (changeto == TFT_NONE) { if (changefrom == TFF_MULTI) { if (step == 1) { if (IsDraw) MainImageForm->DrawRectangleLocate(Temp); Temp.right = X; Temp.bottom = Y; MainImageForm->DrawRectangleLocate(Temp); IsDraw = true; } } } else if (changeto == TFT_NORMALP) { switch(MousePointPlace) { case 1: //Left-Top // X = X; // Y = Y; break; case 2: //Right-Top X = X - FillImage->Bitmap->Width ; // Y = Y; break; case 3: //Left-Bottom // X = X ; Y = Y - FillImage->Bitmap->Height ; break; case 4: //Right-Bottom X = X - FillImage->Bitmap->Width ; Y = Y - FillImage->Bitmap->Height ; break; default: //Center and Initialization X = X - (FillImage->Bitmap->Width / 2.0); Y = Y - (FillImage->Bitmap->Height / 2.0); break; } CommonMouseMove(X, Y); } else if((changeto == TFT_ROTATEP) && (rstep == 0)){ X = X - (FillImage->Bitmap->Width / 2.0); Y = Y - (FillImage->Bitmap->Height / 2.0); CommonMouseMove(X, Y); } else if (changeto == TFT_ROTATEP) { if (rstep == 1) { if (IsRDraw) Rotate_Rect(); // µ¹¾Æ°¡´Â »ç°¢ÇüÀ» ±×¸®´Â ÇÁ·Î½ÃÀú.. ArrowXX = window.size.x / 6; ArrowYY = window.size.y / 6; ArrowX[0] = rotatepoint.x; ArrowX[1] = rotatepoint.x - ArrowXX * 2; ArrowX[2] = rotatepoint.x + ArrowXX * 2; ArrowX[3] = rotatepoint.x; ArrowX[4] = rotatepoint.x; ArrowY[0] = rotatepoint.y - ArrowYY * 2; ArrowY[1] = rotatepoint.y; ArrowY[2] = rotatepoint.y; ArrowY[3] = rotatepoint.y + ArrowYY * 2; ArrowY[4] = rotatepoint.y; Trans_Data(X, Y); for (i = 0; i <= 3; i++) { if (min_x >= sx[i]) min_x = sx[i]; else if (max_x <= sx[i]) max_x = sx[i]; if (min_y >= sy[i]) min_y = sy[i]; else if (max_y <= sy[i]) max_y = sy[i]; } Rotate_Rect(); // µ¹¾Æ°¡´Â »ç°¢ÇüÀ» ±×¸®´Â ÇÁ·Î½ÃÀú.. IsRDraw = true; spDeg->Value = RadToDeg(Theta); } else if (rstep == 2){ X = X-FillImage->Bitmap->Width/2.0; Y = Y-FillImage->Bitmap->Height/2.0; CommonMouseMove(X, Y); } } else { if (changefrom == TFF_SINGLE) { FSource = Image->Bitmap->GetPixelColor(X, Y); if (Image->Bitmap->BitsPerPixel==8) { SSColor->Brush->Color = MainImageForm->Palette->Color[FSource]; } else { SSColor->Brush->Color = (TColor) FSource; } } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::FillPaint() { IsDraw = false; IsRDraw = false; } //--------------------------------------------------------------------------- void __fastcall TFillForm::FillImageMouseDown(TMouseButton Button, TShiftState Shift, int X, int Y) { TPSelectImage *FillImage = MainImageForm->iSelectImage; TPItemImage *Image = MainImageForm->iMainImage; if (changeto == TFT_NORMALP) { FillMouseDown(Button, Shift, Image->CanvasToBitmapX(FillImage->Left + X), Image->CanvasToBitmapY(FillImage->Top + Y)); } else if (changeto == TFT_ROTATEP) { if (rstep == 0) { rotatepoint.x = Image->CanvasToBitmapX(FillImage->Left + X); rotatepoint.y = Image->CanvasToBitmapY(FillImage->Top + Y); FillImage->Visible = false; rstep = 1; } else if (rstep == 2) { if (Button == mbLeft) { BeforeTheta = Theta; if (sbBeforeDeg->Down) sbBeforeDeg->Down = false; rotatepoint.x = Image->CanvasToBitmapX(FillImage->Left + X); rotatepoint.y = Image->CanvasToBitmapY(FillImage->Top + Y); if (changefrom == TFF_SINGLE) { MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height)); FSource = Image->Bitmap->GetPixelColor(rotatepoint.x, rotatepoint.y); if (Image->Bitmap->BitsPerPixel==8) { Selector->Initial(); Selector->AddColor(FSource); SSColor->Brush->Color = MainImageForm->Palette->Color[FSource]; } else { SSColor->Brush->Color = (TColor) FSource; } pfpos = Point(rotatepoint.x - window.size.x / 2.0, rotatepoint.y - window.size.y / 2.0); fillstart = Point(rotatepoint.x, rotatepoint.y); Color_Fill(); } else if (changefrom == TFF_MULTI) { MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height)); switch (MousePointPlace) { case 1: pfpos = Point(rotatepoint.x, rotatepoint.y); break; case 2: pfpos = Point(rotatepoint.x - window.size.x, rotatepoint.y); break; case 3: pfpos = Point(rotatepoint.x, rotatepoint.y - window.size.y); break; case 4: pfpos = Point(rotatepoint.x - window.size.x, rotatepoint.y - window.size.y); break; case 5: pfpos = Point(rotatepoint.x - window.size.x / 2.0, rotatepoint.y - window.size.y / 2.0); } fillstart = Point(rotatepoint.x, rotatepoint.y); Color_Fill(); } FunctionClick(sbTRPattern); } } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::FillImageMouseMove(int X, int Y) { TPSelectImage *FillImage = MainImageForm->iSelectImage; TPItemImage *Image = MainImageForm->iMainImage; if (changeto == TFT_NORMALP) { switch(MousePointPlace) { case 1: //Left-Top X = Image->CanvasToBitmapX(FillImage->Left + X); Y = Image->CanvasToBitmapY(FillImage->Top + Y); break; case 2: //Right-Top X = Image->CanvasToBitmapX(FillImage->Left + X) - FillImage->Bitmap->Width ; Y = Image->CanvasToBitmapY(FillImage->Top + Y); break; case 3: //Left-Bottom X = Image->CanvasToBitmapX(FillImage->Left + X); Y = Image->CanvasToBitmapY(FillImage->Top + Y) - FillImage->Bitmap->Height; break; case 4: //Right-Bottom X = Image->CanvasToBitmapX(FillImage->Left + X) - FillImage->Bitmap->Width; Y = Image->CanvasToBitmapY(FillImage->Top + Y) - FillImage->Bitmap->Height; break; default: //Center and Initialization X = Image->CanvasToBitmapX(FillImage->Left + X) - FillImage->Bitmap->Width / 2.0; Y = Image->CanvasToBitmapY(FillImage->Top + Y) - FillImage->Bitmap->Height / 2.0; break; } CommonMouseMove(X, Y); } else if((changeto == TFT_ROTATEP) && (rstep == 0 || rstep == 2)) { X = Image->CanvasToBitmapX(FillImage->Left + X) - FillImage->Bitmap->Width / 2.0; Y = Image->CanvasToBitmapY(FillImage->Top + Y) - FillImage->Bitmap->Height / 2.0; CommonMouseMove(X, Y); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::iMainImageChange(void) { TPSelectImage *FillImage = MainImageForm->iSelectImage; FillImage->Width = 0; FillImage->Height = 0; if (IsDraw) IsDraw = false; if (IsRDraw) IsRDraw = false; } //--------------------------------------------------------------------------- void __fastcall TFillForm::PatternImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int w, h; w = PatternImage->Width; h = PatternImage->Height; if (changeto == TFT_NORMALP) { if((X>w/4 && X<=3*w/4) && (Y>h/4 && Y<= 3*h/4)) { //Center MousePointPlace = 5; } else if((X>=0 && X<=w/2) && (Y>=0 && Y<=h/2)) { //Left-Top MousePointPlace = 1; } else if((X>=w/2 && X<=w) && (Y>=0 && Y<=h/2)) { //Right-Top MousePointPlace = 2; } else if((X>=0 && X<=w/2) && (Y>h/2 && Y<= h)) { //Left-Bottom MousePointPlace = 3; } else if((X>w/2 && X<=w) && (Y>h/2 && Y<=h)) { //Right-Bottom MousePointPlace = 4; } DrawMousePoint(MousePointPlace); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::DrawMousePoint(int mousepoint) { int width, height; HDC vDC = NULL; TRect canvas; width = PatternImage->Width; height = PatternImage->Height; TPItemImage *Image = MainImageForm->iMainImage; if (Image->Bitmap->BitsPerPixel==8) { // Delete before MouseMark canvas = Rect(0,0,width,height); PatternImage->Canvas->Brush->Color = clWhite; PatternImage->Canvas->FillRect(canvas); } else { #ifndef KNIT TCaptureData *cd = (TCaptureData *)CaptureData->Items[cbPattern->ItemIndex]; window.size.x = cd->Bitmap->Width; window.size.y = cd->Bitmap->Height; if ((vDC = cd->Bitmap->CreateDC()) == NULL) goto fail; SetStretchBltMode(vDC, COLORONCOLOR); StretchBlt(PatternImage->Canvas->Handle, 0, 0,width, height, vDC, 0, 0, window.size.x, window.size.y, SRCCOPY); cd->Bitmap->DeleteDC(vDC); #endif } PatternImage->Repaint(); //Create New MouseMark PatternImage->Canvas->Pen->Color = clBlack; PatternImage->Canvas->Pen->Width = 3; PatternImage->Canvas->Brush->Color = clWhite; switch(mousepoint) { case 1: PatternImage->Canvas->Rectangle(3, 3, 13, 13); break; case 2: PatternImage->Canvas->Rectangle(width-13, 3, width-3, 13); break; case 3: PatternImage->Canvas->Rectangle(3, height-13, 13, height-3); break; case 4: PatternImage->Canvas->Rectangle(width-13, height-13, width-3, height-3); break; default: PatternImage->Canvas->Rectangle(width/2-5, height/2-5, width/2+5, height/2+5); break; } return; fail: EXCEPTION_MESSAGE_OK(EC_RESOURCE_LACK); } //--------------------------------------------------------------------------- void __fastcall TFillForm::cbRepeatTypeChange(TObject *Sender) { RepeatItem = cbRepeatType->ItemIndex; if (cbRepeatType->ItemIndex == 1) spRange->Value = window.size.y/2; else if (cbRepeatType->ItemIndex == 2) spRange->Value = window.size.x/2; RepeatView(); } //--------------------------------------------------------------------------- void __fastcall TFillForm::RepeatView() { if (RepeatItem == 0) { lbWH->Caption = IDS_COMMON_WIDTH; lbRange->Caption = Format("(0 - %d)", OPENARRAY(TVarRec, ((int)window.size.x))); lbWH->Enabled = false; lbRange->Enabled = false; spRange->Enabled = false; } else if (RepeatItem == 1) { lbWH->Enabled = true; lbRange->Enabled = true; spRange->Enabled = true; lbWH->Caption = IDS_COMMON_HEIGHT; lbRange->Caption = Format("(0 - %d)", OPENARRAY(TVarRec, ((int)window.size.y))); } else { lbWH->Enabled = true; lbRange->Enabled = true; spRange->Enabled = true; lbWH->Caption = IDS_COMMON_WIDTH; lbRange->Caption = Format("(0 - %d)", OPENARRAY(TVarRec, ((int)window.size.x))); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::spRangeChange(TObject *Sender) { if (spRange->Text.Length()>0) { if (spRange->Value < 0) spRange->Value = 0; if(RepeatItem == 1) { if (spRange->Value > window.size.y) spRange->Value = window.size.y; } if(RepeatItem == 2) { if (spRange->Value > window.size.x) spRange->Value = window.size.x; } } } //--------------------------------------------------------------------------- void __fastcall TFillForm::spDegChange(TObject *Sender) { if (spDeg->Text.Length() > 0) { Theta = DegToRad(spDeg->Value); } } //--------------------------------------------------------------------------- void __fastcall TFillForm::spDegKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == VK_RETURN) { TPSelectImage *FillImage = MainImageForm->iSelectImage; int deg; TCursor oldcur = Screen->Cursor; Screen->Cursor = crHourGlass; FillImage->Visible = false; deg = spDeg->Value; Theta = DegToRad(deg); rstep = 2; sw = true; if (patternfill_image_rotate()) { MakeFillImage(deg); } Screen->Cursor = oldcur; sw = false; MainImageForm->iMainImage->Repaint(); } } //---------------------------------------------------------------------------