//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "PenManager.h" #include "MainImage.h" #include "Palette.h" #include "Undo.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "Selector" #pragma link "TPStretchImage" #pragma link "TPSpin" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_PEN StringTable[0] #define IDS_TOSQUARE StringTable[1] #define IDS_AIRBRUSH StringTable[2] #define IDS_CRAYON StringTable[3] #define IDS_WATERPEN StringTable[4] #define IDS_SCRAPEPEN StringTable[5] #define IDS_MASKPEN StringTable[6] #define IDS_PRESSURE StringTable[7] #define IDS_ANTIALISE StringTable[8] #define IDS_SINGLE StringTable[9] #define IDS_MULTI StringTable[10] #define IDS_PATTERN StringTable[11] #define IDS_DENSITY StringTable[12] #define IDS_NOZZLE StringTable[13] #define IDS_SPREAD StringTable[14] #define IDS_COLOR StringTable[15] #define IDS_BRISTLES StringTable[16] #define IDS_SCALE StringTable[17] #define IDS_SPREADGRADE StringTable[18] #define IDS_SELECTCOLOR StringTable[19] #define IDS_SELECT StringTable[20] #define IDS_SIMPLE StringTable[21] #define IDS_SPATTER StringTable[22] #define IDS_PURE StringTable[23] #define IDS_DIFFUSE StringTable[24] #define IDS_EFFECT StringTable[25] #define IDS_SHAPE StringTable[26] #define IDS_DRAWINGPEN StringTable[27] #define IDS_INSIDEDENSITY StringTable[28] #define IDS_OUTSIDEDENSITY StringTable[29] #define IDS_CLEAR StringTable[30] #define IDS_DELETE StringTable[31] #define IDS_FILL StringTable[32] #define IDS_TOCIRCLE StringTable[33] #define IDS_REVERSAL StringTable[34] //--------------------------------------------------------------------------- TPenManagerForm *PenManagerForm; //--------------------------------------------------------------------------- __fastcall TPenManagerForm::TPenManagerForm(TComponent* Owner) : TForm(Owner) { StringTable.Create(DirectoryBin, Language, "PenManager"); SetFont(); //======================================== Caption = IDS_PEN; PenWidthPanel->Hint = AnsiString(IDS_COMMON_CIRCLE)+ " : " + AnsiString(IDS_TOSQUARE); sbNormal->Hint = IDS_COMMON_NORMAL; sbAirBrush->Hint = IDS_AIRBRUSH; sbCrayon->Hint = IDS_CRAYON; sbWater->Hint = IDS_WATERPEN; sbScratch->Hint = IDS_SCRAPEPEN; sbMask->Hint = IDS_MASKPEN; cbPressure->Caption = IDS_PRESSURE; sbSingle->Caption = IDS_SINGLE; sbMulti->Caption = IDS_MULTI; sbPattern->Caption = IDS_PATTERN; Label44->Caption = IDS_DENSITY; Label45->Caption = IDS_NOZZLE; Label19->Caption = IDS_DENSITY; Label20->Caption = IDS_NOZZLE; Label17->Caption = IDS_DENSITY; Label43->Caption = IDS_NOZZLE; lSpread->Caption = AnsiString(IDS_SPREAD) + " : " + AnsiString(IDS_COMMON_OFF); lColor->Caption = AnsiString(IDS_COLOR) + " : " + AnsiString(IDS_COMMON_BUTTONNO); lBristles->Caption = IDS_BRISTLES; lScale->Caption = IDS_SCALE; 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; spreadgrade->Caption = IDS_SPREADGRADE; // spreadgrade->Caption = AnsiString(IDS_SPREADGRADE) + "(2 - 70)"; sbWSimple->Hint = IDS_WATERPEN; sbWSpatter->Hint = IDS_SPATTER; sbClear->Caption = IDS_CLEAR; sbWPure->Hint = IDS_PURE; sbWDiffuse->Hint = IDS_DIFFUSE; Label5->Caption = IDS_DENSITY; Label1->Caption = IDS_COLOR; Label2->Caption = IDS_EFFECT; lSelectDraw->Caption = IDS_SELECTCOLOR; lDensity->Caption = IDS_DENSITY; chDelete->Caption = IDS_DELETE; chFill->Caption = IDS_FILL; chReversal->Caption = IDS_REVERSAL; //======================================== #if defined(KNIT) sePenSize->Value = 1; #endif } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormClick(TObject *Sender) { Show(); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormClose(TObject *Sender, TCloseAction &Action) { Visible = false; if (FOnUpdateMenu) FOnUpdateMenu(Sender); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormCreate(TObject *Sender) { Random = new TTexpiaRandom(360); Pen = new TPenObject(Tablet); if (!Tablet->IsDevice()) Tablet->MaxNPressure = 1; if (!Tablet->MaxNPressure) Tablet->MaxNPressure = 1; MenuSW = false; Type = PT_NORMAL; AirType = PAT_SINGLE; BtnClick = false; ClientHeight = ExitPanel->Top + ExitPanel->Height; FHeight = ClientHeight; EtcPanel->Left = 0; EtcPanel->Top = ClientHeight; ScrapePanel->Left = 0; ScrapePanel->Top = EtcSubPanel->Height; DensPanel->Left = 0; DensPanel->Top = EtcSubPanel->Height; ColorPanel->Left = DensPanel->Width; ColorPanel->Top = EtcSubPanel->Height; SpreadPanel->Left = 0; SpreadPanel->Top = EtcSubPanel->Height; WaterPanel->Left = 0; WaterPanel->Top = ClientHeight; AirPanel->Left = 0; AirPanel->Top = ClientHeight; SinglePanel->Left = 0; SinglePanel->Top = ButtonPanel->Height + 5; MultiPanel->Left = 0; MultiPanel->Top = ButtonPanel->Height + 5; PatternPanel->Left = 0; PatternPanel->Top = ButtonPanel->Height + 5; MaskPanel->Left = 0; MaskPanel->Top = ClientHeight; Pen->BasicThick = 12; sbNormal->Down = true; shNormal->Pen->Color = clRed; shNormal->Brush->Color = clRed; shAirBrush->Pen->Color = clBlack; shAirBrush->Brush->Color = clBlack; shCrayon->Pen->Color = clBlack; shCrayon->Brush->Color = clBlack; shWater->Pen->Color = clBlack; shWater->Brush->Color = clBlack; shScratch->Pen->Color = clBlack; shScratch->Brush->Color = clBlack; shMask->Pen->Color = clBlack; shMask->Brush->Color = clBlack; btnUp->Visible = false; btnDown->Visible = true; AirColorList = new TList; ColorPanel->Visible = false; SpreadPanel->Visible = false; ScrapePanel->Visible = false; DensPanel->Visible = false; EtcPanel->Height = EtcPanel->Height - SpreadPanel->Height; spread_pos = 0; spread_grade = 2; interval = 70; aspread = false; acolor = 0; Pen->Brush = 0; cr[PWT_SIMPLE] = 0.14; or[PWT_SIMPLE] = 0.90; cr[PWT_SPATTER] = 0.93; or[PWT_SPATTER] = 0.00; cr[PWT_PURE] = 0.66; or[PWT_PURE] = 0.93; cr[PWT_DIFFUSE] = 0.30; or[PWT_DIFFUSE] = 0.08; WaterType = PWT_SIMPLE; FPointPressurePen = point_pressure_pen; init_pressure_pen(); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormDestroy(TObject *Sender) { if (AirColorList) delete AirColorList; if (Pen) delete Pen; if (Random) delete Random; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::AirFunctionClick(TObject *Sender) { TSpeedButton *s; RGBQUAD rgb[256]; int Tx, Ty; TPItemImage *Image = MainImageForm->iMainImage; s = (TSpeedButton *)Sender; if (s == sbSingle) { AirType = PAT_SINGLE; MultiPanel->Visible = false; PatternPanel->Visible = false; SinglePanel->Visible = true; AirPanel->Height = SinglePanel->Top + SinglePanel->Height; ClientHeight = AirPanel->Top + AirPanel->Height; } else if (s == sbMulti) { AirType = PAT_MULTI; SinglePanel->Visible = false; PatternPanel->Visible = false; MultiPanel->Visible = true; AirPanel->Height = MultiPanel->Top + MultiPanel->Height; ClientHeight = AirPanel->Top + AirPanel->Height; // seMDotNum->SetFocus(); } else if (s == sbPattern) { AirType = PAT_PATTERN; SinglePanel->Visible = false; MultiPanel->Visible = false; PatternPanel->Visible = true; AirPanel->Height = PatternPanel->Top + PatternPanel->Height; ClientHeight = AirPanel->Top + AirPanel->Height; Tx = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; Ty = MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top; Screen->Cursor = crHourGlass; if (Image->Bitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (!(Image1->Bitmap->Create(Tx, Ty, 8, rgb))) goto fail; } else { if (!(Image1->Bitmap->Create(Tx, Ty, 24))) goto fail; } Image1->Bitmap->CopyFromRect(Image->Bitmap, MainImageForm->WorkArea->Range.left, MainImageForm->WorkArea->Range.top, SRCCOPY); Screen->Cursor = crDefault; } return; fail: Screen->Cursor = crDefault; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::shAirColorMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TShape *sh = (TShape *)Sender; if (AirColorList->Count >= sh->Tag + 1) { DeleteAirColorPalette(sh->Tag); ChangeAirColorPalette(sh->Tag, true); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::EditKeyPress(TObject *Sender, char &Key) { TEdit *s; s = (TEdit *)Sender; if (Key == 13) { if (s == eScale) { } else if (s == eGrade) { spread_grade = StrToInt(s->Text); } else { if (AirColorList->Count >= s->Tag + 1) { InputPercent(Sender); } } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::EditMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TEdit *s; s = (TEdit *)Sender; if (s == eGrade) { if (spread_sw[4] == 0) { s->SetFocus(); s->SelectAll(); } } else if (s == eScale) { s->SetFocus(); s->SelectAll(); } else { if (AirColorList->Count >= s->Tag + 1) { s->SetFocus(); s->SelectAll(); } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::seDensityChange(TObject *Sender) { if (seDensity->Text.Length()>0) { density = seDensity->Value; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::ShapeMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { TShape *s; s = (TShape *)Sender; if (s == shFirst) { shFirst->Pen->Color = clRed; shSecond->Pen->Color = clBlack; spread_pos = 0; } else if (s == shSecond) { shFirst->Pen->Color = clBlack; shSecond->Pen->Color = clRed; spread_pos = 1; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::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 TPenManagerForm::LabelClick(TObject *Sender) { TLabel *s; s = (TLabel *)Sender; // sePenSize->SetFocus(); if (s == lSpread) { if (aspread == false) { aspread = true; lSpread->Caption = AnsiString(IDS_SPREAD) + " : " + AnsiString(IDS_COMMON_ON); SpreadPanel->Visible = true; EtcPanel->Height = SpreadPanel->Top + SpreadPanel->Height; if (spread_grade < 2) spread_grade = 2; if (252 - MainImageForm->Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - MainImageForm->Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); if (ScrapePanel->Visible || DensPanel->Visible || ColorPanel->Visible) { SpreadPanel->Top = DensPanel->Top + DensPanel->Height; } EtcPanel->Height = SpreadPanel->Top + SpreadPanel->Height; } else if (aspread == true) { aspread = false; lSpread->Caption = AnsiString(IDS_SPREAD) + " : " + AnsiString(IDS_COMMON_OFF); SpreadPanel->Visible = false; if (ScrapePanel->Visible || DensPanel->Visible || ColorPanel->Visible) { EtcPanel->Height = DensPanel->Top + DensPanel->Height; } else { EtcPanel->Height = EtcSubPanel->Height; } } } else if (s == lColor) { if (acolor == 0) { Selector->Invalid(); acolor = 1; lColor->Caption = AnsiString(IDS_COLOR) + " : " + AnsiString(IDS_SELECT); ColorPanel->Visible = true; EtcPanel->Height = ColorPanel->Top + ColorPanel->Height; if (SpreadPanel->Visible) { SpreadPanel->Top = ColorPanel->Top + ColorPanel->Height; EtcPanel->Height += SpreadPanel->Height; } } else if (acolor == 1) { acolor = 2; lColor->Caption = AnsiString(IDS_COLOR) + " : " + AnsiString(IDS_COMMON_BUTTONYES); } else if (acolor == 2) { acolor = 0; lColor->Caption = AnsiString(IDS_COLOR) + " : " + AnsiString(IDS_COMMON_BUTTONNO); ColorPanel->Visible = false; Selector->SaveToFile(DirectoryItem+"\\Pen.Ini", "Color"); if (SpreadPanel->Visible) { if (ScrapePanel->Visible || DensPanel->Visible) { SpreadPanel->Top = DensPanel->Top + DensPanel->Height; } else { SpreadPanel->Top = EtcSubPanel->Top + EtcSubPanel->Height; } EtcPanel->Height = SpreadPanel->Top + SpreadPanel->Height; } else { if (ScrapePanel->Visible || DensPanel->Visible) { EtcPanel->Height = DensPanel->Top + DensPanel->Height; } else { EtcPanel->Height = EtcSubPanel->Height; } } } MainImageForm->PenChange(); } else if (s == lSelectDraw) { if (spread_sw[4] == 0) { lSelectDraw->Caption = IDS_DRAWINGPEN; spread_sw[4] = 1; if (MainImageForm->iMainImage->Bitmap->BitsPerPixel==8) make_spread(); Selector->Invalid(); } else if (spread_sw[4] == 1) { lSelectDraw->Caption = IDS_SELECTCOLOR; spread_sw[4] = 0; } } ClientHeight = EtcPanel->Top + EtcPanel->Height; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::MenuClick(TObject *Sender) { int h; #ifdef KNIT if ((MenuSW == false) && (DesignMode == D_YARN)) { #else if (MenuSW == false) { #endif Show(); MenuSW = true; switch (Type) { case PT_NORMAL : if (spread_grade < 2) spread_grade = 2; if (252 - MainImageForm->Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - MainImageForm->Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); EtcPanel->Visible = true; EtcPanel->BringToFront(); h = EtcSubPanel->Height; if (SpreadPanel->Visible) { if (ColorPanel->Visible) { h += ColorPanel->Height; } SpreadPanel->Top = h; h += SpreadPanel->Height; } else { if (ColorPanel->Visible) { h += ColorPanel->Height; } } EtcPanel->Height = h; ClientHeight = EtcPanel->Top + h; break; case PT_AIR : AirSelectColor->Brush->Color = MainImageForm->Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; if (MainImageForm->WorkArea->Mask) { sbPattern->Enabled = true; } else { sbPattern->Enabled = false; } AirPanel->Visible = true; AirPanel->BringToFront(); if (AirType == PAT_SINGLE) { MultiPanel->Visible = false; PatternPanel->Visible = false; SinglePanel->Visible = true; AirPanel->Height = SinglePanel->Top + SinglePanel->Height; } else if (AirType == PAT_MULTI) { SinglePanel->Visible = false; PatternPanel->Visible = false; MultiPanel->Visible = true; AirPanel->Height = MultiPanel->Top + MultiPanel->Height; } else if (AirType == PAT_PATTERN) { SinglePanel->Visible = false; MultiPanel->Visible = false; PatternPanel->Visible = true; AirPanel->Height = PatternPanel->Top + PatternPanel->Height; } ClientHeight = AirPanel->Top + AirPanel->Height; break; case PT_WATER : WaterPanel->Visible = true; WaterPanel->BringToFront(); InitWaterPanel(WaterType); ClientHeight = WaterPanel->Top + WaterPanel->Height; break; case PT_MASK : MaskPanel->Height = 50; MaskPanel->Visible = true; MaskPanel->BringToFront(); ClientHeight = MaskPanel->Top + MaskPanel->Height; break; default : if (spread_grade < 2) spread_grade = 2; if (252 - MainImageForm->Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - MainImageForm->Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); EtcPanel->Visible = true; EtcPanel->BringToFront(); h = EtcSubPanel->Height; if (SpreadPanel->Visible) { if (ScrapePanel->Visible || DensPanel->Visible || ColorPanel->Visible) { h += ColorPanel->Height; } SpreadPanel->Top = h; h += SpreadPanel->Height; } else { if (ScrapePanel->Visible || DensPanel->Visible || ColorPanel->Visible) { h += ColorPanel->Height; } } EtcPanel->Height = h; ClientHeight = EtcPanel->Top + h; } btnUp->Visible = true; btnDown->Visible = false; } else if (MenuSW == true) { MenuSW = false; ClientHeight = FHeight; btnUp->Visible = false; btnDown->Visible = true; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::PenWidthPanelClick(TObject *Sender) { MainImageForm->iMainImageChange(); if (Pen->Shape == 1) { PenShape->Shape = stCircle; sePenSize->Value = Pen->BasicThick; Pen->Shape = 0; PenWidthPanel->Hint = AnsiString(IDS_COMMON_CIRCLE) + " : " + AnsiString(IDS_TOSQUARE); } else if (Pen->Shape == 0) { PenShape->Shape = stRectangle; sePenSize->Value = Pen->BasicThick; Pen->Shape = 1; PenWidthPanel->Hint = AnsiString(IDS_COMMON_SQUARE) + " : " + AnsiString(IDS_TOCIRCLE); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::PenShapeMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { MainImageForm->iMainImageChange(); if (Pen->Shape == 1) { PenShape->Shape = stCircle; sePenSize->Value = Pen->BasicThick; Pen->Shape = 0; PenWidthPanel->Hint = AnsiString(IDS_COMMON_CIRCLE) +" : " + AnsiString(IDS_TOSQUARE); } else if (Pen->Shape == 0) { PenShape->Shape = stRectangle; sePenSize->Value = Pen->BasicThick; Pen->Shape = 1; PenWidthPanel->Hint = AnsiString(IDS_COMMON_SQUARE) + " : " + AnsiString(IDS_TOCIRCLE); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::sePenSizeClick(TObject *Sender) { sePenSize->SetFocus(); sePenSize->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::sePenSizeChange(TObject *Sender) { if (sePenSize->Text.Length()>0) { if (MainImageForm) MainImageForm->iMainImageChange(); if (sePenSize->Value > 28) sePenSize->Value = 28; if (sePenSize->Value < 1) sePenSize->Value = 1; Pen->BasicThick = int(sePenSize->Value); PenShape->Height = Pen->BasicThick; PenShape->Width = Pen->BasicThick; PenShape->Top = (PenWidthPanel->Height - Pen->BasicThick + 1) / 2.0; PenShape->Left = (PenWidthPanel->Width - Pen->BasicThick + 1) / 2.0; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::PenSelectClick(TObject *Sender) { TSpeedButton *s; // ExitMenu(); s = (TSpeedButton *)Sender; if (s == sbNormal) InitType(PT_NORMAL); else if (s == sbAirBrush) InitType(PT_AIR); else if (s == sbCrayon) InitType(PT_CRAYON); else if (s == sbWater) InitType(PT_WATER); else if (s == sbScratch) InitType(PT_SCRAPE); else if (s == sbMask) InitType(PT_MASK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::cbPressureClick(TObject *Sender) { Pen->Brush = cbPressure->Checked; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::sbBeforeClick(TObject *Sender) { Selector->LoadFromFile(DirectoryItem+"\\Pen.Ini", "Color"); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::WaterFuctionClick(TObject *Sender) { TSpeedButton *s = (TSpeedButton *) Sender; InitWaterPanel(s->Tag); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::ScrollBarColorScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { cr[WaterType] = ScrollPos/100.0; ColorLabel->Caption = ScrollPos; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::ScrollBarEffectScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { or[WaterType] = ScrollPos/100.0; EffectLabel->Caption = ScrollPos; } //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- /* void TPenManagerForm::WMEXITSIZEMOVE(TMessage &msg) { if ((Left <= MainForm->PenFormPos.x + 100) && (Left >= MainForm->PenFormPos.x - 100)) { if ((Top <= MainForm->PenFormPos.y + 100) && (Top >= MainForm->PenFormPos.y - 100)) { Top = MainForm->PenFormPos.y; Left = MainForm->PenFormPos.x; } } } */ //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::ChangeAirColorPalette(int index, bool del) { int i, count, cnt, modify, chcnt; TColorList *Temp, *Temp2; int TotalValue, DivValue; TShape *s; TEdit *e; TotalValue = 0; DivValue = 0; count = 0; modify = 0; for (i = 1; i <= AirColorList->Count; i++) { Temp = (TColorList *)(AirColorList->Items[i - 1]); if (Temp->modify) { TotalValue += Temp->percent; modify++; } else { count++; } } if (count) { DivValue = double(100 - TotalValue) / count; } else { if (modify > 1) { if (del) chcnt = modify; else chcnt = modify - 1; DivValue = (100 - TotalValue) / chcnt; } else DivValue = 100; } cnt = 0; for (i = 1; i <= 18; i++) { if (i <= AirColorList->Count) { Temp = (TColorList *)(AirColorList->Items[i - 1]); s = (TShape *)(FindComponent("shAirColor" + AnsiString(i))); s->Brush->Color = MainImageForm->Palette->Color[Temp->color]; if (AirColorList->Count == 1) { Temp->modify = false; Temp->percent = 100; } else { if (Temp->modify == false) { //°ªÀ» ¼öÁ¤ÇÏÁö ¾ÊÀº°Í cnt++; if (cnt == count) { Temp->percent = abs(100 - (DivValue * (count - 1) + TotalValue)); } else { Temp->percent = DivValue; } } else if ((count == 0) && (modify >1)) { //°ªÀ» ¼öÁ¤ÇÏÁö ¾ÊÀº °ÍÀÌ ¾ø°í cnt++; //°ªÀ» ¼öÁ¤ÇÑ °Í¸¸ ¿©·¯°³ ³²Àº °æ¿ì if (i-1 != index) { Temp->percent += DivValue; } if (cnt == modify) { if (cnt-1 == index) { Temp2 = (TColorList *)AirColorList->Items[index - 1]; Temp2->percent += abs(100 - (DivValue * chcnt + TotalValue)); e = (TEdit *)(FindComponent("Edit" + AnsiString(i-1))); e->Text = Temp2->percent; } else { Temp->percent += abs(100 - (DivValue * chcnt + TotalValue)); } } } } e = (TEdit *)(FindComponent("Edit" + AnsiString(i))); e->Text = Temp->percent; } else { s = (TShape *)(FindComponent("shAirColor" + AnsiString(i))); s->Brush->Color = clWhite; e = (TEdit *)(FindComponent("Edit" + AnsiString(i))); e->Text = "0"; } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::DeleteAirColorPalette(int index) { AirColorList->Delete(index); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::InputPercent(TObject *Sender) { int i, TotalValue, Percent, Not; TEdit *s; TColorList *Temp; s = (TEdit *)Sender; TotalValue = 0; Not = 0; for (i = 0; i < AirColorList->Count; i++) { if (i != s->Tag) { Temp = (TColorList *)(AirColorList->Items[i]); if (Temp->modify == false) Not++; else TotalValue += Temp->percent; } } Percent = StrToInt(s->Text); if (Percent > 100 - TotalValue - Not) Percent = 100 - TotalValue - Not; Temp = (TColorList *)(AirColorList->Items[s->Tag]); Temp->percent = Percent; Temp->modify = true; ChangeAirColorPalette(s->Tag); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_airbrush_pen(void) { int i, j, x, y, pw, rn; TColorList *V; double r, ran, den; COLORREF c; int x0, y0, xn1, yn1, xp1, yp1; Byte *src, *dst, *dp, *mp; RECT rect; TPItemImage *Image = MainImageForm->iMainImage; if (AirType == PAT_SINGLE) { pw = Pen->Thick / 2 + 1; den = seSDotNum->Value; i = 0; if (Image->Bitmap->BitsPerPixel==8) { c = PaletteForm->DIB256Palette->GetFGCOLORREF(8); if (MainImageForm->MaskArea) { if (MainImageForm->Protect) { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seSNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; Image->Bitmap->PutScanLine(y); } } } else if (seSNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Height) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; Image->Bitmap->PutScanLine(y + 1); } } } } else if (seSNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else if (seSNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } else { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seSNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (mp[x] == 0) src[x] = c; Image->Bitmap->PutScanLine(y); } } } else if (seSNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (mp[x] == 0) src[x] = c; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (mp[x] == 0) src[x] = c; Image->Bitmap->PutScanLine(y + 1); } } } } else if (seSNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else if (seSNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } else { if (MainImageForm->Protect) { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seSNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; Image->Bitmap->PutScanLine(y); } } } else if (seSNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Height) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; Image->Bitmap->PutScanLine(y + 1); } } } } else if (seSNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else if (seSNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } else { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seSNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); src[x] = c; Image->Bitmap->PutScanLine(y); } } } else if (seSNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); src[x] = c; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); src[x] = c; Image->Bitmap->PutScanLine(y + 1); } } } } else if (seSNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else if (seSNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } else { c = PaletteForm->DIB256Palette->GetFGCOLORREF(24); if (MainImageForm->MaskArea) { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seSNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); Image->Bitmap->PutScanLine(y); } } } else if (seSNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; mp = Image->Mask->GetScanLine(y + 1); if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); Image->Bitmap->PutScanLine(y + 1); } } } } else if (seSNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } else if (seSNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*x; mp = Image->Mask->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*(x-1); mp = Image->Mask->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } i++; } } else { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seSNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y)+3*x; SetPixel24(src, c); Image->Bitmap->PutScanLine(y); } } } else if (seSNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; SetPixel24(src, c); Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; SetPixel24(src, c); Image->Bitmap->PutScanLine(y + 1); } } } } else if (seSNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } else if (seSNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } else if (AirType == PAT_MULTI) { pw = Pen->Thick / 2 + 1; int denvalue = seMDotNum->Value; if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->MaskArea) { if (MainImageForm->Protect) { if (AirColorList->Count > 0) { for (j = 0; j < AirColorList->Count; j++) { V = (TColorList *) AirColorList->Items[j]; i = 0; den = denvalue * V->percent / 100.0; c = V->color; while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seMNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; Image->Bitmap->PutScanLine(y); } } } else if (seMNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Height) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; Image->Bitmap->PutScanLine(y + 1); } } } } else if (seMNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else if (seMNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] ==0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } else { if (AirColorList->Count > 0) { for (j = 0; j < AirColorList->Count; j++) { V = (TColorList *) AirColorList->Items[j]; i = 0; den = denvalue * V->percent / 100.0; c = V->color; while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seMNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (mp[x] == 0) src[x] = c; Image->Bitmap->PutScanLine(y); } } } else if (seMNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (mp[x] == 0) src[x] = c; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (mp[x] == 0) src[x] = c; Image->Bitmap->PutScanLine(y + 1); } } } } else if (seMNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else if (seMNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } } else { if (MainImageForm->Protect) { if (AirColorList->Count > 0) { for (j = 0; j <= AirColorList->Count - 1; j++) { V = (TColorList *)(AirColorList->Items[j]); i = 0; den = denvalue * V->percent / 100.0; c = V->color; while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seMNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; Image->Bitmap->PutScanLine(y); } } } else if (seMNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Height) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; Image->Bitmap->PutScanLine(y + 1); } } } } else if (seMNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else if (seMNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = c; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } else { if (AirColorList->Count > 0) { for (j = 0; j <= AirColorList->Count - 1; j++) { V = (TColorList *)(AirColorList->Items[j]); i = 0; den = denvalue * V->percent / 100.0; c = V->color; while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seMNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); src[x] = c; Image->Bitmap->PutScanLine(y); } } } else if (seMNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); src[x] = c; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); src[x] = c; Image->Bitmap->PutScanLine(y + 1); } } } } else if (seMNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else if (seMNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = c; } if (x>=0 && xBitmap->Width) { src[x] = c; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = c; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } } } else { if (MainImageForm->MaskArea) { if (AirColorList->Count > 0) { for (j = 0; j <= AirColorList->Count - 1; j++) { V = (TColorList *)(AirColorList->Items[j]); i = 0; den = denvalue * V->percent / 100.0; c = MainImageForm->Palette->Color[V->color]; while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seMNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); Image->Bitmap->PutScanLine(y); } } } else if (seMNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; mp = Image->Mask->GetScanLine(y + 1); if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); Image->Bitmap->PutScanLine(y + 1); } } } } else if (seMNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } else if (seMNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*x; mp = Image->Mask->GetScanLine(y - 1); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; mp = Image->Mask->GetScanLine(y + 1); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*(x-1); mp = Image->Mask->GetScanLine(y - 1); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); mp = Image->Mask->GetScanLine(y); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); mp = Image->Mask->GetScanLine(y + 1); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } else { if (AirColorList->Count > 0) { for (j = 0; j <= AirColorList->Count - 1; j++) { V = (TColorList *)(AirColorList->Items[j]); i = 0; den = denvalue * V->percent / 100.0; c = MainImageForm->Palette->Color[V->color]; while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (seMNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y)+3*x; SetPixel24(src, c); Image->Bitmap->PutScanLine(y); } } } else if (seMNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; SetPixel24(src, c); Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; SetPixel24(src, c); Image->Bitmap->PutScanLine(y + 1); } } } } else if (seMNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } else if (seMNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); if (x-1>=0 && x-1Bitmap->Width) { SetPixel24(src, c); } src += 3; if (x>=0 && xBitmap->Width) { SetPixel24(src, c); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { SetPixel24(src, c); } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } } } else if (AirType == PAT_PATTERN) { pw = Pen->Thick / 2 + 1; den = sePDotNum->Value; rect = MainImageForm->WorkArea->Range; i = 0; if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->MaskArea) { if (MainImageForm->Protect) { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (x - 1 < rect.left) xn1 = rect.right - (rect.left - x + 1) % (rect.right - rect.left) - rect.left - 1; else xn1 = (x - 1 - rect.left) % (rect.right - rect.left); if (x < rect.left) x0 = rect.right - (rect.left - x) % (rect.right - rect.left) - rect.left - 1; else x0 = (x - rect.left) % (rect.right - rect.left); if (x + 1 < rect.left) xp1 = rect.right - (rect.left - x - 1) % (rect.right - rect.left) - rect.left - 1; else xp1 = (x + 1 - rect.left) % (rect.right - rect.left); if (y - 1 < rect.top) yn1 = rect.bottom - (rect.top - y + 1) % (rect.bottom - rect.top) - rect.top - 1; else yn1 = (y - 1 - rect.top) % (rect.bottom - rect.top); if (y < rect.top) y0 = rect.bottom - (rect.top - y) % (rect.bottom - rect.top) - rect.top -1; else y0 = (y - rect.top) % (rect.bottom - rect.top); if (y + 1 < rect.top) yp1 = rect.bottom - (rect.top - y - 1) % (rect.bottom - rect.top) - rect.top -1; else yp1 = (y + 1 - rect.top) % (rect.bottom - rect.top); if (sePNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; Image->Bitmap->PutScanLine(y); } } } else if (sePNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; Image->Bitmap->PutScanLine(y + 1); } } } } else if (sePNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } else if (sePNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) && (mp[x - 1] == 0)) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x]]->Protect == 0) && (mp[x] == 0)) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if ((MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) && (mp[x + 1] == 0)) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } else { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (x - 1 < rect.left) xn1 = rect.right - (rect.left - x + 1) % (rect.right - rect.left) - rect.left - 1; else xn1 = (x - 1 - rect.left) % (rect.right - rect.left); if (x < rect.left) x0 = rect.right - (rect.left - x) % (rect.right - rect.left) - rect.left - 1; else x0 = (x - rect.left) % (rect.right - rect.left); if (x + 1 < rect.left) xp1 = rect.right - (rect.left - x - 1) % (rect.right - rect.left) - rect.left - 1; else xp1 = (x + 1 - rect.left) % (rect.right - rect.left); if (y - 1 < rect.top) yn1 = rect.bottom - (rect.top - y + 1) % (rect.bottom - rect.top) - rect.top - 1; else yn1 = (y - 1 - rect.top) % (rect.bottom - rect.top); if (y < rect.top) y0 = rect.bottom - (rect.top - y) % (rect.bottom - rect.top) - rect.top - 1; else y0 = (y - rect.top) % (rect.bottom - rect.top); if (y + 1 < rect.top) yp1 = rect.bottom - (rect.top - y - 1) % (rect.bottom - rect.top) - rect.top - 1; else yp1 = (y + 1 - rect.top) % (rect.bottom - rect.top); if (sePNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (mp[x] == 0) src[x] = dst[x0]; Image->Bitmap->PutScanLine(y); } } } else if (sePNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (mp[x] == 0) src[x] = dst[x0]; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (mp[x] == 0) src[x] = dst[x0]; Image->Bitmap->PutScanLine(y + 1); } } } } else if (sePNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } else if (sePNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); mp = Image->Mask->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { if (mp[x - 1] == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (mp[x] == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (mp[x + 1] == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } else { if (MainImageForm->Protect) { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (x - 1 < rect.left) xn1 = rect.right - (rect.left - x + 1) % (rect.right - rect.left) - rect.left - 1; else xn1 = (x - 1 - rect.left) % (rect.right - rect.left); if (x < rect.left) x0 = rect.right - (rect.left - x) % (rect.right - rect.left) - rect.left - 1; else x0 = (x - rect.left) % (rect.right - rect.left); if (x + 1 < rect.left) xp1 = rect.right - (rect.left - x - 1) % (rect.right - rect.left) - rect.left - 1; else xp1 = (x + 1 - rect.left) % (rect.right - rect.left); if (y - 1 < rect.top) yn1 = rect.bottom - (rect.top - y + 1) % (rect.bottom - rect.top) - rect.top - 1; else yn1 = (y - 1 - rect.top) % (rect.bottom - rect.top); if (y < rect.top) y0 = rect.bottom - (rect.top - y) % (rect.bottom - rect.top) - rect.top - 1; else y0 = (y - rect.top) % (rect.bottom - rect.top); if (y + 1 < rect.top) yp1 = rect.bottom - (rect.top - y - 1) % (rect.bottom - rect.top) - rect.top - 1; else yp1 = (y + 1 - rect.top) % (rect.bottom - rect.top); if (sePNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; Image->Bitmap->PutScanLine(y); } } } else if (sePNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; Image->Bitmap->PutScanLine(y + 1); } } } } else if (sePNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } else if (sePNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x - 1]]->Protect == 0) src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { if (MainImageForm->Palette->ColorData[src[x]]->Protect == 0) src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { if (MainImageForm->Palette->ColorData[src[x + 1]]->Protect == 0) src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } else { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (x - 1 < rect.left) xn1 = rect.right - (rect.left - x + 1) % (rect.right - rect.left) - rect.left - 1; else xn1 = (x - 1 - rect.left) % (rect.right - rect.left); if (x < rect.left) x0 = rect.right - (rect.left - x) % (rect.right - rect.left) - rect.left - 1; else x0 = (x - rect.left) % (rect.right - rect.left); if (x + 1 < rect.left) xp1 = rect.right - (rect.left - x - 1) % (rect.right - rect.left) - rect.left - 1; else xp1 = (x + 1 - rect.left) % (rect.right - rect.left); if (y - 1 < rect.top) yn1 = rect.bottom - (rect.top - y + 1) % (rect.bottom - rect.top) - rect.top - 1; else yn1 = (y - 1 - rect.top) % (rect.bottom - rect.top); if (y < rect.top) y0 = rect.bottom - (rect.top - y) % (rect.bottom - rect.top) - rect.top - 1; else y0 = (y - rect.top) % (rect.bottom - rect.top); if (y + 1 < rect.top) yp1 = rect.bottom - (rect.top - y - 1) % (rect.bottom - rect.top) - rect.top - 1; else yp1 = (y + 1 - rect.top) % (rect.bottom - rect.top); if (sePNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); src[x] = dst[x0]; Image->Bitmap->PutScanLine(y); } } } else if (sePNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); src[x] = dst[x0]; Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); src[x] = dst[x0]; Image->Bitmap->PutScanLine(y + 1); } } } } else if (sePNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } else if (sePNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { src[x - 1] = dst[xn1]; } if (x>=0 && xBitmap->Width) { src[x] = dst[x0]; } if (x+1>=0 && x+1Bitmap->Width) { src[x + 1] = dst[xp1]; } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } else { if (MainImageForm->MaskArea) { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (x - 1 < rect.left) xn1 = rect.right - (rect.left - x + 1) % (rect.right - rect.left) - rect.left - 1; else xn1 = (x - 1 - rect.left) % (rect.right - rect.left); if (x < rect.left) x0 = rect.right - (rect.left - x) % (rect.right - rect.left) - rect.left - 1; else x0 = (x - rect.left) % (rect.right - rect.left); if (x + 1 < rect.left) xp1 = rect.right - (rect.left - x - 1) % (rect.right - rect.left) - rect.left - 1; else xp1 = (x + 1 - rect.left) % (rect.right - rect.left); if (y - 1 < rect.top) yn1 = rect.bottom - (rect.top - y + 1) % (rect.bottom - rect.top) - rect.top - 1; else yn1 = (y - 1 - rect.top) % (rect.bottom - rect.top); if (y < rect.top) y0 = rect.bottom - (rect.top - y) % (rect.bottom - rect.top) - rect.top - 1; else y0 = (y - rect.top) % (rect.bottom - rect.top); if (y + 1 < rect.top) yp1 = rect.bottom - (rect.top - y - 1) % (rect.bottom - rect.top) - rect.top - 1; else yp1 = (y + 1 - rect.top) % (rect.bottom - rect.top); if (sePNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0)+3*x0; if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) CopyPixel24(src, dst); Image->Bitmap->PutScanLine(y); } } } else if (sePNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0)+3*x0; if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) CopyPixel24(src, dst); Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1)+3*x0; if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) CopyPixel24(src, dst); Image->Bitmap->PutScanLine(y + 1); } } } } else if (sePNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y + 1); } } else if (sePNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) { dp = dst+3*xn1; CopyPixel24(src, dp); } } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) { dp = dst+3*xn1; CopyPixel24(src, dp); } } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*x; mp = Image->Mask->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >>3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*(x-1); mp = Image->Mask->GetScanLine(y - 1); dst = Image1->Bitmap->GetScanLine(yn1); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) { dp = dst+3*xn1; CopyPixel24(src, dp); } } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); mp = Image->Mask->GetScanLine(y); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) { dp = dst+3*xn1; CopyPixel24(src, dp); } } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); mp = Image->Mask->GetScanLine(y + 1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { if ((mp[(x - 1) >> 3] & (0x80 >> ((x - 1) & 7))) == 0) { dp = dst+3*xn1; CopyPixel24(src, dp); } } src += 3; if (x>=0 && xBitmap->Width) { if ((mp[x >> 3] & (0x80 >> (x & 7))) == 0) { dp = dst+3*x0; CopyPixel24(src, dp); } } src += 3; if (x+1>=0 && x+1Bitmap->Width) { if ((mp[(x + 1) >> 3] & (0x80 >> ((x + 1) & 7))) == 0) { dp = dst+3*xp1; CopyPixel24(src, dp); } } Image->Bitmap->PutScanLine(y + 1); } } i++; } } else { while (i < den) { rn = Random->Get(360); r = rn % pw; ran = DegToRad(rn % 360); x = Lsx + r * cos(ran); y = Lsy + r * sin(ran); if (x - 1 < rect.left) xn1 = rect.right - (rect.left - x + 1) % (rect.right - rect.left) - rect.left - 1; else xn1 = (x - 1 - rect.left) % (rect.right - rect.left); if (x < rect.left) x0 = rect.right - (rect.left - x) % (rect.right - rect.left) - rect.left - 1; else x0 = (x - rect.left) % (rect.right - rect.left); if (x + 1 < rect.left) xp1 = rect.right - (rect.left - x - 1) % (rect.right - rect.left) - rect.left - 1; else xp1 = (x + 1 - rect.left) % (rect.right - rect.left); if (y - 1 < rect.top) yn1 = rect.bottom - (rect.top - y + 1) % (rect.bottom - rect.top) - rect.top - 1; else yn1 = (y - 1 - rect.top) % (rect.bottom - rect.top); if (y < rect.top) y0 = rect.bottom - (rect.top - y) % (rect.bottom - rect.top) - rect.top - 1; else y0 = (y - rect.top) % (rect.bottom - rect.top); if (y + 1 < rect.top) yp1 = rect.bottom - (rect.top - y - 1) % (rect.bottom - rect.top) - rect.top - 1; else yp1 = (y + 1 - rect.top) % (rect.bottom - rect.top); if (sePNozzle->Value == 1) { if (y>=0 && yBitmap->Height) { if (x>=0 && xBitmap->Width) { src = Image->Bitmap->GetScanLine(y)+3*x; dst = Image1->Bitmap->GetScanLine(y0)+3*x0; CopyPixel24(src, dst); Image->Bitmap->PutScanLine(y); } } } else if (sePNozzle->Value == 2) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y); } } else { if (x>=0 && xBitmap->Width) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; dst = Image1->Bitmap->GetScanLine(y0)+3*x0; CopyPixel24(src, dst); Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; dst = Image1->Bitmap->GetScanLine(yp1)+3*x0; CopyPixel24(src, dst); Image->Bitmap->PutScanLine(y + 1); } } } } else if (sePNozzle->Value == 3) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y + 1); } } else if (sePNozzle->Value == 4) { if (x & 1) { if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { dp = dst+3*xn1; CopyPixel24(src, dp); } src += 3; if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { dp = dst+3*xn1; CopyPixel24(src, dp); } src += 3; if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y + 1); } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*x; dst = Image1->Bitmap->GetScanLine(yn1); if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*x; dst = Image1->Bitmap->GetScanLine(y0); if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*x; dst = Image1->Bitmap->GetScanLine(yp1); if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y + 1); } } } else { if (y-1>=0 && y-1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y - 1)+3*(x-1); dst = Image1->Bitmap->GetScanLine(yn1); if (x-1>=0 && x-1Bitmap->Width) { dp = dst+3*xn1; CopyPixel24(src, dp); } src += 3; if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y - 1); } if (y>=0 && yBitmap->Height) { src = Image->Bitmap->GetScanLine(y)+3*(x-1); dst = Image1->Bitmap->GetScanLine(y0); if (x-1>=0 && x-1Bitmap->Width) { dp = dst+3*xn1; CopyPixel24(src, dp); } src += 3; if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y); } if (y+1>=0 && y+1Bitmap->Height) { src = Image->Bitmap->GetScanLine(y + 1)+3*(x-1); dst = Image1->Bitmap->GetScanLine(yp1); if (x-1>=0 && x-1Bitmap->Width) { dp = dst+3*xn1; CopyPixel24(src, dp); } src += 3; if (x>=0 && xBitmap->Width) { dp = dst+3*x0; CopyPixel24(src, dp); } src += 3; if (x+1>=0 && x+1Bitmap->Width) { dp = dst+3*xp1; CopyPixel24(src, dp); } Image->Bitmap->PutScanLine(y + 1); } } i++; } } } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::line_airbrush_pen(void) { int sx, sy, ex, ey, i; double dx, dy; double slopex, slopey; TPItemImage *Image = MainImageForm->iMainImage; RECT rect; int ls, rs; ls = Pen->Thick >> 1; rs = Pen->Thick - ls; if (Image->Bitmap->StartScanLine() == false) goto fail; if (MainImageForm->MaskArea) { if (Image->Mask->StartScanLine() == false) goto fail; } if (AirType == PAT_PATTERN) { if (Image1->Bitmap->StartScanLine() == false) goto fail; } sx = Lsx; ex = Lex; sy = Lsy; ey = Ley; dx = ex - sx; dy = ey - sy; if (sx == ex) { if (sy == ey) { set_airbrush_pen(); } else { Lsx = sx; if (sy < ey) { for (i = sy; i <= ey; i += 3) { Lsy = i; set_airbrush_pen(); } } else { for (i = sy; i >= ey; i -= 3) { Lsy = i; set_airbrush_pen(); } } } } else { if (sy == ey) { Lsy = sy; if (sx < ex) { for (i = sx; i <= ex; i += 3) { Lsx = i; set_airbrush_pen(); } } else { for (i = sx; i >= ex; i -= 3) { Lsx = i; set_airbrush_pen(); } } } else { slopex = dy / dx; slopey = dx / dy; if (sx < ex) { if (sy < ey) { if (fabs(slopex) < 1.0) { for (i = sx; i <= ex; i += 3) { Lsx = i; Lsy = slopex * (Lsx - sx) + sy; set_airbrush_pen(); } } else { for (i = sy; i <= ey; i += 3) { Lsy = i; Lsx = slopey * (Lsy - sy) + sx; set_airbrush_pen(); } } } else { if (fabs(slopex) < 1.0) { for (i = sx; i <= ex; i += 3) { Lsx = i; Lsy = slopex * (Lsx - sx) + sy; set_airbrush_pen(); } } else { for (i = sy; i >= ey; i -= 3) { Lsy = i; Lsx = slopey * (Lsy - sy) + sx; set_airbrush_pen(); } } } } else { if (sy < ey) { if (fabs(slopex) < 1.0) { for (i = sx; i >= ex; i -= 3) { Lsx = i; Lsy = slopex * (Lsx - sx) + sy; set_airbrush_pen(); } } else { for (i = sy; i <= ey; i += 3) { Lsy = i; Lsx = slopey * (Lsy - sy) + sx; set_airbrush_pen(); } } } else { if (fabs(slopex) < 1.0) { for (i = sx; i >= ex; i -= 3) { Lsx = i; Lsy = slopex * (Lsx - sx) + sy; set_airbrush_pen(); } } else { for (i = sy; i >= ey; i -= 3) { Lsy = i; Lsx = slopey * (Lsy - sy) + sx; set_airbrush_pen(); } } } } } } if (AirType == PAT_PATTERN) { Image1->Bitmap->StopScanLine(); } if (MainImageForm->MaskArea) Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); rect.left = min(sx, ex) - ls; rect.top = min(sy, ey) - ls; rect.right = max(sx, ex) + rs; rect.bottom = max(sy, ey) + rs; Image->RectPaint(rect); Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; return; fail : Image1->Bitmap->StopScanLine(); Image->Mask->StartScanLine(); Image->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_brush_spread_pen(int lsx, int lsy, int size, COLORREF color) { int sx, sy, x, y, s, e, pw; Byte *P, *MP; TPItemImage *Image = MainImageForm->iMainImage; pw = size; sx = lsx - 14; sy = lsy - 14; s = 13 - pw / 2.0; e = 14 + pw / 2.0; if (MainImageForm->MaskArea) { if (Image->Bitmap->StartScanLine() == false) goto fail; if (Image->Mask->StartScanLine() == false) goto fail; if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { if (acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[P[sx + x]]->Protect == 0) && (Selector->Number[P[sx + x]] < 255) && (MP[sx + x] == 0)) { P[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[P[sx + x]]->Protect == 0) && (MP[sx + x] == 0)) { P[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } } else { if (acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (Selector->Number[P[sx + x]] < 255) && (MP[sx + x] == 0)) { P[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x] && (MP[sx + x] == 0)) { P[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y)+3*(sx+s); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++, P+=3) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x] && ((MP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { SetPixel24(P, color); } } } Image->Bitmap->PutScanLine(sy + y); } } } Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); } else { if (Image->Bitmap->StartScanLine() == false) goto fail; if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { if (acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[P[sx + x]]->Protect == 0) && (Selector->Number[P[sx + x]] < 255)) { P[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[P[sx + x]]->Protect == 0)) { P[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } } else { if (acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (Selector->Number[P[sx + x]] < 255)) { P[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { P[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(sy + y)+3*(sx+s); for (x = s; x <= e; x++, P+=3) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { SetPixel24(P, color); } } } Image->Bitmap->PutScanLine(sy + y); } } } Image->Bitmap->StopScanLine(); } return; fail : Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_crayon_brush_spread_pen(int lsx, int lsy, int size, COLORREF color) { int s, e, sx, sy, x, y, pw, p; Byte *IP, *MP; int ran; TPItemImage *Image = MainImageForm->iMainImage; pw = size; sx = lsx - 14; sy = lsy - 14; s = 13 - pw / 2.0; e = 14 + pw / 2.0; if (pw <= 0) p = 1; else p = pw; if (density == 1) { ran = 5000 / p; } else if (density == 2) { ran = 12000 / p; } else if (density == 3) { ran = 18000 / p; } else if (density == 4) { ran = 24000 / p; } else { ran = 30000 / p; } if (MainImageForm->MaskArea) { if (Image->Bitmap->StartScanLine() == false) goto fail; if (Image->Mask->StartScanLine() == false) goto fail; if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { if (acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (MP[sx + x] == 0)) { IP[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } } else { if (acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MP[sx + x] == 0)) { IP[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y)+3*(sx+s); MP = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++, IP+=3) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && ((MP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { SetPixel24(IP, color); } } } Image->Bitmap->PutScanLine(sy + y); } } } Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); } else { if (Image->Bitmap->StartScanLine() == false) goto fail; if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { if (acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0)) { IP[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } } else { if (acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran)) { IP[sx + x] = color; } } } Image->Bitmap->PutScanLine(sy + y); } } } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { IP = Image->Bitmap->GetScanLine(sy + y)+3*(sx+s); for (x = s; x <= e; x++, IP+=3) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if ((pshape[Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran)) { SetPixel24(IP, color); } } } Image->Bitmap->PutScanLine(sy + y); } } } Image->Bitmap->StopScanLine(); } return; fail : Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_brush_mask_pen(int lsx, int lsy, int size) { int sx, sy, x, y, s, e, pw; Byte *P; TPItemImage *Image = MainImageForm->iMainImage; pw = size; sx = lsx - 14; sy = lsy - 14; s = 13 - pw / 2.0; e = 14 + pw / 2.0; if (Image->Mask->StartScanLine() == false) goto fail; if (Image->Bitmap->BitsPerPixel == 8) { if (chDelete->Checked) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { P[sx + x] = 0x00; } } } Image->Mask->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { P[sx + x] = 0x0F; } } } Image->Mask->PutScanLine(sy + y); } } } } else { if (chDelete->Checked) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { P[(sx + x) >> 3] &= ~(0x80 >> ((sx + x) & 7)); } } } Image->Mask->PutScanLine(sy + y); } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Image->Bitmap->Height)) { P = Image->Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Image->Bitmap->Width)) { if (pshape[Pen->Shape].size[pw - 1].dot[y][x]) { P[(sx + x) >> 3] |= (0x80 >> ((sx + x) & 7)); } } } Image->Mask->PutScanLine(sy + y); } } } } Image->Mask->StopScanLine(); return; fail : Image->Mask->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::init_pressure_pen() { int i, j, k, l, cx, cy, sx, sy, a, t; double r; for (i = 0; i <= 1; i++) { for (j = 0; j <= 27; j++) { for (k = 0; k <= 28; k++) { for (l = 0; l <= 28; l++) { pshape[i].size[j].dot[k][l] = 0; } } } } cx = 14; cy = 14; pshape[0].size[0].dot[cy][cx] = 1; for (j = 0; j <= 27; j++) { r = (j + 1.0) / 2.0; t = r; if (j & 1) { for (k = 0; k <= t - 1; k++) { l = sqrt(t * t - (k + 0.5) * (k + 0.5)) + 0.5; for (a = cx - l; a <= cx + l; a++) { pshape[0].size[j].dot[cy + k][a] = 1; pshape[0].size[j].dot[cy - k - 1][a] = 1; } } } else { for (k = 0; k <= t; k++) { l = sqrt(r * r - k * k); for (a = cx - l; a <= cx + l; a++) { pshape[0].size[j].dot[cy + k][a] = 1; pshape[0].size[j].dot[cy - k][a] = 1; } } } } pshape[1].size[0].dot[cy][cx] = 1; for (j = 1; j <= 27; j++) { sx = cx - (j + 1) / 2.0; sy = cy - (j + 1) / 2.0; for (k = sy; k <= sy + j; k++) { for (l = sx; l <= sx + j; l++) { pshape[1].size[j].dot[k][l] = 1; } } } } /*--------------------------------------------------------------------------- void __fastcall TPenManagerForm::point_pressure_pen(int lsx, int lsy, int size, COLORREF color) { TColor rgb; RGBQUAD m_rgb[3]; if (T_NONE == MainMenuForm->Item) { if (MainForm->MainImageForm->iMainImage->Bitmap->BitsPerPixel==8) { if (Type == PT_NORMAL) { set_brush_spread_pen(lsx, lsy, size, color); } else if (Type == PT_CRAYON) { set_crayon_brush_spread_pen(lsx, lsy, size, color); } } else { if (aspread) { m_rgb[0] = MainForm->MainImageForm->Palette->ColorData[spread_start]->RGB; m_rgb[1] = MainForm->MainImageForm->Palette->ColorData[spread_end]->RGB; m_rgb[2].rgbRed = m_rgb[0].rgbRed+color*(m_rgb[1].rgbRed-m_rgb[0].rgbRed)/255; m_rgb[2].rgbGreen = m_rgb[0].rgbGreen+color*(m_rgb[1].rgbGreen-m_rgb[0].rgbGreen)/255; m_rgb[2].rgbBlue = m_rgb[0].rgbBlue+color*(m_rgb[1].rgbBlue-m_rgb[0].rgbBlue)/255; rgb = RGBToTColor(m_rgb[2]); } else { rgb = MainForm->MainImageForm->Palette->Color[color]; } if (Type == PT_NORMAL) { set_brush_spread_pen(lsx, lsy, size, rgb); } else if (Type == PT_CRAYON) { set_crayon_brush_spread_pen(lsx, lsy, size, rgb); } } } else if (T_PATTERN == MainMenuForm->Item) { if (Type == PT_NORMAL) { if (PatternRepeatForm->Item == T_REGULAR) set_brush_spread_regular_pattern_pen(lsx, lsy, size, color); else set_brush_spread_irregular_pattern_pen(lsx, lsy, size, color); } else if (Type == PT_CRAYON) { if (PatternRepeatForm->Item == T_REGULAR) set_crayon_brush_spread_regular_pattern_pen(lsx, lsy, size, color); else set_crayon_brush_spread_irregular_pattern_pen(lsx, lsy, size, color); } } } */ //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::point_pressure_pen(int lsx, int lsy, int size, COLORREF color) { TColor rgb; RGBQUAD m_rgb[3]; if (MainImageForm->iMainImage->Bitmap->BitsPerPixel==8) { if (Type == PT_NORMAL) { set_brush_spread_pen(lsx, lsy, size, color); } else if (Type == PT_CRAYON) { set_crayon_brush_spread_pen(lsx, lsy, size, color); } else if (Type == PT_MASK) { set_brush_mask_pen(lsx, lsy, size); } } else { if (aspread) { m_rgb[0] = MainImageForm->Palette->ColorData[spread_start]->RGB; m_rgb[1] = MainImageForm->Palette->ColorData[spread_end]->RGB; m_rgb[2].rgbRed = m_rgb[0].rgbRed+color*(m_rgb[1].rgbRed-m_rgb[0].rgbRed)/Tablet->MaxNPressure; m_rgb[2].rgbGreen = m_rgb[0].rgbGreen+color*(m_rgb[1].rgbGreen-m_rgb[0].rgbGreen)/Tablet->MaxNPressure; m_rgb[2].rgbBlue = m_rgb[0].rgbBlue+color*(m_rgb[1].rgbBlue-m_rgb[0].rgbBlue)/Tablet->MaxNPressure; rgb = RGBToTColor(m_rgb[2]); } else { rgb = MainImageForm->Palette->Color[color]; } if (Type == PT_NORMAL) { set_brush_spread_pen(lsx, lsy, size, rgb); } else if (Type == PT_CRAYON) { set_crayon_brush_spread_pen(lsx, lsy, size, rgb); } else if (Type == PT_MASK) { set_brush_mask_pen(lsx, lsy, size); } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::line_pressure_pen(int pw, COLORREF spc) { int size, sx, sy, ex, ey, pwl, pcl; COLORREF color; double pwx, pwy, pcx, pcy; double dx, dy; double slopex, slopey; TPItemImage *Image = MainImageForm->iMainImage; RECT rect; int ls, rs; ls = pw >> 1; rs = pw - ls; sx = Lsx; ex = Lex; sy = Lsy; ey = Ley; dx = ex - sx; dy = ey - sy; pwl = pw - o_size; if (dx == 0) pwx = pwl; else pwx = pwl / fabs(dx); if (dy == 0) pwy = pwl; else pwy = pwl / fabs(dy); pcl = spc - o_color; if (dx == 0) pcx = pcl; else pcx = pcl / fabs(dx); if (dy == 0) pcy = pcl; else pcy = pcl / fabs(dy); if (sx == ex) { if (sy == ey) { if (o_size < pw) { FPointPressurePen(Lsx, Lsy, pw, spc); } } else { Lsx = sx; if (sy < ey) { for (Lsy = sy; Lsy <= ey; Lsy++) { size = o_size + (Lsy - sy) * pwy + 0.5; color = o_color + (Lsy - sy) * pcy + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy >= ey; Lsy--) { size = o_size + (sy - Lsy) * pwy + 0.5; color = o_color + (sy - Lsy) * pcy + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } } else { if (sy == ey) { Lsy = sy; if (sx < ex) { for (Lsx = sx; Lsx <= ex; Lsx++) { size = o_size + (Lsx - sx) * pwx + 0.5; color = o_color + (Lsx - sx) * pcx + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsx = sx; Lsx >= ex; Lsx--) { size = o_size + (sx - Lsx) * pwx + 0.5; color = o_color + (sx - Lsx) * pcx + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } else { slopex = dy / dx; slopey = dx / dy; if (sx < ex) { if (sy < ey) { if (fabs(slopex) < 1.0) { for (Lsx = sx; Lsx <= ex; Lsx++) { Lsy = slopex * (Lsx - sx) + sy; size = o_size + pwx * (Lsx - sx) + 0.5; color = o_color + pcx * (Lsx - sx) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy <= ey; Lsy++) { Lsx = slopey * (Lsy - sy) + sx; size = o_size + pwy * (Lsy - sy) + 0.5; color = o_color + pcy * (Lsy - sy) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } else { if (fabs(slopex) < 1.0) { for (Lsx = sx; Lsx <= ex; Lsx++) { Lsy = slopex * (Lsx - sx) + sy; size = o_size + pwx * (Lsx - sx) + 0.5; color = o_color + pcx * (Lsx - sx) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy >= ey; Lsy--) { Lsx = slopey * (Lsy - sy) + sx; size = o_size + pwy * (sy - Lsy) + 0.5; color = o_color + pcy * (sy - Lsy) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } } else { if (sy < ey) { if (fabs(slopex) < 1.0) { for (Lsx = sx; Lsx >= ex; Lsx--) { Lsy = slopex * (Lsx - sx) + sy; size = o_size + pwx * (sx - Lsx) + 0.5; color = o_color + pcx * (sx - Lsx) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy <= ey; Lsy++) { Lsx = slopey * (Lsy - sy) + sx; size = o_size + pwy * (Lsy - sy) + 0.5; color = o_color + pcy * (Lsy - sy) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } else { if (fabs(slopex) < 1.0) { for (Lsx = sx; Lsx >= ex; Lsx--) { Lsy = slopex * (Lsx - sx) + sy; size = o_size + pwx * (sx - Lsx) + 0.5; color = o_color + pcx * (sx - Lsx) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } else { for (Lsy = sy; Lsy >= ey; Lsy--) { Lsx = slopey * (Lsy - sy) + sx; size = o_size + pwy * (sy - Lsy) + 0.5; color = o_color + pcy * (sy - Lsy) + 0.5; FPointPressurePen(Lsx, Lsy, size, color); } } } } } } rect.left = min(sx, ex) - ls; rect.top = min(sy, ey) - ls; rect.right = max(sx, ex) + rs; rect.bottom = max(sy, ey) + rs; Image->RectPaint(rect); Lsx = sx; Lex = ex; Lsy = sy; Ley = ey; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_pen(int x, int y, int size, COLORREF color) { int xx; double x1, yy, r, r2; Byte *P, *MP; TPItemImage *Image = MainImageForm->iMainImage; if (MainImageForm->MaskArea) { if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { if (acolor == 2) { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); MP = Image->Mask->GetScanLine(y - yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); MP = Image->Mask->GetScanLine(y + yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); MP = Image->Mask->GetScanLine(y - yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); MP = Image->Mask->GetScanLine(y + yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y + yy); } } } } else { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0 && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); MP = Image->Mask->GetScanLine(y - yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0 && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); MP = Image->Mask->GetScanLine(y + yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0 && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0 && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); MP = Image->Mask->GetScanLine(y - yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0 && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); MP = Image->Mask->GetScanLine(y + yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0 && (MP[x + xx] == 0)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y + yy); } } } } } else { if (acolor == 2) { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); MP = Image->Mask->GetScanLine(y - yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); MP = Image->Mask->GetScanLine(y + yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); MP = Image->Mask->GetScanLine(y - yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); MP = Image->Mask->GetScanLine(y + yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y + yy); } } } } else { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); MP = Image->Mask->GetScanLine(y - yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); MP = Image->Mask->GetScanLine(y + yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); MP = Image->Mask->GetScanLine(y - yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); MP = Image->Mask->GetScanLine(y + yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (MP[x + xx] == 0)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y + yy); } } } } } } else { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y)+3*(int)(x-r); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && ((MP[(x + xx) >> 3] & (0x80 >> ((x + xx) & 7))) == 0)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy)+3*(int)(x-r); MP = Image->Mask->GetScanLine(y - yy); for (xx = -r; xx <= r; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && ((MP[(x + xx) >> 3] & (0x80 >> ((x + xx) & 7))) == 0)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy)+3*(int)(x-r); MP = Image->Mask->GetScanLine(y + yy); for (xx = -r; xx <= r; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && ((MP[(x + xx) >> 3] & (0x80 >> ((x + xx) & 7))) == 0)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y)+3*(int)(x-r); MP = Image->Mask->GetScanLine(y); for (xx = -r; xx <= r; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && ((MP[(x + xx) >> 3] & (0x80 >> ((x + xx) & 7))) == 0)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy)+3*(int)(x-x1); MP = Image->Mask->GetScanLine(y - yy); for (xx = -x1; xx <= x1; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && ((MP[(x + xx) >> 3] & (0x80 >> ((x + xx) & 7))) == 0)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy)+3*(int)(x-x1); MP = Image->Mask->GetScanLine(y + yy); for (xx = -x1; xx <= x1; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && ((MP[(x + xx) >> 3] & (0x80 >> ((x + xx) & 7))) == 0)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y + yy); } } } } } else { if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { if (acolor == 2) { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if ((MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y + yy); } } } } else { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { if (MainImageForm->Palette->ColorData[P[x + xx]]->Protect == 0) { P[x + xx] = color; } } } Image->Bitmap->PutScanLine(y + yy); } } } } } else { if (acolor == 2) { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width) && (Selector->Number[P[x + xx]] < 255)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y + yy); } } } } else { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y); for (xx = -r; xx <= r; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy); for (xx = -x1; xx <= x1; xx++) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { P[x + xx] = color; } } Image->Bitmap->PutScanLine(y + yy); } } } } } } else { if (Pen->Shape == 1) { r = size / 2.0 - 0.25; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y)+3*(int)(x-r); for (xx = -r; xx <= r; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy)+3*(int)(x-r); for (xx = -r; xx <= r; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy)+3*(int)(x-r); for (xx = -r; xx <= r; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y + yy); } } } else { r = size / 2.0 - 0.25; r2 = r * r; if ((y >= 0) && (y < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y)+3*(int)(x-r); for (xx = -r; xx <= r; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y); } for (yy = 1; yy <= r; yy++) { x1 = sqrt(r2 - yy * yy); if ((y - yy >= 0) && (y - yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y - yy)+3*(int)(x-x1); for (xx = -x1; xx <= x1; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y - yy); } if ((y + yy >= 0) && (y + yy < Image->Bitmap->Height)) { P = Image->Bitmap->GetScanLine(y + yy)+3*(int)(x-x1); for (xx = -x1; xx <= x1; xx++, P+=3) { if ((x + xx >= 0) && (x + xx < Image->Bitmap->Width)) { SetPixel24(P, color); } } Image->Bitmap->PutScanLine(y + yy); } } } } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::calc_scrape_position(int size, int i, int &sx, int &sy, int &ex, int &ey) { int lx, ly; double theta, st, ct; lx = Lex - Lsx; ly = Ley - Lsy; theta = M_PI / 2.0 - atan2((double)ly, (double)lx); if (theta == M_PI / 2.0) { st = (StrToInt(eScale->Text) / 100.0) * size * i; sx = Lsx; sy = Lsy - st; ex = Lex; ey = Ley - st; } else if (theta == -M_PI / 2.0) { st = (StrToInt(eScale->Text) / 100.0) * size * i; sx = Lsx; sy = Lsy + st; ex = Lex; ey = Ley + st; } else { ct = cos(theta) * (StrToInt(eScale->Text) / 100.0) * size * i; st = sin(theta) * (StrToInt(eScale->Text) / 100.0) * size * i; sx = Lsx + ct; sy = Lsy - st; ex = Lex + ct; ey = Ley - st; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::scrape_pen(int size, COLORREF color) { int px, py, i, radius, sx, sy, ex, ey, count, t; double s; TPItemImage *Image = MainImageForm->iMainImage; RECT rect; int ls, rs; ls = size >> 1; rs = size - ls; t = (size + 8) / 8.0; radius = seBristles->Value / 2.0; if (((int) seBristles->Value % 2)==1) count = radius + 1; else count = radius; sx = Lsx; sy = Lsy; ex = Lex; ey = Ley; if (Image->Bitmap->StartScanLine() == false) goto fail; if (MainImageForm->MaskArea) { if (Image->Mask->StartScanLine() == false) goto fail; } for (i = -radius; i <= count - 1; i++) { calc_scrape_position(size, i, sx, sy, ex, ey); if (sx == ex) { if (sy < ey) { py = sy; while (py <= ey) { set_pen(sx, py, size, color); py = py + t; } } else { py = sy; while (py >= ey) { set_pen(sx, py, size, color); py = py - t; } } } else if (sy == ey) { if (sx < ex) { px = sx; while (px <= ex) { set_pen(px, sy, size, color); px = px + t; } } else { px = sx; while (px >= ex) { set_pen(px, sy, size, color); px = px - t; } } } else { s = double(ey - sy) / (ex - sx); if (fabs(s) > 1.0) { if (sy < ey) { py = sy; while (py <= ey) { px = sx + (py - sy) / s + 0.5; set_pen(px, py, size, color); py = py + t; } } else { py = sy; while (py >= ey) { px = sx + (py - sy) / s + 0.5; set_pen(px, py, size, color); py = py - t; } } } else { if (sx < ex) { px = sx; while (px <= ex) { py = sy + (px - sx) * s + 0.5; set_pen(px, py, size, color); px = px + t; } } else { px = sx; while (px >= ex) { py = sy + (px - sx) * s + 0.5; set_pen(px, py, size, color); px = px - t; } } } } rect.left = min(sx, ex) - ls; rect.top = min(sy, ey) - ls; rect.right = max(sx, ex) + rs; rect.bottom = max(sy, ey) + rs; Image->RectPaint(rect); } if (MainImageForm->MaskArea) Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); return; fail : Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::make_spread() { Byte s, e; char ColorIndex[2]; char ColorGap[1]; if (MainImageForm->Palette->UseColor + spread_grade < 252) { ColorIndex[0] = spread_start; ColorIndex[1] = spread_end; spread_start = MainImageForm->Palette->UseColor + 1; ColorGap[0] = spread_grade - 1; MainImageForm->Palette->MakeSpread(1, ColorIndex, 2, ColorGap, 1); spread_end = MainImageForm->Palette->UseColor; s = spread_start; e = spread_end; ::RepaintColor(); } else { eGrade->Text = "2"; spread_grade = 2; spread_start = s; spread_end = e; EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::InitWaterPanel(int i) { switch (i) { case 0: WaterType = PWT_SIMPLE; Label1->Caption = IDS_COLOR; Label2->Caption = IDS_EFFECT; ScrollBarColor->Position = 100*cr[PWT_SIMPLE]; ScrollBarEffect->Position = 100*or[PWT_SIMPLE]; Label5->Visible = false; spEditDensity->Visible = false; // Pen->PenDrawFunc = set_simple; SimpleShape->Brush->Color = clRed; SpatterShape->Brush->Color = clBlack; PureShape->Brush->Color = clBlack; DiffuseShape->Brush->Color = clBlack; break; case 1: WaterType = PWT_SPATTER; Label1->Caption = IDS_INSIDEDENSITY; Label2->Caption = IDS_OUTSIDEDENSITY; ScrollBarColor->Position = 100*cr[PWT_SPATTER]; ScrollBarEffect->Position = 100*or[PWT_SPATTER]; Label5->Visible = true; spEditDensity->Visible = true; // Pen->PenDrawFunc = set_spatter; SimpleShape->Brush->Color = clBlack; SpatterShape->Brush->Color = clRed; PureShape->Brush->Color = clBlack; DiffuseShape->Brush->Color = clBlack; break; case 2: WaterType = PWT_PURE; Label1->Caption = IDS_COLOR; Label2->Caption = IDS_EFFECT; ScrollBarColor->Position = 100*cr[PWT_PURE]; ScrollBarEffect->Position = 100*or[PWT_PURE]; Label5->Visible = false; spEditDensity->Visible = false; // Pen->PenDrawFunc = set_pure; SimpleShape->Brush->Color = clBlack; SpatterShape->Brush->Color = clBlack; PureShape->Brush->Color = clRed; DiffuseShape->Brush->Color = clBlack; break; case 3: WaterType = PWT_DIFFUSE; Label1->Caption = IDS_COLOR; Label2->Caption = IDS_SHAPE; ScrollBarColor->Position = 100*cr[PWT_DIFFUSE]; ScrollBarEffect->Position = 100*or[PWT_DIFFUSE]; Label5->Visible = false; spEditDensity->Visible = false; // Pen->PenDrawFunc = set_diffuse; SimpleShape->Brush->Color = clBlack; SpatterShape->Brush->Color = clBlack; PureShape->Brush->Color = clBlack; DiffuseShape->Brush->Color = clRed; break; } ColorLabel->Caption = ScrollBarColor->Position; EffectLabel->Caption = ScrollBarEffect->Position; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_water_func() { switch (WaterType) { case PWT_SIMPLE: if (MainImageForm->MaskArea) Pen->PenDrawFunc = set_simple_mask; else Pen->PenDrawFunc = set_simple_normal; break; case PWT_SPATTER: if (MainImageForm->MaskArea) Pen->PenDrawFunc = set_spatter_mask; else Pen->PenDrawFunc = set_spatter_normal; break; case PWT_PURE: if (MainImageForm->MaskArea) Pen->PenDrawFunc = set_pure_mask; else Pen->PenDrawFunc = set_pure_normal; break; case PWT_DIFFUSE: if (MainImageForm->MaskArea) Pen->PenDrawFunc = set_diffuse_mask; else Pen->PenDrawFunc = set_diffuse_normal; break; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_simple_normal(sPenDraw &draw) { int x, y; RGBQUAD rgb; double r = cr[PWT_SIMPLE]*0.2; x = draw.cp.x+draw.mq.x; y = draw.cp.y+draw.mq.y; if (x>=0 && xBitmap->Width && y>=0 && yBitmap->Height) { rgb = TColorToRGB((TColor)draw.Image->Bitmap->GetPixelColor(x, y)); rgb.rgbRed = rgb.rgbRed+(rgbWater.rgbRed-rgb.rgbRed)*r; rgb.rgbGreen = rgb.rgbGreen+(rgbWater.rgbGreen-rgb.rgbGreen)*r; rgb.rgbBlue = rgb.rgbBlue+(rgbWater.rgbBlue-rgb.rgbBlue)*r; draw.Image->Bitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_simple_mask(sPenDraw &draw) { Byte *mp; int x, y; RGBQUAD rgb; double r = cr[PWT_SIMPLE]*0.2; x = draw.cp.x+draw.mq.x; y = draw.cp.y+draw.mq.y; if (x>=0 && xBitmap->Width && y>=0 && yBitmap->Height) { mp = draw.Image->Mask->GetScanLine(y); if (mp[x >> 3] & (0x80 >> (x & 7))) return; rgb = TColorToRGB((TColor)draw.Image->Bitmap->GetPixelColor(x, y)); rgb.rgbRed = rgb.rgbRed+(rgbWater.rgbRed-rgb.rgbRed)*r; rgb.rgbGreen = rgb.rgbGreen+(rgbWater.rgbGreen-rgb.rgbGreen)*r; rgb.rgbBlue = rgb.rgbBlue+(rgbWater.rgbBlue-rgb.rgbBlue)*r; draw.Image->Bitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::spatter(int X, int Y) { int size, width; double r, ran, temp; double interval[5] = { 1.0, 0.75, 0.5, 0.25, 0.1 }; TPoint mp; width = Pen->BasicThick; size = Pen->Thick; r = (rand()%(size*3)); ran = (rand()%360)*(M_PI/180.0); mp = Point(X+r*cos(ran), Y+r*sin(ran)); temp = interval[(int)spEditDensity->Value-1]*size; if ((mp.x>X+temp || mp.xY+temp || mp.yThick = rand()%size+1; Pen->SetPixels(pd, mp.x, mp.y); Pen->BasicThick = width; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_spatter_normal(sPenDraw &draw) { int x, y; RGBQUAD rgb; double r; x = draw.cp.x+draw.mq.x; y = draw.cp.y+draw.mq.y; if (x>=0 && xBitmap->Width && y>=0 && yBitmap->Height) { rgb = TColorToRGB((TColor) draw.Image->Bitmap->GetPixelColor(x, y)); r = sqrt(draw.mq.x*draw.mq.x+draw.mq.y*draw.mq.y)/Pen->Thick*2.0; if (r<0.0) r = 0.0; else if (r>1.0) r = 1.0; r = cr[PWT_SPATTER]-(cr[PWT_SPATTER]-or[PWT_SPATTER])*r; rgb.rgbRed = rgb.rgbRed+(rgbWater.rgbRed-rgb.rgbRed)*r; rgb.rgbGreen = rgb.rgbGreen+(rgbWater.rgbGreen-rgb.rgbGreen)*r; rgb.rgbBlue = rgb.rgbBlue+(rgbWater.rgbBlue-rgb.rgbBlue)*r; draw.Image->Bitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_spatter_mask(sPenDraw &draw) { Byte *mp; int x, y; RGBQUAD rgb; double r; x = draw.cp.x+draw.mq.x; y = draw.cp.y+draw.mq.y; if (x>=0 && xBitmap->Width && y>=0 && yBitmap->Height) { mp = draw.Image->Mask->GetScanLine(y); if (mp[x >> 3] & (0x80 >> (x & 7))) return; rgb = TColorToRGB((TColor) draw.Image->Bitmap->GetPixelColor(x, y)); r = sqrt(draw.mq.x*draw.mq.x+draw.mq.y*draw.mq.y)/Pen->Thick*2.0; if (r<0.0) r = 0.0; else if (r>1.0) r = 1.0; r = cr[PWT_SPATTER]-(cr[PWT_SPATTER]-or[PWT_SPATTER])*r; rgb.rgbRed = rgb.rgbRed+(rgbWater.rgbRed-rgb.rgbRed)*r; rgb.rgbGreen = rgb.rgbGreen+(rgbWater.rgbGreen-rgb.rgbGreen)*r; rgb.rgbBlue = rgb.rgbBlue+(rgbWater.rgbBlue-rgb.rgbBlue)*r; draw.Image->Bitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_pure_normal(sPenDraw &draw) { int x, y; COLORREF c; double rr, hls[2][3]; RGBQUAD rgb[3]; x = draw.cp.x+draw.mq.x; y = draw.cp.y+draw.mq.y; if (x>=0 && xBitmap->Width && y>=0 && yBitmap->Height) { c = draw.Image->Bitmap->GetPixelColor(draw.fp.x, draw.fp.y); rgb[1] = TColorToRGB((TColor)c); TColor2HLS((TColor)c, hls[1][0], hls[1][1], hls[1][2]); c = draw.Image->Bitmap->GetPixelColor(x, y); rgb[0] = TColorToRGB((TColor)c); TColor2HLS((TColor)c, hls[0][0], hls[0][1], hls[0][2]); if (hls[0][2]==0.0 && hls[0][1]==1.0) { rr = cr[PWT_PURE]; } else { rr = (1.0-hls[0][1])*cr[PWT_PURE]; } rgb[2].rgbRed = rgb[0].rgbRed+(rgb[1].rgbRed-rgb[0].rgbRed)*rr; rgb[2].rgbGreen = rgb[0].rgbGreen+(rgb[1].rgbGreen-rgb[0].rgbGreen)*rr; rgb[2].rgbBlue = rgb[0].rgbBlue+(rgb[1].rgbBlue-rgb[0].rgbBlue)*rr; draw.Image->Bitmap->PutPixelColor(x, y, RGBToTColor(rgb[2])); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_pure_mask(sPenDraw &draw) { Byte *mp; int x, y; COLORREF c; double rr, hls[2][3]; RGBQUAD rgb[3]; x = draw.cp.x+draw.mq.x; y = draw.cp.y+draw.mq.y; if (x>=0 && xBitmap->Width && y>=0 && yBitmap->Height) { mp = draw.Image->Mask->GetScanLine(y); if (mp[x >> 3] & (0x80 >> (x & 7))) return; c = draw.Image->Bitmap->GetPixelColor(draw.fp.x, draw.fp.y); rgb[1] = TColorToRGB((TColor)c); TColor2HLS((TColor)c, hls[1][0], hls[1][1], hls[1][2]); c = draw.Image->Bitmap->GetPixelColor(x, y); rgb[0] = TColorToRGB((TColor)c); TColor2HLS((TColor)c, hls[0][0], hls[0][1], hls[0][2]); if (hls[0][2]==0.0 && hls[0][1]==1.0) { rr = cr[PWT_PURE]; } else { rr = (1.0-hls[0][1])*cr[PWT_PURE]; } rgb[2].rgbRed = rgb[0].rgbRed+(rgb[1].rgbRed-rgb[0].rgbRed)*rr; rgb[2].rgbGreen = rgb[0].rgbGreen+(rgb[1].rgbGreen-rgb[0].rgbGreen)*rr; rgb[2].rgbBlue = rgb[0].rgbBlue+(rgb[1].rgbBlue-rgb[0].rgbBlue)*rr; draw.Image->Bitmap->PutPixelColor(x, y, RGBToTColor(rgb[2])); } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_diffuse_normal(sPenDraw &draw) { RGBQUAD rgb; int x, y, temp; bool sw = false; double r, ratio, radius; x = draw.cp.x+draw.mq.x; y = draw.cp.y+draw.mq.y; if (x>=0 && xBitmap->Width && y>=0 && yBitmap->Height) { radius = Pen->Thick/4.0; ratio = sqrt(draw.mq.x*draw.mq.x+draw.mq.y*draw.mq.y)/radius; if (ratio<0.0) ratio = 0.0; else if (ratio>2.0) ratio = 2.0; if (ratio>1.75) { temp = rand()%9; if (temp<4) { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>1.5 && ratio<=1.75) { temp = rand()%8; if (temp<3) { sw = true; r = ratio/1.1*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>1.25 && ratio<=1.5) { temp = rand()%7; if (temp<3) { sw = true; r = ratio/1.2*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>1.0 && ratio<=1.25) { temp = rand()%6; if (temp<3) { sw = true; r = ratio/1.3*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>0.75 && ratio<=1.0) { temp = rand()%5; if (temp<3) { sw = true; r = ratio/1.4*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>0.5 && ratio<=0.75) { temp = rand()%4; if (temp<2) { sw = true; r = ratio/1.5*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>0.25 && ratio<=0.5) { temp = rand()%3; if (temp<2) { sw = true; r = ratio/1.6*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } if (sw) { rgb = TColorToRGB((TColor)draw.Image->Bitmap->GetPixelColor(x, y)); if (r<0.0) r = 0.0; else if (r>(1.5+or[PWT_DIFFUSE])*0.5) r = 1.0; r = 0.2*cr[PWT_DIFFUSE]*(2.0-r); rgb.rgbRed = rgb.rgbRed+(rgbWater.rgbRed-rgb.rgbRed)*r; rgb.rgbGreen = rgb.rgbGreen+(rgbWater.rgbGreen-rgb.rgbGreen)*r; rgb.rgbBlue = rgb.rgbBlue+(rgbWater.rgbBlue-rgb.rgbBlue)*r; draw.Image->Bitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::set_diffuse_mask(sPenDraw &draw) { Byte *mp; RGBQUAD rgb; int x, y, temp; bool sw = false; double r, ratio, radius; x = draw.cp.x+draw.mq.x; y = draw.cp.y+draw.mq.y; if (x>=0 && xBitmap->Width && y>=0 && yBitmap->Height) { mp = draw.Image->Mask->GetScanLine(y); if (mp[x >> 3] & (0x80 >> (x & 7))) return; radius = Pen->Thick/4.0; ratio = sqrt(draw.mq.x*draw.mq.x+draw.mq.y*draw.mq.y)/radius; if (ratio<0.0) ratio = 0.0; else if (ratio>2.0) ratio = 2.0; if (ratio>1.75) { temp = rand()%9; if (temp<4) { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>1.5 && ratio<=1.75) { temp = rand()%8; if (temp<3) { sw = true; r = ratio/1.1*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>1.25 && ratio<=1.5) { temp = rand()%7; if (temp<3) { sw = true; r = ratio/1.2*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>1.0 && ratio<=1.25) { temp = rand()%6; if (temp<3) { sw = true; r = ratio/1.3*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>0.75 && ratio<=1.0) { temp = rand()%5; if (temp<3) { sw = true; r = ratio/1.4*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>0.5 && ratio<=0.75) { temp = rand()%4; if (temp<2) { sw = true; r = ratio/1.5*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else if (ratio>0.25 && ratio<=0.5) { temp = rand()%3; if (temp<2) { sw = true; r = ratio/1.6*or[PWT_DIFFUSE]; } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } } else { sw = true; r = ratio*or[PWT_DIFFUSE]; } if (sw) { rgb = TColorToRGB((TColor)draw.Image->Bitmap->GetPixelColor(x, y)); if (r<0.0) r = 0.0; else if (r>(1.5+or[PWT_DIFFUSE])*0.5) r = 1.0; r = 0.2*cr[PWT_DIFFUSE]*(2.0-r); rgb.rgbRed = rgb.rgbRed+(rgbWater.rgbRed-rgb.rgbRed)*r; rgb.rgbGreen = rgb.rgbGreen+(rgbWater.rgbGreen-rgb.rgbGreen)*r; rgb.rgbBlue = rgb.rgbBlue+(rgbWater.rgbBlue-rgb.rgbBlue)*r; draw.Image->Bitmap->PutPixelColor(x, y, RGBToTColor(rgb)); } } } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::SetFont() { SetSmallFont(Font); SetSmallFont(lSpread->Font); SetSmallFont(lColor->Font); SetSmallFont(lBristles->Font); SetSmallFont(lScale->Font); SetSmallFont(lDensity->Font); SetSmallFont(spreadgrade->Font); SetSmallFont(lGrade->Font); SetSmallFont(lSelectDraw->Font); SetSmallFont(Label1->Font); SetSmallFont(Label2->Font); SetSmallFont(Label5->Font); SetSmallFont(Label19->Font); SetSmallFont(Label20->Font); SetSmallFont(Label17->Font); SetSmallFont(Label43->Font); SetSmallFont(Label44->Font); SetSmallFont(Label45->Font); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::InitType(TPenType pt) { if (pt == PT_NORMAL) { sbNormal->Down = true; ScrapePanel->Visible = false; DensPanel->Visible = false; shNormal->Pen->Color = clRed; shNormal->Brush->Color = clRed; shAirBrush->Pen->Color = clBlack; shAirBrush->Brush->Color = clBlack; shCrayon->Pen->Color = clBlack; shCrayon->Brush->Color = clBlack; shWater->Pen->Color = clBlack; shWater->Brush->Color = clBlack; shScratch->Pen->Color = clBlack; shScratch->Brush->Color = clBlack; shMask->Pen->Color = clBlack; shMask->Brush->Color = clBlack; if (MainImageForm) MainImageForm->SetMaskShow(false); } else if (pt == PT_AIR) { sbAirBrush->Down = true; shNormal->Pen->Color = clBlack; shNormal->Brush->Color = clBlack; shAirBrush->Pen->Color = clRed; shAirBrush->Brush->Color = clRed; shCrayon->Pen->Color = clBlack; shCrayon->Brush->Color = clBlack; shWater->Pen->Color = clBlack; shWater->Brush->Color = clBlack; shScratch->Pen->Color = clBlack; shScratch->Brush->Color = clBlack; shMask->Pen->Color = clBlack; shMask->Brush->Color = clBlack; if (MainImageForm) MainImageForm->SetMaskShow(false); } else if (pt == PT_CRAYON) { sbCrayon->Down = true; ScrapePanel->Visible = false; DensPanel->Visible = true; shNormal->Pen->Color = clBlack; shNormal->Brush->Color = clBlack; shAirBrush->Pen->Color = clBlack; shAirBrush->Brush->Color = clBlack; shCrayon->Pen->Color = clRed; shCrayon->Brush->Color = clRed; shWater->Pen->Color = clBlack; shWater->Brush->Color = clBlack; shScratch->Pen->Color = clBlack; shScratch->Brush->Color = clBlack; shMask->Pen->Color = clBlack; shMask->Brush->Color = clBlack; if (MainImageForm) MainImageForm->SetMaskShow(false); } else if (pt == PT_WATER) { sbWater->Down = true; shNormal->Pen->Color = clBlack; shNormal->Brush->Color = clBlack; shAirBrush->Pen->Color = clBlack; shAirBrush->Brush->Color = clBlack; shCrayon->Pen->Color = clBlack; shCrayon->Brush->Color = clBlack; shWater->Pen->Color = clRed; shWater->Brush->Color = clRed; shScratch->Pen->Color = clBlack; shScratch->Brush->Color = clBlack; shMask->Pen->Color = clBlack; shMask->Brush->Color = clBlack; if (MainImageForm) MainImageForm->SetMaskShow(false); pd.Image = MainImageForm->iMainImage; } else if (pt == PT_SCRAPE) { sbScratch->Down = true; DensPanel->Visible = false; ScrapePanel->Visible = true; shNormal->Pen->Color = clBlack; shNormal->Brush->Color = clBlack; shAirBrush->Pen->Color = clBlack; shAirBrush->Brush->Color = clBlack; shCrayon->Pen->Color = clBlack; shCrayon->Brush->Color = clBlack; shWater->Pen->Color = clBlack; shWater->Brush->Color = clBlack; shScratch->Pen->Color = clRed; shScratch->Brush->Color = clRed; shMask->Pen->Color = clBlack; shMask->Brush->Color = clBlack; if (MainImageForm) MainImageForm->SetMaskShow(false); } else if (pt == PT_MASK) { sbMask->Down = true; shNormal->Pen->Color = clBlack; shNormal->Brush->Color = clBlack; shAirBrush->Pen->Color = clBlack; shAirBrush->Brush->Color = clBlack; shCrayon->Pen->Color = clBlack; shCrayon->Brush->Color = clBlack; shWater->Pen->Color = clBlack; shWater->Brush->Color = clBlack; shScratch->Pen->Color = clBlack; shScratch->Brush->Color = clBlack; shMask->Pen->Color = clRed; shMask->Brush->Color = clRed; TPItemImage *ti = MainImageForm->iMainImage; RECT r; if (ti->Mask==NULL) { if (ti->Bitmap->Width<=0 || ti->Bitmap->Height<=0) goto fail; ti->Mask = new TTexpiaBitmap; if (ti->Mask==NULL) goto fail; if (ti->Bitmap->BitsPerPixel == 8) { if (ti->Mask->Create(ti->Bitmap->Width, ti->Bitmap->Height, 8)==false) goto fail; } else { if (ti->Mask->Create(ti->Bitmap->Width, ti->Bitmap->Height, 1)==false) goto fail; } SetRect(&r, 0, 0, ti->Bitmap->Width, ti->Bitmap->Height); ti->Mask->FillRect(r, 0); } MainImageForm->MaskArea = true; if (MainImageForm) MainImageForm->SetMaskShow(true); } Type = pt; MenuClick(NULL); MainImageForm->PenChange(); ::RepaintImage(); return; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::SelectColor(Byte Color) { switch (Type) { case PT_AIR : AddAirBrushColor(Color); break; default : if (spread_sw[4] == 0) { if (spread_grade < 2) spread_grade = 2; if (252 - MainImageForm->Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - MainImageForm->Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); if (aspread) { if (spread_pos == 0) { spread_pos = 1; spread_start = Color; shFirst->Brush->Color = MainImageForm->Palette->Color[spread_start]; shFirst->Pen->Color = clBlack; shSecond->Pen->Color = clRed; } else if (spread_pos == 1) { spread_pos = 0; spread_end = Color; shSecond->Brush->Color = MainImageForm->Palette->Color[spread_end]; shFirst->Pen->Color = clRed; shSecond->Pen->Color = clBlack; } } } else { if (acolor == 1) { Selector->AddColor(Color); } } } PenShape->Pen->Color = MainImageForm->Palette->Color[Color]; PenShape->Brush->Color = MainImageForm->Palette->Color[Color]; PenWidthPanel->Color = MainImageForm->Palette->Color[BackgroundIndex]; } //--------------------------------------------------------------------------- bool __fastcall TPenManagerForm::mask_fill_read_8(Byte *p, int x) { return p[x] == 0x00; } //---------------------------------------------------------------------------- void __fastcall TPenManagerForm::mask_fill_save_8(Byte *p, int x) { p[x] = 0x0F; } //--------------------------------------------------------------------------- bool __fastcall TPenManagerForm::mask_fill_read_24(Byte *p, int x) { return (p[x >> 3] & (0x80 >> (x & 7))) == 0; } //---------------------------------------------------------------------------- void __fastcall TPenManagerForm::mask_fill_save_24(Byte *p, int x) { p[x >> 3] |= 0x80 >> (x & 7); } //--------------------------------------------------------------------------- bool __fastcall TPenManagerForm::mask_fill_delete_read_8(Byte *p, int x) { return p[x] == 0x0F; } //---------------------------------------------------------------------------- void __fastcall TPenManagerForm::mask_fill_delete_save_8(Byte *p, int x) { p[x] = 0x00; } //--------------------------------------------------------------------------- bool __fastcall TPenManagerForm::mask_fill_delete_read_24(Byte *p, int x) { return p[x >> 3] & (0x80 >> (x & 7)); } //---------------------------------------------------------------------------- void __fastcall TPenManagerForm::mask_fill_delete_save_24(Byte *p, int x) { p[x >> 3] &= ~(0x80 >> (x & 7)); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpecialMouseDown(TMouseButton Button, TShiftState Shift, int X, int Y) { COLORREF spc; int pw; TRect r; int ix, iy; TPItemImage *Image = MainImageForm->iMainImage; if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { if (acolor == 1) { 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; } } } } else if (Button == mbLeft) { if (acolor != 1) { #ifndef KNIT int ZoomIn = Image->ZoomIn; int ZoomOut = Image->ZoomOut; int PenSize = PenManagerForm->Pen->Thick; r.Left = Image->PositionX - (PenSize + 30); // 30 is Caption Height if (r.Left<0) r.Left = 0; r.Top = Image->PositionY - (PenSize + 30); if (r.Top<0) r.Top = 0; r.Right = r.Left+Image->Width*ZoomOut/ZoomIn + PenSize + 60; if (r.Right>Image->Bitmap->Width) r.Right = Image->Bitmap->Width; r.Bottom = r.Top+Image->Height*ZoomOut/ZoomIn + PenSize + 60; if (r.Bottom>Image->Bitmap->Height) r.Bottom = Image->Bitmap->Height; #else r = Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height); #endif switch (Type) { case PT_NORMAL: #ifdef KNIT if ((DesignMode != D_YARN) && (Pen->Brush == 1 || aspread)) return; #endif #ifdef CARPET MainImageForm->UndoSave(UK_PATTERN, r, false); #else MainImageForm->UndoSave(UK_PATTERN, r); #endif BtnClick = true; Lsx = X; Lsy = Y; if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = Tablet->prsNew; } FPointPressurePen(Lsx, Lsy, Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else { Lex = Lsx; Ley = Lsy; MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF(Image->Bitmap->BitsPerPixel)); } } else if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = Tablet->prsNew; } pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } break; case PT_AIR: #ifdef CARPET MainImageForm->UndoSave(UK_PATTERN, r, false); #else MainImageForm->UndoSave(UK_PATTERN, r); #endif BtnClick = true; Lsx = X; Lsy = Y; Lex = Lsx; Ley = Lsy; line_airbrush_pen(); break; case PT_CRAYON: #ifdef CARPET MainImageForm->UndoSave(UK_PATTERN, r, false); #else MainImageForm->UndoSave(UK_PATTERN, r); #endif BtnClick = true; Lsx = X; Lsy = Y; if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = Tablet->prsNew; } FPointPressurePen(Lsx, Lsy, Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; FPointPressurePen(Lsx, Lsy, Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = Tablet->prsNew; } pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } break; case PT_WATER: #ifdef CARPET MainImageForm->UndoSave(UK_PATTERN, r, false); #else MainImageForm->UndoSave(UK_PATTERN, r); #endif set_water_func(); if (MainImageForm->MaskArea) MainImageForm->iMainImage->Mask->StartScanLine(); if (WaterType==PWT_SPATTER) { rgbWater = PaletteForm->DIB256Palette->ForegroundRgb; spatter(X, Y); } else { if (WaterType!=PWT_PURE) { rgbWater = PaletteForm->DIB256Palette->ForegroundRgb; } Pen->MoveRatio = WaterType==PWT_SIMPLE || WaterType==PWT_PURE ? 3+or[WaterType]*7 : 8; if (WaterType==PWT_DIFFUSE) Pen->ThickRatio = 1.0+or[PWT_DIFFUSE]; Pen->MoveTo(pd, X, Y); } BtnClick = true; break; case PT_SCRAPE: #ifdef CARPET MainImageForm->UndoSave(UK_PATTERN, r, false); #else MainImageForm->UndoSave(UK_PATTERN, r); #endif BtnClick = true; Lsx = X; Lsy = Y; Lex = Lsx; Ley = Lsy; break; case PT_MASK: if (chFill->Checked) { POINT p = Point(X, Y); RECT rect; #ifdef CARPET MainImageForm->UndoSave(UK_MASK, false); #else MainImageForm->UndoSave(UK_MASK); #endif if (MainImageForm->iMainImage->Bitmap->BitsPerPixel==8) { if (chDelete->Checked) { Image->Mask->FloodFill(p, mask_fill_delete_read_8, mask_fill_delete_save_8, rect); } else { Image->Mask->FloodFill(p, mask_fill_read_8, mask_fill_save_8, rect); } } else { if (chDelete->Checked) { Image->Mask->FloodFill(p, mask_fill_delete_read_24, mask_fill_delete_save_24, rect); } else { Image->Mask->FloodFill(p, mask_fill_read_24, mask_fill_save_24, rect); } } Image->Repaint(); } else { #ifdef CARPET MainImageForm->UndoSave(UK_MASK, r, false); #else MainImageForm->UndoSave(UK_MASK, r); #endif BtnClick = true; Lsx = X; Lsy = Y; if (Pen->Brush == 0) { Lex = Lsx; Ley = Lsy; MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF(Image->Bitmap->BitsPerPixel)); } else if (Pen->Brush == 1) { spc = PaletteForm->DIB256Palette->ChoiceIndex; pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; FPointPressurePen(Lsx, Lsy, pw, spc); o_size = pw; o_color = spc; } } break; } } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpecialMouseMove(TShiftState Shift, int X, int Y) { COLORREF spc; int pw; RGBQUAD m_rgb[3]; TPItemImage *Image = MainImageForm->iMainImage; if (acolor != 1) { switch (Type) { case PT_NORMAL: if (BtnClick) { #ifdef KNIT // if ((DesignMode != D_YARN) && (Pen->Brush == 1 || aspread)) return; // 7.41 if ((DesignMode != D_YARN) && ((MainImageForm->Arrange->Dmark.set&0x0f)>1)) return; #endif Lex = X; Ley = Y; if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = Tablet->prsNew; } line_pressure_pen(Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else { MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF(Image->Bitmap->BitsPerPixel)); } } else if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = Tablet->prsNew; } pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } } Lsx = Lex; Lsy = Ley; } break; case PT_AIR: if (BtnClick) { Lex = X; Ley = Y; line_airbrush_pen(); Lsx = Lex; Lsy = Ley; } break; case PT_CRAYON: if (BtnClick) { Lex = X; Ley = Y; if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = Tablet->prsNew; } line_pressure_pen(Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; line_pressure_pen(Pen->Thick, spc); o_size = Pen->Thick; o_color = spc; } } else if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { spc = Tablet->prsNew; } pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } } else { spc = PaletteForm->DIB256Palette->ChoiceIndex; pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } } Lsx = Lex; Lsy = Ley; } break; case PT_WATER: if (BtnClick) { if (abs(X-pd.fp.x)>Pen->BasicThick || abs(Y-pd.fp.y)>Pen->BasicThick) { if (WaterType==PWT_SPATTER) { spatter(X, Y); } else { Pen->LineTo(pd, X, Y); } } } break; case PT_SCRAPE: if (BtnClick) { Lex = X; Ley = Y; if ((Lsx - 5 > Lex) || (Lsx + 5 < Lex) || (Lsy - 5 > Ley) || (Lsy + 5 < Ley)) { if (Pen->Brush == 1) { if (aspread) { if (spread_sw[4] == 1) { pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { m_rgb[0] = MainImageForm->Palette->ColorData[spread_start]->RGB; m_rgb[1] = MainImageForm->Palette->ColorData[spread_end]->RGB; m_rgb[2].rgbRed = m_rgb[0].rgbRed+Tablet->prsNew*(m_rgb[1].rgbRed-m_rgb[0].rgbRed)/Tablet->MaxNPressure; m_rgb[2].rgbGreen = m_rgb[0].rgbGreen+Tablet->prsNew*(m_rgb[1].rgbGreen-m_rgb[0].rgbGreen)/Tablet->MaxNPressure; m_rgb[2].rgbBlue = m_rgb[0].rgbBlue+Tablet->prsNew*(m_rgb[1].rgbBlue-m_rgb[0].rgbBlue)/Tablet->MaxNPressure; spc = RGBToTColor(m_rgb[2]); } scrape_pen(pw, spc); } } else { pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; scrape_pen(pw, PaletteForm->DIB256Palette->GetFGCOLORREF(Image->Bitmap->BitsPerPixel)); } } else if (Pen->Brush == 0) { if (aspread) { if (spread_sw[4] == 1) { if (Image->Bitmap->BitsPerPixel==8) { spc = spread_start + double(spread_grade - 1) * Tablet->prsNew / Tablet->MaxNPressure + 0.5; } else { m_rgb[0] = MainImageForm->Palette->ColorData[spread_start]->RGB; m_rgb[1] = MainImageForm->Palette->ColorData[spread_end]->RGB; m_rgb[2].rgbRed = m_rgb[0].rgbRed+Tablet->prsNew*(m_rgb[1].rgbRed-m_rgb[0].rgbRed)/Tablet->MaxNPressure; m_rgb[2].rgbGreen = m_rgb[0].rgbGreen+Tablet->prsNew*(m_rgb[1].rgbGreen-m_rgb[0].rgbGreen)/Tablet->MaxNPressure; m_rgb[2].rgbBlue = m_rgb[0].rgbBlue+Tablet->prsNew*(m_rgb[1].rgbBlue-m_rgb[0].rgbBlue)/Tablet->MaxNPressure; spc = RGBToTColor(m_rgb[2]); } scrape_pen(Pen->Thick, spc); } } else { scrape_pen(Pen->Thick, PaletteForm->DIB256Palette->GetFGCOLORREF(Image->Bitmap->BitsPerPixel)); } } Lsx = Lex; Lsy = Ley; } } break; case PT_MASK: if (BtnClick) { Lex = X; Ley = Y; if (Pen->Brush == 0) { MainImageForm->line_pen(Lsx, Lsy, Lex, Ley, PaletteForm->DIB256Palette->GetFGCOLORREF(Image->Bitmap->BitsPerPixel)); } else if (Pen->Brush == 1) { spc = PaletteForm->DIB256Palette->ChoiceIndex; pw = double(Pen->Thick - 1) * Tablet->prsNew / Tablet->MaxNPressure + 1.0; line_pressure_pen(pw, spc); o_size = pw; o_color = spc; } Lsx = Lex; Lsy = Ley; } break; } } else if (acolor == 1) { if (step == 1) { if (IsDraw) MainImageForm->DrawRectangleLocate(Temp); Temp.right = X; Temp.bottom = Y; MainImageForm->DrawRectangleLocate(Temp); IsDraw = true; } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpecialMouseUp(TMouseButton Button, TShiftState Shift, int X, int Y) { switch (Type) { case PT_NORMAL: case PT_AIR: case PT_CRAYON: case PT_SCRAPE: case PT_WATER: case PT_MASK: BtnClick = false; } if (Type == PT_WATER && MainImageForm->MaskArea) MainImageForm->iMainImage->Mask->StopScanLine(); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpecialPaint() { IsDraw = false; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::AddAirBrushColor(Byte SetColor) { TColorList *pcolor, *p; if (AirType == PAT_SINGLE) { AirSelectColor->Brush->Color = MainImageForm->Palette->Color[SetColor]; } else if (AirType == PAT_MULTI) { if (AirColorList->Count < 18) { pcolor = new TColorList; pcolor->color = SetColor; pcolor->modify = false; for (int i = 0; i < AirColorList->Count; i++) { p = (TColorList *) AirColorList->Items[i]; if (p->color == pcolor->color) { delete pcolor; return; } } AirColorList->Add(pcolor); ChangeAirColorPalette(AirColorList->Count - 1); } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::WorkAreaChange() { RGBQUAD rgb[256]; int Tx, Ty; TPItemImage *Image = MainImageForm->iMainImage; if (Type == PT_AIR) { // by kjs workarea change--> PenManagerForm change if (AirType == PAT_PATTERN) { if (MainImageForm->WorkArea->Mask) { sbPattern->Enabled = true; Tx = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; Ty = MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top; if (Image->Bitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (!(Image1->Bitmap->Create(Tx, Ty, 8, rgb))) goto fail; } else { if (!(Image1->Bitmap->Create(Tx, Ty, 24))) goto fail; } Image1->Bitmap->CopyFromRect(Image->Bitmap, MainImageForm->WorkArea->Range.left, MainImageForm->WorkArea->Range.top, SRCCOPY); Image1->Repaint(); } else { sbSingle->Down = true; AirFunctionClick(sbSingle); sbPattern->Enabled = false; } } else { if (AirPanel->Visible) { if (MainImageForm->WorkArea->Mask) sbPattern->Enabled = true; else sbPattern->Enabled = false; } } } /* if (AirType == PAT_PATTERN) { // Source Code.... if (MainImageForm->WorkArea->Mask) { sbPattern->Enabled = true; Tx = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; Ty = MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top; if (Image->Bitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (!(Image1->Bitmap->Create(Tx, Ty, 8, rgb))) goto fail; } else { if (!(Image1->Bitmap->Create(Tx, Ty, 24))) goto fail; } Image1->Bitmap->CopyFromRect(Image->Bitmap, MainImageForm->WorkArea->Range.left, MainImageForm->WorkArea->Range.top, SRCCOPY); Image1->Repaint(); } else { sbSingle->Down = true; AirFunctionClick(sbSingle); sbPattern->Enabled = false; } } */ return; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::iMainImageChange() { if (IsDraw) IsDraw = false; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::SetColor(TPalette *Palette) { Selector->SetPalette(Palette); Selector->Invalid(); shFirst->Update(); shSecond->Update(); PenShape->Pen->Color = Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; PenShape->Brush->Color = Palette->Color[PaletteForm->DIB256Palette->ChoiceIndex]; PenWidthPanel->Color = Palette->Color[BackgroundIndex]; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::SpreadChange(TPalette *Palette) { Byte ChoiceIndex = PaletteForm->DIB256Palette->ChoiceIndex; TColor ChoiceColor = Palette->Color[ChoiceIndex]; Selector->Initial(); Selector->SetPalette(Palette); spread_grade = 2; eGrade->Text = "2"; if (252 - Palette->UseColor - 1 > 70) interval = 70; else interval = 252 - Palette->UseColor - 1; lGrade->Caption = Format("(2 - %d)", OPENARRAY(TVarRec, (interval))); spread_start = ChoiceIndex; shFirst->Brush->Color = ChoiceColor; spread_end = ChoiceIndex; shSecond->Brush->Color = ChoiceColor; lSelectDraw->Caption = IDS_SELECTCOLOR; spread_sw[4] = 0; spread_pos = 0; shFirst->Pen->Color = clRed; shSecond->Pen->Color = clBlack; PenShape->Pen->Color = ChoiceColor; PenShape->Brush->Color = ChoiceColor; PenWidthPanel->Color = Palette->Color[BackgroundIndex]; AirSelectColor->Brush->Color = ChoiceColor; TShape *s = 0; TColorList *Temp = 0; for (int i = 1; i <= AirColorList->Count; i++) { Temp = (TColorList *)(AirColorList->Items[i - 1]); s = (TShape *)(FindComponent("shAirColor" + AnsiString(i))); s->Brush->Color = Palette->Color[Temp->color]; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::PenShapeChange(int value) { PenShape->Pen->Color = PaletteForm->DIB256Palette->Palette->Color[value]; PenShape->Brush->Color = PaletteForm->DIB256Palette->Palette->Color[value]; } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::FormChange(TPalette *Palette) { MainImageForm->PenChange(); if (Type == PT_AIR) { if (MainImageForm->WorkArea->Mask) { sbPattern->Enabled = true; } else { sbPattern->Enabled = false; } EtcPanel->Visible = false; AirPanel->Visible = true; if (AirType == PAT_SINGLE) { MultiPanel->Visible = false; PatternPanel->Visible = false; SinglePanel->Visible = true; AirPanel->Height = SinglePanel->Top + SinglePanel->Height - 1; } else if (AirType == PAT_MULTI) { SinglePanel->Visible = false; PatternPanel->Visible = false; MultiPanel->Visible = true; AirPanel->Height = MultiPanel->Top + MultiPanel->Height - 1; } else if (AirType == PAT_PATTERN) { SinglePanel->Visible = false; MultiPanel->Visible = false; PatternPanel->Visible = true; AirPanel->Height = PatternPanel->Top + PatternPanel->Height - 1; } ClientHeight = AirPanel->Top + AirPanel->Height - 1; MenuSW = true; btnUp->Visible = true; btnDown->Visible = false; } else if (Type == PT_MASK) { TPItemImage *ti = MainImageForm->iMainImage; RECT r; if (ti->Mask==NULL) { if (ti->Bitmap->Width<=0 || ti->Bitmap->Height<=0) goto fail; ti->Mask = new TTexpiaBitmap; if (ti->Mask==NULL) goto fail; if (ti->Bitmap->BitsPerPixel == 8) { if (ti->Mask->Create(ti->Bitmap->Width, ti->Bitmap->Height, 8) == false) goto fail; } else { if (ti->Mask->Create(ti->Bitmap->Width, ti->Bitmap->Height, 1) == false) goto fail; } SetRect(&r, 0, 0, ti->Bitmap->Width, ti->Bitmap->Height); ti->Mask->FillRect(r, 0); } } WorkAreaChange(); return; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::sbClearClick(TObject *Sender) { RECT r; SetRect(&r, 0, 0, MainImageForm->iMainImage->Bitmap->Width, MainImageForm->iMainImage->Bitmap->Height); MainImageForm->iMainImage->Mask->FillRect(r, 0x00); ::RepaintImage(); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::chDeleteClick(TObject *Sender) { if (MainImageForm->iMainImage->Bitmap->BitsPerPixel==8) { MainImageForm->OnSetHLine = MainImageForm->SetHLineMask8; if (chDelete->Checked) { MainImageForm->MaskPixel = 0x00; } else { MainImageForm->MaskPixel = 0x0F; } } else { if (chDelete->Checked) { MainImageForm->OnSetHLine = MainImageForm->SetHLineMaskDelete24; MainImageForm->MaskPixel = 0x00; } else { MainImageForm->OnSetHLine = MainImageForm->SetHLineMask24; MainImageForm->MaskPixel = 0x80; } } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::chReversalClick(TObject *Sender) { int x, y, w, h; Byte *bp = NULL, m; w = MainImageForm->iMainImage->Mask->Width; h = MainImageForm->iMainImage->Mask->Height; if ((MainImageForm->iMainImage->Mask->StartScanLine()) == false) goto fail; if (MainImageForm->iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; yiMainImage->Mask->GetScanLine(y); for (x=0; xiMainImage->Mask->PutScanLine(y); } } else { for (y=0; yiMainImage->Mask->GetScanLine(y); /* m = 0x80; for (x = 0; x < w; x++) { if (*bp & m) *bp &= ~m; else *bp |= m; if (m == 1) { m = 0x80; bp++; } else m >>= 1; } */ for (x=0; x>3] ^= (0x80>>(x&7)); } MainImageForm->iMainImage->Mask->PutScanLine(y); } } MainImageForm->iMainImage->Mask->StopScanLine(); MainImageForm->iMainImage->Repaint(); return; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::InitPenForm() { InitType(PT_NORMAL); sbNormal->Down = true; ClientHeight = FHeight; btnUp->Visible = false; btnDown->Visible = true; MenuSW = false; SpreadChange(MainImageForm->Palette); } //--------------------------------------------------------------------------- #ifdef KNIT void __fastcall TPenManagerForm::ChangeMode() { if (DesignMode == D_YARN){ sbNormal->Enabled = true; sbAirBrush->Enabled = true; sbCrayon->Enabled = true; sbWater->Enabled = false; sbScratch->Enabled = true; sbMask->Enabled = true; btnUp->Visible = true; cbPressure->Enabled = true; } else { sbNormal->Enabled = true; sbAirBrush->Enabled = false; sbCrayon->Enabled = false; sbWater->Enabled = false; sbScratch->Enabled = false; sbMask->Enabled = false; btnUp->Visible = false; cbPressure->Enabled = false; } } #endif //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::sePDotNumChange(TObject *Sender) { if (sePDotNum->Text.Length() > 0) { if (sePDotNum->Value > sePDotNum->MaxValue) sePDotNum->Value = sePDotNum->MaxValue; else if (sePDotNum->Value < sePDotNum->MinValue) sePDotNum->Value = sePDotNum->MinValue; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::sePNozzleChange(TObject *Sender) { if (sePNozzle->Text.Length() > 0) { if (sePNozzle->Value > sePNozzle->MaxValue) sePNozzle->Value = sePNozzle->MaxValue; else if (sePNozzle->Value < sePNozzle->MinValue) sePNozzle->Value = sePNozzle->MinValue; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::seMDotNumChange(TObject *Sender) { if (seMDotNum->Text.Length() > 0) { if (seMDotNum->Value > seMDotNum->MaxValue) seMDotNum->Value = seMDotNum->MaxValue; else if (seMDotNum->Value < seMDotNum->MinValue) seMDotNum->Value = seMDotNum->MinValue; } } //--------------------------------------------------------------------------- void __fastcall TPenManagerForm::seMNozzleChange(TObject *Sender) { if (seMNozzle->Text.Length() > 0) { if (seMNozzle->Value > seMNozzle->MaxValue) seMNozzle->Value = seMNozzle->MaxValue; else if (seMNozzle->Value < seMNozzle->MinValue) seMNozzle->Value = seMNozzle->MinValue; } } //---------------------------------------------------------------------------