//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "PatternRepeat.h" #include "FullView.h" #include "MainImage.h" #include "Palette.h" #include "PenManager.h" #include "StatusProgress.h" #include "Undo.h" #include "LogData.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TNumEdit" #pragma link "RzBckgnd" #pragma link "RzButton" #pragma link "RzCmboBx" #pragma link "RzRadChk" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_REGULAR StringTable[0] #define IDS_IRREGULAR StringTable[1] #define IDS_IMAGESPRAY StringTable[2] #define IDS_REGULAR1 StringTable[3] #define IDS_SELECTPOS StringTable[4] #define IDS_MIRROR StringTable[5] #define IDS_UPDOWN StringTable[6] #define IDS_MUPDOWN StringTable[7] #define IDS_IMAGESPRAY2 StringTable[8] #define IDS_IRREGULAR3 StringTable[9] #define IDS_CONTINUOUS StringTable[10] #define IDS_SHAPE StringTable[11] #define IDS_FREE StringTable[12] #define IDS_OBLIQUE StringTable[13] #define IDS_HV StringTable[14] #define IDS_RECTANGLE StringTable[15] #define IDS_ELLIPSE StringTable[16] #define IDS_CURVE StringTable[17] #define IDS_CIRCLE StringTable[18] #define IDS_CENTER StringTable[19] #define IDS_LEFT StringTable[20] #define IDS_RIGHT StringTable[21] #define IDS_BOTH StringTable[22] #define IDS_UNITDEG StringTable[23] #define IDS_COUNT StringTable[24] #define IDS_USECOUNT StringTable[25] // pen manager¿Í °°Àº ÀÌÀ¯·Î.. #define MAX_PEN_HALF_WIDTH 25 // 7.42 ¹öÀü¿¡¼­ ÀÌ °ªÀº 14 (¹°·Ð 7.41ÀÌÀü¿¡ Á¤ÇØÁø °ªÀ̰ÚÁö¸¸..) #define MAX_PEN_LEFT_CENTER 25 // 7.42 ¹öÀü¿¡¼­ ÀÌ °ªÀº 13 (ÀÌ °ªÀÌ ¿¡·¯¸¦ À¯¹ßÇßÁö¸¸ ¾î¶² ¿ëµµ·Î »ç¿ëµÇ¾ú´ÂÁö ¸ô¶ó defineÀ» µû·Î Çß´Ù) by celberus //--------------------------------------------------------------------------- TPatternRepeatForm *PatternRepeatForm; //--------------------------------------------------------------------------- __fastcall TPatternRepeatForm::TPatternRepeatForm(TComponent* Owner) : TForm(Owner) { hWnd = ((TWinControl *)Owner)->Handle; //=========================================================== StringTable.Create(DirectoryBin, Language, "PatternRepeat"); /* SetSmallFont(Font); SetSmallFont(Label4->Font); SetSmallFont(Label1->Font); SetSmallFont(Label2->Font); SetSmallFont(Label->Font); SetSmallFont(LabelUnit->Font); */ rzRegular->Caption = IDS_REGULAR; rzIrregular->Caption = IDS_IRREGULAR; rzImgSpray->Caption = IDS_IMAGESPRAY; rzckContinuous->Caption=IDS_CONTINUOUS; rzbtnRun->Caption = IDS_COMMON_RUN; rzbtnSelectPos->Caption = IDS_SELECTPOS; lbDirection->Caption = IDS_COMMON_DIRECTION; rzckComboDirection->Items->Clear(); rzckComboDirection->Items->Add(IDS_COMMON_NORMAL); rzckComboDirection->Items->Add(IDS_MIRROR); rzckComboDirection->Items->Add(IDS_UPDOWN); rzckComboDirection->Items->Add(IDS_MUPDOWN); lbShape->Caption = IDS_SHAPE; rzckShape->Items->Clear(); rzckShape->Items->Add(IDS_FREE); rzckShape->Items->Add(IDS_OBLIQUE); rzckShape->Items->Add(IDS_HV); rzckShape->Items->Add(IDS_RECTANGLE); rzckShape->Items->Add(IDS_CIRCLE); rzckShape->Items->Add(IDS_ELLIPSE); rzckShape->Items->Add(IDS_CURVE); rzckPosition->Items->Clear(); rzckPosition->Items->Add(IDS_CENTER); rzckPosition->Items->Add(IDS_LEFT); rzckPosition->Items->Add(IDS_RIGHT); rzckPosition->Items->Add(IDS_BOTH); rzckUnit->Caption = "Cm"; rzckCount->Caption = IDS_COUNT; Circle1->Caption = IDS_CIRCLE; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::FormCreate(TObject *Sender) { //Ellipse ¸¦ ±×¸± °æ¿ì Ãʱ⠸¶¿ì½º ´Ù¿î ½ÃÀÛÁÂÇ¥ ÀúÀå ¼³Á¤ ¿©ºÎ Ãʰ¡È­ //////////////// // ThreadList = new TList; // ¸®½ºÆ® ÀνºÅϽº »ý¼º check = false; /////////////// //=========================================================== rzbtnRun->Visible=false; rzckContinuous->Checked=false; COLOROVERFLOW = false; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::EditDotClick(TObject *Sender) { EditDot->SetFocus(); EditDot->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::EditCountClick(TObject *Sender) { EditCount->SetFocus(); EditCount->SelectAll(); } //--------------------------------------------------------------------------- //// PRIVATE METHOD /////////////////////////////////////////////////////// //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::InitData() { POINT *p = NULL; if (pstore) { while (pstore->Count>0) { p = (POINT *) pstore->Last(); pstore->Remove(p); if (p) { delete p; p = NULL; } } } TPoint_Deg *pd = NULL; if (pdstore) { while (pdstore->Count>0) { pd = (TPoint_Deg *) pdstore->Last(); pdstore->Remove(pd); if (pd) { delete pd; pd = NULL; } } } } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::EraseLine() { if(Shape != S_ELLIPSE) { MainImageForm->DrawFreeLineLocate (Point(0,0),0);///////by jeegeo } } //--------------------------------------------------------------------------- double __fastcall calculatelength(POINT sp, POINT ep) { int x, y; x = ep.x - sp.x; y = ep.y - sp.y; return sqrt (x*x + y*y); } //--------------------------------------------------------------------------- double __fastcall calculateangle(POINT sp, POINT ep) { double dx, dy, deg; dx = ep.x - sp.x; dy = ep.y - sp.y; if (dx) deg = atanl((double)dy/dx); else { if (dy>0) deg = M_PI_2; else deg = -M_PI_2; } deg = 18000 * deg/M_PI; return deg; } //--------------------------------------------------------------------------- int __fastcall TPatternRepeatForm::GetLimitDot(TList *store) { BEGIN_LOG(""); //by linuxjun for ºñÁî °³¼ö if(rzckCount->Checked==false){ if (EditDot->Value == 0) { END_LOG; return LimitDot; }else{ EditDotChange(NULL); END_LOG; return LimitDot; } }else{ double sumlength1, sumlength2; if (Shape == S_ELLIPSE) { int a = abs(Pos[0].x - Pos[1].x)/2; int b = abs(Pos[0].y - Pos[1].y)/2; sumlength1 = M_PI * (3*a + 3*b - sqrt((a+3*b)*(3*a+b))); //Ÿ¿øÀÇ µÑ·¹ ±Ù»ç½Ä } // return LimitDot; // EditCountChange(NULL); /////////////////////// if (Shape==S_CIRCLE) { /* StatusProgress->Maximum = 360; len = sqrt((Pos[0].x-Pos[1].x)*(Pos[0].x-Pos[1].x) + (Pos[0].y-Pos[1].y)*(Pos[0].y-Pos[1].y)); for (int deg=0; deg<360; deg+=LimitDeg) { StatusProgress->Position = deg; drawpoint.x = Pos[0].x + len*cos(M_PI*deg/180); drawpoint.y = Pos[0].y + len*sin(M_PI*deg/180); a = (deg+90) * 100; if (a<0) a += 36000; if (a>35999) a -= 36000; DrawImage(drawpoint, a); if(COLOROVERFLOW)goto next; } */ } else if (Shape==S_CURVE) { LimitDot = 1; /* for (int i=0; iCount; i++) { pd = (TPoint_Deg *)pdstore->Items[StatusProgress->Position]; DrawImage(pd->pt, pd->deg); } */ } else { if (store->Count>0) { POINT * sp; POINT * ep; int sumlength = 0; int len=0; for (int i = 1; i < store->Count; i++) { sp = (POINT *) store->Items[i-1]; ep = (POINT *) store->Items[i]; len = calculatelength(*sp, *ep); sumlength += len; } if (Shape != S_ELLIPSE) LimitDot = GetProperLimitDot(sumlength); else LimitDot = GetProperLimitDot(sumlength1); } } /////////////////////// END_LOG; return LimitDot; } } //--------------------------------------------------------------------------- int __fastcall TPatternRepeatForm::GetProperLimitDot(int sumLength) { //by linuxjun for ºñÁî °³¼ö if(LimitCount<=0){EditCountChange(NULL);} double temp = ((double)sumLength)/LimitCount; int result = temp; // if(temp-result>0){result++;} return result; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageSpray() { BEGIN_LOG(""); mousedown=0;////////by jeegeo //step reset if(Shape==S_CURVE)MainImageForm->DrawFreeLineLocate(Point(0,0),0);//by jeegeo POINT *sp, *ep, pre, drawpoint, temp; double rad, len, dx, dy; int a; bool first; TCursor old = Screen->Cursor; Screen->Cursor = crHourGlass; TPoint_Deg *pd; if (Shape==S_CIRCLE) { // MainImageForm->UndoSave(UK_ALL, Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, // MainImageForm->iMainImage->uBitmap->Height)); MainImageForm->UndoSave(UK_ALL, Rect(0, 0, 0, 0)); StatusProgress->Maximum = 360; len = sqrt((Pos[0].x-Pos[1].x)*(Pos[0].x-Pos[1].x) + (Pos[0].y-Pos[1].y)*(Pos[0].y-Pos[1].y)); if(rzckCount->Checked==false){ for (int deg=0; deg<360; deg+=LimitDeg) { StatusProgress->Position = deg; drawpoint.x = Pos[0].x + len*cos(M_PI*deg/180); drawpoint.y = Pos[0].y + len*sin(M_PI*deg/180); a = (deg+90) * 100; if (a<0) a += 36000; if (a>35999) a -= 36000; DrawImage(drawpoint, a); if(COLOROVERFLOW)goto next; } }else{ //by linuxjun for ºñÁî °³¼ö int deg=0; GetLimitDot(pstore); //by linuxjun for (int i=0; iPosition = deg; drawpoint.x = Pos[0].x + len*cos(M_PI*deg/180); drawpoint.y = Pos[0].y + len*sin(M_PI*deg/180); a = (deg+90) * 100; if (a<0) a += 36000; if (a>35999) a -= 36000; DrawImage(drawpoint, a); if(COLOROVERFLOW)goto next; } } } else if (Shape==S_CURVE) { // MainImageForm->UndoSave(UK_ALL, Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, // MainImageForm->iMainImage->uBitmap->Height)); MainImageForm->UndoSave(UK_ALL, Rect(0, 0, 0, 0)); GetLimitDot(pstore); //by linuxjun if(rzckCount->Checked==false){ StatusProgress->Maximum = pdstore->Count; StatusProgress->Position = 0; for (int i=0; iCount; i++) { // drawpoint.x = Pos[0].x + len*cos(M_PI*deg/180); // drawpoint.y = Pos[0].y + len*sin(M_PI*deg/180); // a = (deg+90) * 100; // if (a<0) a += 36000; // if (a>35999) a -= 36000; pd = (TPoint_Deg *)pdstore->Items[StatusProgress->Position]; DrawImage(pd->pt, pd->deg); if(COLOROVERFLOW)goto next; StatusProgress->Position = i; } }else{ //by linuxjun for ºñÁî °³¼ö // GetLimitDot(pstore); //by linuxjun StatusProgress->Maximum = LimitCount; StatusProgress->Position = 0; int num = 0; for (int i=0; iCount)/LimitCount; pd = (TPoint_Deg *)pdstore->Items[num]; DrawImage(pd->pt, pd->deg); if(COLOROVERFLOW)goto next; StatusProgress->Position++; } /* for (int i=0; iCount; i=i+pdstore->Count/LimitCount) { pd = (TPoint_Deg *)pdstore->Items[i]; DrawImage(pd->pt, pd->deg); if(COLOROVERFLOW)goto next; StatusProgress->Position++; } */ } } //by embakum 080401 °¢µµ°¡ ¹Ì¼¼ÇÏ°Ô º¯°æµÇ´ø°Í ¼öÁ¤. else if (Shape == S_OBLIQUE) { TPoint_Deg *pd_ = new TPoint_Deg; MainImageForm->UndoSave(UK_ALL, Rect(0, 0, 0, 0)); sp = (POINT *) pstore->Items[0]; ep = (POINT *) pstore->Items[1]; double length = calculatelength(*sp, *ep); double angle = calculateangle(*sp, *ep); if(rzckCount->Checked==false){ int delta_x = (ep->x-sp->x)*LimitDot/length; int delta_y = (ep->y-sp->y)*LimitDot/length; int numrepeat = length/LimitDot; StatusProgress->Maximum = numrepeat; StatusProgress->Position = 0; for (int i = 0; i < numrepeat; i++) { pd_->deg = angle; pd_->pt = Point(sp->x+delta_x*i,sp->y+delta_y*i); DrawImage(pd_->pt, pd_->deg); if(COLOROVERFLOW)goto next; StatusProgress->Position++; } } else { StatusProgress->Maximum = LimitCount; StatusProgress->Position = 0; for (int i = 0; i < LimitCount; i++) { pd_->deg = angle; pd_->pt = Point(sp->x+(ep->x-sp->x)*i/LimitCount,sp->y+(ep->y-sp->y)*i/LimitCount); DrawImage(pd_->pt, pd_->deg); if(COLOROVERFLOW)goto next; StatusProgress->Position++; } } delete pd_; } else { if (pstore->Count>0) { // MainImageForm->UndoSave(UK_ALL, Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, // MainImageForm->iMainImage->uBitmap->Height)); MainImageForm->UndoSave(UK_ALL, Rect(0, 0, 0, 0)); sumlength = 0; a = 0; len = 0; rad = 0; sp = (POINT *) pstore->Items[0]; pre = *sp; drawpoint = pre; StatusProgress->Maximum = pstore->Count - 1; GetLimitDot(pstore); //by linuxjun int PatternCount = 0; //by linuxjun for (int i = 1; i < pstore->Count; i++) { StatusProgress->Position = i; ep = (POINT *) pstore->Items[i]; len = calculatelength(pre, *ep); sumlength += len; first = true; //while (sumlength > LimitDot) while (sumlength >= LimitDot) //by linuxjun { dx = ep->x - pre.x; dy = ep->y - pre.y; if (dx || dy) rad = atan2(dy, dx); else rad = 0; if (first) { a = LimitDot - (sumlength - len); } else { a = LimitDot; } temp.x = a * cos(rad) + pre.x; temp.y = a * sin(rad) + pre.y; if(rzckCount->Checked){ //by linuxjun if(PatternCount>=LimitCount){ //by linuxjun goto next; } } PutImage(temp, drawpoint); PatternCount++; //by linuxjun if(COLOROVERFLOW)goto next; if (first) { sumlength = len - a; } else { sumlength = sumlength - LimitDot; } pre = temp; drawpoint = temp; first = false; } pre = *ep; } if(rzckCount->Checked==false){ PutImage(pre, drawpoint); } } } next: COLOROVERFLOW = false; StatusProgress->End(); ::RepaintColor(); Screen->Cursor = old; InitData(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::PutImage(POINT sp, POINT ep) { BEGIN_LOG(""); int deg, CenterX, CenterY, RelativeX, RelativeY; double dx, dy,rad, Tangent, eA, eB; dx = sp.x - ep.x; dy = sp.y - ep.y; if (dx || dy || (Shape==S_ELLIPSE)) { //Ÿ¿øÀ϶§´Â ¹«Á¶°Ç ÀÌÂÊÀ¸·Î µé¾î¿Â´Ù. if(Shape!=S_ELLIPSE) rad = atan2(dy, dx); if(Shape == S_RECT){ //qe Á÷»ç°¢ÇüÀ϶§´Â À̹ÌÁö°¡ ³õ¿©Áö´Â if((Pos[0].x - Pos[1].x) > 0){ //°¢µµ¸¦ ´ÙÀ½ÀÇ 4°³·Î ÇÑÁ¤ÇÏ¿´´Ù. if(rad > -M_PI && rad < -M_PI_2) rad = -M_PI_2; if(rad > -M_PI_2 && rad < 0) rad = 0; if(rad > 0 && rad < M_PI_2) rad = M_PI_2; if(rad > M_PI_2 && rad < M_PI) rad = M_PI; } else{ if(rad > -M_PI && rad < -M_PI_2) rad = M_PI; if(rad > -M_PI_2 && rad < 0) rad = -M_PI_2; if(rad > 0 && rad < M_PI_2) rad = 0; if(rad > M_PI_2 && rad < M_PI) rad = M_PI_2; } }else if(Shape == S_ELLIPSE){ //Ÿ¿øÀ϶§´Â À̹ÌÁö°¡ ³õ¿©Áö´Â °¢µµ¸¦ CenterX = (Pos[0].x + Pos[1].x)/2; // Á¢¼±ÀÇ ±â¿ï±â¸¦ ÅëÇØ Á¤ÇÏ¿´´Ù. CenterY = (Pos[0].y + Pos[1].y)/2; RelativeX = ep.x - CenterX; RelativeY = ep.y - CenterY; eA = (Pos[0].x - Pos[1].x)/2; eB = (Pos[0].y - Pos[1].y)/2; if(RelativeY==0){ if(RelativeX > 0) rad = M_PI_2; else rad = -M_PI_2; }else{ //Á¢¼±ÀÇ ±â¿ï±â : -(eB*eB)*(RelativeX)/(eA*eA)/(RelativeY) rad = atan2((eB*eB)*(RelativeX), -(eA*eA)*(RelativeY)); } } deg = 18000*rad / M_PI; //for RotateBitmapFine (pai / 180000) if (deg<0) deg = 35999 + deg; } else { deg = 0; } DrawImage(ep, deg); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::DrawImage(POINT sp, int deg) { BEGIN_LOG(""); POINT fp; //fix point Byte *sl, *mp, mm; int x, y; COLORREF crrf; double rad; TPException ec = EC_NONE; PosState = (TPosState)rzckPosition->ItemIndex; // Mask ¸¸µé±â if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (PosState != POS_BOTH) { if (TempBitmap->Create(FSize.x, FSize.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TempBitmap->Copy(sBitmap, SRCCOPY); if (deg) { if (!TempBitmap->Rotate(deg, true, PALETTEINDEX(0))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } else { if (TempBitmap->Create(FSize.x, FSize.y*2, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TempBitmap->Copy(sBitmap, SRCCOPY); TempBitmap->Flip(); TempBitmap->Copy(sBitmap, SRCCOPY); if (deg) { if (!TempBitmap->Rotate(deg, true, PALETTEINDEX(0))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } if (sMask->Create(TempBitmap->Width, TempBitmap->Height, 8) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (sMask->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < TempBitmap->Height; y++) { sl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if (*(sl + x) == 0) { *(mp + x) = 0; } else *(mp + x) = 0xFF; } } sMask->Unlock(); TempBitmap->StopScanLine(); } else { if (PosState != POS_BOTH) { if (TempBitmap->Create(FSize.x, FSize.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TempBitmap->Copy(sBitmap, SRCCOPY); if (deg) { if (!TempBitmap->Rotate(deg, true, FillColor)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } else { if (TempBitmap->Create(FSize.x, FSize.y*2, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TempBitmap->Copy(sBitmap, SRCCOPY); TempBitmap->Flip(); TempBitmap->Copy(sBitmap, SRCCOPY); if (deg) { if (!TempBitmap->Rotate(deg, true, FillColor)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } } if (sMask->Create(TempBitmap->Width, TempBitmap->Height, 1) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (sMask->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < TempBitmap->Height; y++) { sl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); *mp = 0; mm = 0x80; x = 0; while(1) { GetPixel24(sl, crrf); if (crrf != FillColor) { *mp |= mm; } x++; if (x >= TempBitmap->Width) break; sl += 3; if (mm == 1) { mp++; *mp = 0; mm = 0x80; } else mm >>= 1; } } sMask->Unlock(); TempBitmap->StopScanLine(); } rad = (double)(36000 - deg)/18000*M_PI; switch (PosState) { case POS_CENTER: fp.x = sp.x - TempBitmap->Width / 2; fp.y = sp.y - TempBitmap->Height / 2; break; case POS_LEFT: fp.x = sp.x - TempBitmap->Width / 2 - FSize.y*sin(rad)/2; fp.y = sp.y - TempBitmap->Height / 2 - FSize.y*cos(rad)/2; break; case POS_RIGHT: fp.x = sp.x - TempBitmap->Width / 2 + FSize.y*sin(rad)/2; fp.y = sp.y - TempBitmap->Height / 2 + FSize.y*cos(rad)/2; break; case POS_BOTH: fp.x = sp.x - TempBitmap->Width / 2; fp.y = sp.y - TempBitmap->Height / 2; break; } // ½ÇÁ¦ ±×¸®±â.... switch (FullViewForm->Super) { case sOff: ImageOffDrawing(fp.x, fp.y); break; case sNormal: ImageNormalDrawing(fp.x, fp.y); break; case sGauze: ImageGauzeDrawing(fp.x, fp.y); break; case sOverlap: ImageOverLapDrawing(fp.x, fp.y); break; } TempBitmap->Destroy(); END_LOG; return; fail : sMask->Destroy(); TempBitmap->Destroy(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageOffDrawing(int sx, int sy) { BEGIN_LOG(""); int x, y; Byte *ssl, *dsl, *mp, mm, *mml, *lml; COLORREF crrf; TUnionBitmap *Bitmap = MainImageForm->iMainImage->uBitmap; // convert by celberus TUnionBitmap *Mask = MainImageForm->iMainImage->Mask; // convert by celberus TUnionBitmap *LayerMask = MainImageForm->iMainImage->LayerMask; // convert by celberus TPException ec = EC_NONE; if (LayerMask) { if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (sMask->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0 && (mml[sx + x] == 0)) if (mp[x]) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); //by linuxjun Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); //by linuxjun } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mml[sx + x] == 0) { if (mp[x]) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx, TempBitmap->Width); //by linuxjun Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); //by linuxjun } } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { if ((mml[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0) { if (*mp & mm) { GetPixel24(ssl, crrf); SetPixel24(dsl, crrf); lml[(sx + x) >> 3] &= ~(0x80 >> ((sx + x) & 7)); } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); //by linuxjun *3?? Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); //by linuxjun *3?? } } } Mask->StopScanLine(); } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0) { if (mp[x]) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) if (mp[x]) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { if (*mp & mm) { GetPixel24(ssl, crrf); SetPixel24(dsl, crrf); lml[(sx + x) >> 3] &= ~(0x80 >> ((sx + x) & 7)); } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } sMask->Unlock(); TempBitmap->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); } else { if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (sMask->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0 && (mml[sx + x] == 0)) if (mp[x]) dsl[sx+x] = ssl[x]; } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mml[sx + x] == 0) { if (mp[x]) dsl[sx+x] = ssl[x]; } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { if ((mml[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0) { if (*mp & mm) { GetPixel24(ssl, crrf); SetPixel24(dsl, crrf); } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } Mask->StopScanLine(); } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0) { if (mp[x]) dsl[sx+x] = ssl[x]; } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mp[x]) dsl[sx+x] = ssl[x]; } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { if (*mp & mm) { GetPixel24(ssl, crrf); SetPixel24(dsl, crrf); } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } sMask->Unlock(); TempBitmap->StopScanLine(); Bitmap->StopScanLine(); } END_LOG; return; fail : Mask->StopScanLine(); sMask->Unlock(); LayerMask->StopScanLine(); TempBitmap->StopScanLine(); Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageNormalDrawing(int sx, int sy) { BEGIN_LOG(""); int x, y; Byte *ssl, *dsl, *mp, mm, *mml, *lml; COLORREF crrf, dc; TUnionBitmap *Bitmap = MainImageForm->iMainImage->uBitmap; // convert by celberus TUnionBitmap *LayerMask = MainImageForm->iMainImage->LayerMask; // convert by celberus TUnionBitmap *Mask = MainImageForm->iMainImage->Mask; // convert by celberus TPException ec = EC_NONE; if (LayerMask) { if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (sMask->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if(Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0 && (mml[sx + x] == 0)) { if (mp[x] && (ssl[x] != 1)) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mml[sx + x] == 0) { if (mp[x] && (ssl[x] != 1)) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { dc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { if ((mml[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0) { if (*mp & mm) { GetPixel24(ssl, crrf); if (crrf != dc) { SetPixel24(dsl, crrf); lml[(sx + x) >> 3] &= ~(0x80 >>((sx + x) & 7)); } } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } Mask->StopScanLine(); } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0) { if (mp[x] && (ssl[x] != 1)) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mp[x] && (ssl[x] != 1)) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { dc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { if (*mp & mm) { GetPixel24(ssl, crrf); if (crrf != dc) { SetPixel24(dsl, crrf); lml[(sx + x) >> 3] &= ~(0x80 >>((sx + x) & 7)); } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } sMask->Unlock(); TempBitmap->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); } else { if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (sMask->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if(Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0 && (mml[sx + x] == 0)) { if (mp[x] && (ssl[x] != 1)) { dsl[sx+x] = ssl[x]; } } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mml[sx + x] == 0) { if (mp[x] && (ssl[x] != 1)) { dsl[sx+x] = ssl[x]; } } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { dc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { if ((mml[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0) { if (*mp & mm) { GetPixel24(ssl, crrf); if (crrf != dc) { SetPixel24(dsl, crrf); } } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } Mask->StopScanLine(); } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0) { if (mp[x] && (ssl[x] != 1)) { dsl[sx+x] = ssl[x]; } } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mp[x] && (ssl[x] != 1)) { dsl[sx+x] = ssl[x]; } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { dc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { if (*mp & mm) { GetPixel24(ssl, crrf); if (crrf != dc) { SetPixel24(dsl, crrf); } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } sMask->Unlock(); TempBitmap->StopScanLine(); Bitmap->StopScanLine(); } END_LOG; return; fail : Mask->StopScanLine(); sMask->Unlock(); TempBitmap->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageGauzeDrawing(int sx, int sy) { BEGIN_LOG(""); int x, y; Byte *ssl, *dsl, *mp, mm, *mml, *lml; COLORREF crrf, crrb, bgc; TUnionBitmap *Bitmap = MainImageForm->iMainImage->uBitmap; // convert by celberus TUnionBitmap *LayerMask = MainImageForm->iMainImage->LayerMask; // convert by celberus TUnionBitmap *Mask = MainImageForm->iMainImage->Mask; // convert by celberus TPException ec = EC_NONE; if (LayerMask) { if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (sMask->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0 && (mml[sx + x] == 0) && (ssl[x] != 1)) { if (dsl[sx+x] > 1) { if (mp[x]) { if ((x + y) & 1) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } }else if(ssl[x] > 1){ dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mml[sx + x] == 0 && (ssl[x] != 1)) { if (dsl[sx+x] > 1) { if (mp[x]) { if ((x + y) & 1) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } }else if(ssl[x] > 1){ dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { GetPixel24(ssl, crrf); if ((mml[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0 && (crrf != bgc)) { if (*mp & mm) { GetPixel24(dsl, crrb); if(crrb != bgc) { if ((x + y) & 1) { SetPixel24(dsl, crrf); lml[(sx + x) >> 3] &= ~(0x80 >>((sx + x) & 7)); } }else { SetPixel24(dsl, crrf); lml[(sx + x) >> 3] &= ~(0x80 >>((sx + x) & 7)); } } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } Mask->StopScanLine(); } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0 && (ssl[x] != 1)) { if (dsl[sx+x] > 1) { if (mp[x]) { if ((x + y) & 1) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } }else if(ssl[x] > 1) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mp[x] && ssl[x] != 1) { if (dsl[sx+x] > 1) { if ((x + y) & 1) { dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } }else if(ssl[x] > 1){ dsl[sx+x] = ssl[x]; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { GetPixel24(ssl, crrf); if (crrf != bgc) { if (*mp & mm) { GetPixel24(dsl, crrb); if(crrb != bgc) { if ((x + y) & 1) { SetPixel24(dsl, crrf); lml[(sx + x) >> 3] &= ~(0x80 >>((sx + x) & 7)); } }else { SetPixel24(dsl, crrf); lml[(sx + x) >> 3] &= ~(0x80 >>((sx + x) & 7)); } } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } sMask->Unlock(); TempBitmap->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); } else { if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (sMask->Lock() == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0 && (mml[sx + x] == 0) && (ssl[x] != 1)) { if(dsl[sx+x] > 1){ if (mp[x]) { if ((x + y) & 1) { dsl[sx+x] = ssl[x]; } } }else if(ssl[x] > 1){ dsl[sx+x] = ssl[x]; } } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (mml[sx + x] == 0 && (ssl[x] != 1)) { if(dsl[sx+x] > 1){ if (mp[x]) { if ((x + y) & 1) { dsl[sx+x] = ssl[x]; } } }else if(ssl[x] > 1){ dsl[sx+x] = ssl[x]; } } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { GetPixel24(ssl, crrf); if ((mml[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0 && (crrf != bgc)) { if (*mp & mm) { GetPixel24(dsl, crrb); if(crrb != bgc) { if ((x + y) & 1) { SetPixel24(dsl, crrf); } }else { SetPixel24(dsl, crrf); } } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } Mask->StopScanLine(); } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[dsl[sx+x]]->Protect==0 && (ssl[x] != 1)) { if(dsl[sx+x] > 1){ if (mp[x]) { if ((x + y) & 1) { dsl[sx+x] = ssl[x]; } } }else if(ssl[x] > 1){ dsl[sx+x] = ssl[x]; } } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (dsl[sx+x] > 1) { if (mp[x] && ssl[x] > 1) { if ((x + y) & 1) { dsl[sx+x] = ssl[x]; } } }else if(ssl[x] > 1){ dsl[sx+x] = ssl[x]; } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { GetPixel24(ssl, crrf); if (crrf != bgc) { if (*mp & mm) { GetPixel24(dsl, crrb); if(crrb != bgc) { if ((x + y) & 1) { SetPixel24(dsl, crrf); } }else SetPixel24(dsl, crrf); } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } sMask->Unlock(); TempBitmap->StopScanLine(); Bitmap->StopScanLine(); } END_LOG; return; fail : Mask->StopScanLine(); sMask->Unlock(); TempBitmap->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageOverLapDrawing(int sx, int sy) { BEGIN_LOG(""); int x, y; Byte *ssl, *dsl, *mp, mm, *mml, *lml; COLORREF color, crr1, crr2, bgc; TUnionBitmap *Bitmap = MainImageForm->iMainImage->uBitmap; // convert by celberus TUnionBitmap *LayerMask = MainImageForm->iMainImage->LayerMask; // convert by celberus TUnionBitmap *Mask = MainImageForm->iMainImage->Mask; // convert by celberus if (LayerMask) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8){ if (LayerMask->StartScanLine() == false) goto fail; if (Bitmap->StartScanLine() == false) goto fail; if (TempBitmap->StartScanLine() == false) goto fail; if (sMask->Lock() == NULL) goto fail; MainImageForm->InitOverlap(); if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) goto fail; for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + sx; lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mml = Mask->GetScanLine(sy+y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++, dsl ++, ssl ++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[*dsl]->Protect==0 && mml[sx + x] == 0 && (*ssl>1)) { if (*dsl > 1) { color = MainImageForm->Overlap(*dsl, *ssl); if (color==0xFF) { MainImageForm->ExitOverlap(); Bitmap->StopScanLine(); TempBitmap->StopScanLine(); LayerMask->StopScanLine(); // Undo->Read(); //BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->Undo->UndoRead(); //BeConverted by linuxjun Don't Forget!! Undo_Method ::RepaintColor(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); COLOROVERFLOW = true; END_LOG; return; } else { *dsl = color; lml[sx+x] = 0; } } else { *dsl = *ssl; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } Mask->StopScanLine(); } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + sx; lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++, dsl ++, ssl ++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[*dsl]->Protect==0 && (*ssl>1)) { if (*dsl > 1) { color = MainImageForm->Overlap(*dsl, *ssl); if (color==0xFF) { MainImageForm->ExitOverlap(); Bitmap->StopScanLine(); TempBitmap->StopScanLine(); LayerMask->StopScanLine(); // Undo->Read(); //BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->Undo->UndoRead(); //BeConverted by linuxjun Don't Forget!! Undo_Method ::RepaintColor(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); COLOROVERFLOW = true; END_LOG; return; } else { *dsl = color; lml[sx+x] = 0; } } else { *dsl = *ssl; lml[sx+x] = 0; } } } } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } }else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Bitmap->StartScanLine() == false) goto fail; if (LayerMask->StartScanLine() == false) goto fail; if (TempBitmap->StartScanLine() == false) goto fail; if (sMask->Lock() == NULL) goto fail; MainImageForm->InitOverlap(); if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) goto fail; for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; lml = LayerMask->GetScanLine(sy+y); mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { GetPixel24(ssl, crr1); if ((mml[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0 && (crr1 != bgc)) { if (*mp & mm) { GetPixel24(dsl, crr2); color = MainImageForm->Overlap(crr2, crr1); SetPixel24(dsl, color); lml[(sx + x) >> 3] &= ~(0x80 >>((sx + x) & 7)); } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } Mask->StopScanLine(); } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; lml = LayerMask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { GetPixel24(ssl, crr1); if (crr1 != bgc) { if (*mp & mm) { GetPixel24(dsl, crr2); color = MainImageForm->Overlap(crr2, crr1); SetPixel24(dsl, color); lml[(sx + x) >> 3] &= ~(0x80 >>((sx + x) & 7)); } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } LayerMask->PutScanLine(sy+y,sx,TempBitmap->Width); Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } MainImageForm->ExitOverlap(); sMask->Unlock(); TempBitmap->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); } else { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8){ if (Bitmap->StartScanLine() == false) goto fail; if (TempBitmap->StartScanLine() == false) goto fail; if (sMask->Lock() == NULL) goto fail; MainImageForm->InitOverlap(); if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) goto fail; for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + sx; ssl = TempBitmap->GetScanLine(y); mml = Mask->GetScanLine(sy+y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++, dsl ++, ssl ++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[*dsl]->Protect==0 && mml[sx + x] == 0 && (*ssl > 1)) { if (*dsl > 1) { color = MainImageForm->Overlap(*dsl, *ssl); if (color==0xFF) { MainImageForm->ExitOverlap(); Bitmap->StopScanLine(); TempBitmap->StopScanLine(); // Undo->Read(); //BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->Undo->UndoRead(); //BeConverted by linuxjun Don't Forget!! Undo_Method ::RepaintColor(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); COLOROVERFLOW = true; END_LOG; return; } else { *dsl = color; } } else { *dsl = *ssl; } } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } Mask->StopScanLine(); } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + sx; ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); for (x = 0; x < TempBitmap->Width; x++, dsl ++, ssl ++) { if ((sx + x) >=0 && (sx+x) < Bitmap->Width) { if (MainImageForm->Palette->ColorData[*dsl]->Protect==0 && (*ssl > 1)) { if (*dsl > 1) { color = MainImageForm->Overlap(*dsl, *ssl); if (color==0xFF) { MainImageForm->ExitOverlap(); Bitmap->StopScanLine(); TempBitmap->StopScanLine(); // Undo->Read(); //BeConverted by linuxjun Don't Forget!! Undo_Method MainImageForm->Undo->UndoRead(); //BeConverted by linuxjun Don't Forget!! Undo_Method ::RepaintColor(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); COLOROVERFLOW = true; END_LOG; return; } else { *dsl = color; } } else { *dsl = *ssl; } } } } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } }else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Bitmap->StartScanLine() == false) goto fail; if (TempBitmap->StartScanLine() == false) goto fail; if (sMask->Lock() == NULL) goto fail; MainImageForm->InitOverlap(); if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) goto fail; for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; mml = Mask->GetScanLine(sy+y); ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { GetPixel24(ssl, crr1); if ((mml[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0 && (crr1 != bgc)) { if (*mp & mm) { GetPixel24(dsl, crr2); color = MainImageForm->Overlap(crr2, crr1); SetPixel24(dsl, color); } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } Mask->StopScanLine(); } else { for (y = 0; y < TempBitmap->Height; y++) { if ((sy + y) >=0 && (sy + y) < Bitmap->Height) { dsl = Bitmap->GetScanLine(sy+y) + 3*sx; ssl = TempBitmap->GetScanLine(y); mp = sMask->ScanLine(y); mm = 0x80; for (x = 0; x < TempBitmap->Width; x++, dsl += 3, ssl += 3) { if ((sx + x) >=0 && (sx + x) < Bitmap->Width) { GetPixel24(ssl, crr1); if (crr1 != bgc) { if (*mp & mm) { GetPixel24(dsl, crr2); color = MainImageForm->Overlap(crr2, crr1); SetPixel24(dsl, color); } } } if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } Bitmap->PutScanLine(sy+y,sx,TempBitmap->Width); } } } } MainImageForm->ExitOverlap(); sMask->Unlock(); TempBitmap->StopScanLine(); Bitmap->StopScanLine(); } END_LOG; return; fail : Mask->StopScanLine(); MainImageForm->ExitOverlap(); sMask->Unlock(); LayerMask->StopScanLine(); TempBitmap->StopScanLine(); Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::PreviewImageDraw() { BEGIN_LOG(""); TCanvas *cv; TPException ec = EC_NONE; PreviewImage->Picture->Bitmap->Width = 110; PreviewImage->Picture->Bitmap->Height = 110; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { PreviewImage->Picture->Bitmap->PixelFormat = pf8bit; SetDIBColorTable(PreviewImage->Picture->Bitmap->Canvas->Handle, 0, 256, rgb); } else { PreviewImage->Picture->Bitmap->PixelFormat = pf24bit; } if ((cv = previewBitmap->CreateCanvas()) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } SetStretchBltMode(PreviewImage->Picture->Bitmap->Canvas->Handle,COLORONCOLOR); StretchBlt(PreviewImage->Picture->Bitmap->Canvas->Handle, 0, 0, PreviewImage->Picture->Bitmap->Width, PreviewImage->Picture->Bitmap->Height, cv->Handle,0, 0, previewBitmap->Width, previewBitmap->Height,SRCCOPY); // PreviewImage->Picture->Bitmap->Canvas->CopyRect(Rect(0, 0, // PreviewImage->Picture->Bitmap->Width, PreviewImage->Picture->Bitmap->Height), // cv, Rect(0, 0, sBitmap->Width, sBitmap->Height)); previewBitmap->DeleteCanvas(cv); doDestroy(previewBitmap); PreviewImage->Repaint(); END_LOG; return; fail : EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::convertTemp24() { BEGIN_LOG(""); Byte *ssl, *mp, mm; COLORREF crrf = FillColor; int x, y; TPException ec = EC_NONE; if (sBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->WorkArea->Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < sBitmap->Height; y++) { ssl = sBitmap->GetScanLine(y); mp = MainImageForm->WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x = 0; x < sBitmap->Width; x++, ssl += 3) { if ((*mp & mm) == 0) SetPixel24(ssl, crrf); if (mm == 1) { mp++; mm = 0x80; } else mm >>= 1; } sBitmap->PutScanLine(y); } MainImageForm->WorkArea->Mask->StopScanLine(); sBitmap->StopScanLine(); END_LOG; return; fail : MainImageForm->WorkArea->Mask->StopScanLine(); sBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- COLORREF __fastcall TPatternRepeatForm::SearchFillColor() { // ÀÌ·± ¾îÀ̾ø´Â Äڵ尡.. 256°³ÀÇ Èæ¹éÀ¸·Î¸¸ ÀÌ·ç¾îÁø ºñÆ®¸Ê¿¡¼­´Â FillColor°¡ ¾È³ª¿Â´Ù BEGIN_LOG(""); int x, y, i, j; Byte *sl; Byte rgb[3][256]; int r, g, b; COLORREF crrf; TPException ec = EC_NONE; memset(rgb, 0, 256 * 3); if (sBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = 0; y < sBitmap->Height; y++) { sl = sBitmap->GetScanLine(y); for (x = 0; x < sBitmap->Width; x++, sl += 3) { GetPixel24(sl, crrf); /* r = crrf & 0x00000011; g = (crrf>>8) & 0x000011; b = (crrf>>16) & 0x0011; */ r = crrf & 0xFF; g = (crrf>>8) & 0xFF; b = (crrf>>16) & 0xFF; // by celberus rgb[0][r] = 1; rgb[1][g] = 1; rgb[2][b] = 1; } } sBitmap->StopScanLine(); for (i = 0; i < 3; i++) { for (j = 0; j < 256; j++) { if (rgb[i][j] == 0) { END_LOG; return 0x00000000 | (j<<(8*i)); } } } END_LOG; return 0; fail : sBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return 0; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::set_brush_spread_regular_pattern_pen(int lsx, int lsy, int size, COLORREF color) { BEGIN_LOG(""); int sx, sy, x, y, s, e, pw; Byte *IP = 0, *SP = 0, *MP = 0, *Mdsl = 0, *Tsl = 0, *IMP = 0, *LMP = 0; int x0, y0; COLORREF dc; TUnionBitmap *Bitmap = MainImageForm->iMainImage->uBitmap; // convert by celberus TUnionBitmap *LayerMask = MainImageForm->iMainImage->LayerMask; // convert by celberus TUnionBitmap *Mask = MainImageForm->iMainImage->Mask; // convert by celberus TPException ec = EC_NONE; if (LayerMask) { pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; x0 = (sx - FStart.x) % FSize.x; if (x0 < 0) x0 = x0 + FSize.x; y0 = (sy - FStart.y) % FSize.y; if (y0 < 0) y0 = y0 + FSize.y; if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Bitmap->BitsPerPixel == 8) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempMask->StopScanLine(); } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && ((IMP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { Tsl = SP; Tsl += 3*((x0 + x) % FSize.x); GetPixel24(Tsl, dc); if (dc != FillColor) { SetPixel24(Mdsl, dc); LMP[(sx + x) >> 3] &= ~(0x80 >> ((sx + x) & 7)); } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } Mask->StopScanLine(); } else { if (Bitmap->BitsPerPixel == 8) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempMask->StopScanLine(); } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) { Tsl = SP; Tsl += 3*((x0 + x) % FSize.x); GetPixel24(Tsl, dc); if (dc != FillColor) { SetPixel24(Mdsl, dc); LMP[(sx+x) >> 3] &= ~(0x80 >> ((sx + x) & 7)); } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempBitmap->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); } else { pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; x0 = (sx - FStart.x) % FSize.x; if (x0 < 0) x0 = x0 + FSize.x; y0 = (sy - FStart.y) % FSize.y; if (y0 < 0) y0 = y0 + FSize.y; if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Bitmap->BitsPerPixel == 8) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempMask->StopScanLine(); } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && ((IMP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { Tsl = SP; Tsl += 3*((x0 + x) % FSize.x); GetPixel24(Tsl, dc); if (dc != FillColor) { SetPixel24(Mdsl, dc); } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } Mask->StopScanLine(); } else { if (Bitmap->BitsPerPixel == 8) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempMask->StopScanLine(); } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) { Tsl = SP; Tsl += 3*((x0 + x) % FSize.x); GetPixel24(Tsl, dc); if (dc != FillColor) { SetPixel24(Mdsl, dc); } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempBitmap->StopScanLine(); Bitmap->StopScanLine(); } END_LOG; return; fail : Mask->StopScanLine(); TempMask->StopScanLine(); TempBitmap->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::set_brush_spread_irregular_pattern_pen(int lsx, int lsy, int size, COLORREF color) { BEGIN_LOG(""); int sx, sy, x, y, s, e, pw; Byte *IP = 0, *Mdsl = 0, *SSP = 0, *MP = 0, *LMP = 0; COLORREF dc; TUnionBitmap *Bitmap = MainImageForm->iMainImage->uBitmap; // convert by celberus TUnionBitmap *LayerMask = MainImageForm->iMainImage->LayerMask; // convert by celberus TUnionBitmap *Mask = MainImageForm->iMainImage->Mask; // convert by celberus TPException ec = EC_NONE; if (LayerMask) { pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Bitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } } else { if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); IP = TempBitmap->GetScanLine(random(FSize.y)); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && ((MP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { SSP = IP; SSP += 3*random(FSize.x); GetPixel24(SSP, dc); SetPixel24(Mdsl, dc); LMP[(sx + x) >> 3] &= ~(0x80 >> ((sx + x) & 7)); } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } TempBitmap->StopScanLine(); } Mask->StopScanLine(); } else { if (Bitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { LMP = LayerMask->GetScanLine(sy + y); IP = Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } } else { if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); LMP = LayerMask->GetScanLine(sy + y); IP = TempBitmap->GetScanLine(random(FSize.y)); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) { SSP = IP; SSP += 3*random(FSize.x); GetPixel24(SSP, dc); SetPixel24(Mdsl, dc); LMP[(sx+x) >> 3] &= ~(0x80 >> ((sx+x) & 7)); } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } TempBitmap->StopScanLine(); } } LayerMask->StopScanLine(); Bitmap->StopScanLine(); } else { pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Bitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } } else { if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); MP = Mask->GetScanLine(sy + y); IP = TempBitmap->GetScanLine(random(FSize.y)); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && ((MP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { SSP = IP; SSP += 3*random(FSize.x); GetPixel24(SSP, dc); SetPixel24(Mdsl, dc); } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } TempBitmap->StopScanLine(); } Mask->StopScanLine(); } else { if (Bitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } } else { if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); IP = TempBitmap->GetScanLine(random(FSize.y)); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) { SSP = IP; SSP += 3*random(FSize.x); GetPixel24(SSP, dc); SetPixel24(Mdsl, dc); } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } TempBitmap->StopScanLine(); } } Bitmap->StopScanLine(); } END_LOG; return; fail : TempBitmap->StopScanLine(); Mask->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::set_crayon_brush_spread_regular_pattern_pen(int lsx, int lsy, int size, COLORREF color) { BEGIN_LOG(""); int s, e, sx, sy, x, y, pw, p; Byte *IP = 0, *SP = 0, *MP = 0, *Mdsl = 0, *Tsl = 0, *IMP = 0, *LMP = 0; int ran; int x0, y0; COLORREF dc; TUnionBitmap *Bitmap = MainImageForm->iMainImage->uBitmap; // convert by celberus TUnionBitmap *LayerMask = MainImageForm->iMainImage->LayerMask; // convert by celberus TUnionBitmap *Mask = MainImageForm->iMainImage->Mask; // convert by celberus TPException ec = EC_NONE; if (LayerMask) { pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; if (pw <= 0) p = 1; else p = pw; if (PenManagerForm->density == 1) { ran = 5000 / p; } else if (PenManagerForm->density == 2) { ran = 12000 / p; } else if (PenManagerForm->density == 3) { ran = 18000 / p; } else if (PenManagerForm->density == 4) { ran = 24000 / p; } else { ran = 30000 / p; } x0 = (sx - FStart.x) % FSize.x; if (x0 < 0) x0 = x0 + FSize.x; y0 = (sy - FStart.y) % FSize.y; if (y0 < 0) y0 = y0 + FSize.y; if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Bitmap->BitsPerPixel ==8) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempMask->StopScanLine(); } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); LMP = LayerMask->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (rand() < ran) && ((IMP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { Tsl = SP; Tsl += 3*((x0 + x) % FSize.x); GetPixel24(Tsl, dc); if (dc != FillColor) { SetPixel24(Mdsl, dc); LMP[(sx+x) >> 3] &= ~(0x80 >>((sx+x) & 7)); } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } Mask->StopScanLine(); } else { if (Bitmap->BitsPerPixel ==8) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; LMP[sx + x] = 0; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempMask->StopScanLine(); } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); LMP = LayerMask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (rand() < ran)) { Tsl = SP; Tsl += 3*((x0 + x) % FSize.x); GetPixel24(Tsl, dc); if (dc != FillColor) { SetPixel24(Mdsl, dc); LMP[(sx + x) >> 3] &= ~(0x80 >> ((sx + x) & 7)); } } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempBitmap->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); } else { pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; if (pw <= 0) p = 1; else p = pw; if (PenManagerForm->density == 1) { ran = 5000 / p; } else if (PenManagerForm->density == 2) { ran = 12000 / p; } else if (PenManagerForm->density == 3) { ran = 18000 / p; } else if (PenManagerForm->density == 4) { ran = 24000 / p; } else { ran = 30000 / p; } x0 = (sx - FStart.x) % FSize.x; if (x0 < 0) x0 = x0 + FSize.x; y0 = (sy - FStart.y) % FSize.y; if (y0 < 0) y0 = y0 + FSize.y; if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Bitmap->BitsPerPixel ==8) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (IMP[sx + x] == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempMask->StopScanLine(); } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); IMP = Mask->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (rand() < ran) && ((IMP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { Tsl = SP; Tsl += 3*((x0 + x) % FSize.x); GetPixel24(Tsl, dc); if (dc != FillColor) { SetPixel24(Mdsl, dc); } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } Mask->StopScanLine(); } else { if (Bitmap->BitsPerPixel ==8) { if (TempMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; //LMP[sx + x] = 0; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); MP = TempMask->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran)) { if (MP[(x0 + x) % FSize.x]) { IP[sx + x] = SP[(x0 + x) % FSize.x]; } } } } Bitmap->PutScanLine(sy + y,sx + s,e - s + 1); // } } } } TempMask->StopScanLine(); } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); SP = TempBitmap->GetScanLine((y0 + y) % FSize.y); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (rand() < ran)) { Tsl = SP; Tsl += 3*((x0 + x) % FSize.x); GetPixel24(Tsl, dc); if (dc != FillColor) { SetPixel24(Mdsl, dc); } } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } TempBitmap->StopScanLine(); Bitmap->StopScanLine(); } END_LOG; return; fail : TempMask->StopScanLine(); Mask->StopScanLine(); LayerMask->StopScanLine(); TempBitmap->StopScanLine(); Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::set_crayon_brush_spread_irregular_pattern_pen(int lsx, int lsy, int size, COLORREF color) { BEGIN_LOG(""); int s, e, sx, sy, x, y, pw, p; Byte *IP = 0, *Mdsl = 0, *SSP = 0, *MP = 0, *LMP = 0; COLORREF dc; int ran; TUnionBitmap *Bitmap = MainImageForm->iMainImage->uBitmap; // convert by celberus TUnionBitmap *LayerMask = MainImageForm->iMainImage->LayerMask; // convert by celberus TUnionBitmap *Mask = MainImageForm->iMainImage->Mask; // convert by celberus TPException ec = EC_NONE; if (LayerMask) { pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; if (pw <= 0) p = 1; else p = pw; if (PenManagerForm->density == 1) { ran = 5000 / p; } else if (PenManagerForm->density == 2) { ran = 12000 / p; } else if (PenManagerForm->density == 3) { ran = 18000 / p; } else if (PenManagerForm->density == 4) { ran = 24000 / p; } else { ran = 30000 / p; } if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (LayerMask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Bitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->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] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } } else { if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); LMP = LayerMask->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); IP = TempBitmap->GetScanLine(random(FSize.y)); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (rand() < ran) && ((MP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { SSP = IP; SSP += 3*random(FSize.x); GetPixel24(SSP, dc); SetPixel24(Mdsl, dc); LMP[(sx+x) >> 3] &= ~(0x80 >> ((sx+x) & 7)); } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } TempBitmap->StopScanLine(); } Mask->StopScanLine(); } else { if (Bitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); LMP = LayerMask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; LMP[sx + x] = 0; } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } } else { if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); LMP = LayerMask->GetScanLine(sy + y); IP = TempBitmap->GetScanLine(random(FSize.y)); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (rand() < ran)) { SSP = IP; SSP += 3*random(FSize.x); GetPixel24(SSP, dc); SetPixel24(Mdsl, dc); LMP[(sx+x) >> 3] &= ~(0x80 >> ((sx+x) & 7)); } } } LayerMask->PutScanLine(sy + y,sx + s,e-s+1); // Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } TempBitmap->StopScanLine(); } } LayerMask->StopScanLine(); Bitmap->StopScanLine(); } else { pw = size; sx = lsx - MAX_PEN_HALF_WIDTH; sy = lsy - MAX_PEN_HALF_WIDTH; s = MAX_PEN_LEFT_CENTER - pw / 2.0; e = MAX_PEN_HALF_WIDTH + pw / 2.0; if (pw <= 0) p = 1; else p = pw; if (PenManagerForm->density == 1) { ran = 5000 / p; } else if (PenManagerForm->density == 2) { ran = 12000 / p; } else if (PenManagerForm->density == 3) { ran = 18000 / p; } else if (PenManagerForm->density == 4) { ran = 24000 / p; } else { ran = 30000 / p; } if (Bitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->MaskArea) { if (Mask->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Bitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->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] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); MP = Mask->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MP[sx + x] == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } } else { if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); MP = Mask->GetScanLine(sy + y); IP = TempBitmap->GetScanLine(random(FSize.y)); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (rand() < ran) && ((MP[(sx + x) >> 3] & (0x80 >> ((sx + x) & 7))) == 0)) { SSP = IP; SSP += 3*random(FSize.x); GetPixel24(SSP, dc); SetPixel24(Mdsl, dc); } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } TempBitmap->StopScanLine(); } Mask->StopScanLine(); } else { if (Bitmap->BitsPerPixel == 8) { if (MainImageForm->Protect) { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (MainImageForm->Palette->ColorData[IP[sx + x]]->Protect == 0)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } else { if (PenManagerForm->acolor == 2) { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran) && (PenManagerForm->Selector->Number[IP[sx + x]] < 255)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } else { for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { IP = Bitmap->GetScanLine(sy + y); for (x = s; x <= e; x++) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if ((PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x]) && (rand() < ran)) { IP[sx + x] = CColor->Code[random(CColor->Count)]; } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } } } } else { if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y = s; y <= e; y++) { if ((sy + y >= 0) && (sy + y < Bitmap->Height)) { Mdsl = Bitmap->GetScanLine(sy + y) + 3*(sx+s); IP = TempBitmap->GetScanLine(random(FSize.y)); for (x = s; x <= e; x++, Mdsl += 3) { if ((sx + x >= 0) && (sx + x < Bitmap->Width)) { if (PenManagerForm->pshape[PenManagerForm->Pen->Shape].size[pw - 1].dot[y][x] && (rand() < ran)) { SSP = IP; SSP += 3*random(FSize.x); GetPixel24(SSP, dc); SetPixel24(Mdsl, dc); } } } Bitmap->PutScanLine(sy + y,sx + s,e-s+1); // } } TempBitmap->StopScanLine(); } } Bitmap->StopScanLine(); } END_LOG; return; fail : TempBitmap->StopScanLine(); Mask->StopScanLine(); LayerMask->StopScanLine(); Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::point_pressure_pattern_pen(int lsx, int lsy, int size, COLORREF color) { BEGIN_LOG(""); if (PenManagerForm->Type == PT_NORMAL) { if (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 (PenManagerForm->Type == PT_CRAYON) { if (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); } END_LOG; } //--------------------------------------------------------------------------- ////// PUBLIC METHOD ///////////////////////////////////////////////////// //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::InitFunction() { BEGIN_LOG(""); TPException ec = EC_NONE; if (Item == T_REGULAR) { if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (TempBitmap->Create(FSize.x, FSize.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TempBitmap->Copy(sBitmap, SRCCOPY); TempMask = NULL; if ((TempMask = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempMask->Create(FSize.x, FSize.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TempMask->Copy(MainImageForm->WorkArea->Mask, SRCCOPY); } else { if (TempBitmap->Create(FSize.x, FSize.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TempBitmap->Copy(sBitmap, SRCCOPY); } } else if (Item == T_IRREGULAR) { CColor = new TChoiceColor; MainImageForm->SearchWorkAreaColor(CColor); } else if (Item == T_IMGSPRAY) { mousedown = 0; //lhskys ¸¶¿ì½º·Î Ŭ¸¯À» üũ sMask = NULL; //============================================================== Shape = (TShapeItem)rzckShape->ItemIndex; //lhskys curve Àΰæ¿ì¿¡ if(Shape==S_CURVE)rzckContinuous->Visible=true; else { rzckContinuous->Visible=false; rzbtnRun->Visible=false; } /* if(rzckCount->Checked==false){ EditCount->Visible = false; LabelCount->Visible = false; EditDot->Visible = true; LabelUnit->Visible = true; }else{ EditCount->Visible = true; LabelCount->Visible = true; EditDot->Visible = false; LabelUnit->Visible = false; } */ //=============================================================== if ((sMask = new TPBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { if (sMask->Create(FSize.x, FSize.y, 8) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } else { if (sMask->Create(FSize.x, FSize.y, 1) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } pstore = new TList; pdstore = new TList; mdown = false; } END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ExitFunction() { if (Item == T_REGULAR) { doDestroy(TempMask) } else if (Item == T_IRREGULAR) { doDestroy(CColor) } else if (Item == T_IMGSPRAY) { InitData(); doDestroy(pstore) doDestroy(pdstore) doDestroy(sMask) } } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::InitForm() { BEGIN_LOG(""); TempMask = NULL; CColor = NULL; pstore = NULL; sMask = NULL; sBitmap = NULL; TempBitmap = NULL; pdstore = NULL; TPException ec = EC_NONE; //ParentHeight = Parent->Height+20; //ClientHeight = 245; //Parent->Height = ParentHeight+ClientHeight; PenManagerForm->PointPressurePen = point_pressure_pattern_pen; RECT rect = MainImageForm->WorkArea->Range; FSize = Point ((rect.right - rect.left), (rect.bottom - rect.top)); //REGULAR FStart = Point (rect.left, rect.top); if ((TempBitmap = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((sBitmap = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { //Image Spray if (sBitmap->Create(FSize.x, FSize.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // sBitmap->CopyFromRect(MainImageForm->iMainImage->uBitmap, rect.left, rect.top, SRCCOPY); HDC dcsBitmap = sBitmap->CreateDC(); // convert by celberus MainImageForm->iMainImage->uBitmap->UnionBitBlt(dcsBitmap, 0, 0, sBitmap->Width, sBitmap->Height, rect.left, rect.top, SRCCOPY, false); // convert by celberus sBitmap->DeleteDC(dcsBitmap); // convert by celberus MainImageForm->WorkArea->Mask->PutColors(0, 256, rgb); TTexpiaBitmap *TempMask; if ((TempMask = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempMask->Create(FSize.x, FSize.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } doDestroy(previewBitmap) if ((previewBitmap = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (previewBitmap->Create(FSize.x, FSize.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } sBitmap->Copy(MainImageForm->WorkArea->Mask, SRCAND); previewBitmap->Copy(sBitmap, SRCCOPY); TempMask->Copy(MainImageForm->WorkArea->Mask, NOTSRCCOPY); previewBitmap->Copy(TempMask, SRCPAINT); doDestroy(TempMask) if (TempBitmap->Create(FSize.x, FSize.y, 8, rgb) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TempBitmap->Copy(sBitmap, SRCCOPY); } else { //Image Spray if (sBitmap->Create(FSize.x, FSize.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // sBitmap->CopyFromRect(MainImageForm->iMainImage->uBitmap, rect.left, rect.top, SRCCOPY); HDC dcsBitmap = sBitmap->CreateDC(); // convert by celberus MainImageForm->iMainImage->uBitmap->UnionBitBlt(dcsBitmap, 0, 0, sBitmap->Width, sBitmap->Height, rect.left, rect.top, SRCCOPY, false); // convert by celberus sBitmap->DeleteDC(dcsBitmap); // convert by celberus TTexpiaBitmap *TempMask; if ((TempMask = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (TempMask->Create(FSize.x, FSize.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } doDestroy(previewBitmap) if ((previewBitmap = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (previewBitmap->Create(FSize.x, FSize.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } sBitmap->Copy(MainImageForm->WorkArea->Mask, SRCAND); previewBitmap->Copy(sBitmap, SRCCOPY); TempMask->Copy(MainImageForm->WorkArea->Mask, NOTSRCCOPY); previewBitmap->Copy(TempMask, SRCPAINT); doDestroy(TempMask) FillColor = SearchFillColor(); if (TempBitmap->Create(FSize.x, FSize.y, 24) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } TempBitmap->Copy(sBitmap, SRCCOPY); convertTemp24(); } MainImageForm->OnSetHLine = SetHLine; rzckComboDirection->ItemIndex = 0; ReadIni(); if (Item == T_REGULAR) { rzRegular->Down = true; FunctionClick(rzRegular); } else if (Item == T_IRREGULAR) { rzIrregular->Down = true; FunctionClick(rzIrregular); } else if (Item == T_IMGSPRAY) { rzImgSpray->Down = true; FunctionClick(rzImgSpray); } PreviewImageDraw(); END_LOG; return; fail : TempBitmap->Destroy(); sBitmap->Destroy(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ExitForm() { MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo MainImageForm->iMainImage->Repaint(); WriteIni(); if (Item == T_IMGSPRAY) { InitData(); doDestroy(pstore) doDestroy(pdstore) doDestroy(sMask) } doDestroy(sBitmap) doDestroy(TempBitmap) doDestroy(TempMask) doDestroy(previewBitmap) PenManagerForm->PointPressurePen = PenManagerForm->point_pressure_pen; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ReadIni() { ShowMessage(AppDataItem); BEGIN_LOG(""); double value; TIniFile *PRIni = new TIniFile(AppDataItem + "\\Pattern.ini"); if (PRIni) { Item = (TFItem)PRIni->ReadInteger("Menu", "Item", 0); LimitDot = PRIni->ReadInteger("Irregular", "ValueDot" , 80); LimitDeg = PRIni->ReadInteger("Irregular", "ValueDeg" , 4); LimitCount = PRIni->ReadInteger("Irregular", "ValueCount", 3); rzckCount->Checked = PRIni->ReadBool("Irregular", "ValueCountUse", true); if (rzckCount->Checked) rzckUnit->Checked = false; else rzckUnit->Checked = true; Shape = (TShapeItem)PRIni->ReadInteger("Shape","Value",S_FREE); PosState = (TPosState)PRIni->ReadInteger("Shape", "Position", POS_CENTER); delete PRIni; } else { Item = T_REGULAR; LimitDot = 80; LimitDeg = 4; LimitCount = 3; rzckCount->Checked = true; rzckUnit->Checked = false; Shape = S_FREE; PosState = POS_CENTER; } rzckShape->ItemIndex = Shape; rzckPosition->ItemIndex = PosState; EditCount->Value = LimitCount; if (Shape != S_CIRCLE) { rzckUnit->Caption = MainImageForm->UnitName(); if (MainImageForm->CurrentUnit == uDot) { currentUnit = 1; EditDot->Value = LimitDot; } else if (MainImageForm->CurrentUnit == uInch) { currentUnit = 2; value = LimitDot/ 160.0 + 0.0005; EditDot->Value = value; //Format("%.3f", OPENARRAY(TVarRec,(value))); } else if (MainImageForm->CurrentUnit == uCm) { currentUnit = 0; value = ((float)LimitDot * 2.54 / 160) + 0.0005; EditDot->Value = value; //Format("%.3f", OPENARRAY(TVarRec,(value))); } } else if (Shape == S_CIRCLE) { rzckUnit->Caption = IDS_UNITDEG; EditDot->Value = LimitDeg; //Format("%d", OPENARRAY(TVarRec,(LimitDeg))); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::WriteIni() { BEGIN_LOG(""); TIniFile *PRIni = new TIniFile(AppDataItem + "\\Pattern.ini"); if (PRIni) { PRIni->WriteInteger("Menu", "Item", Item); PRIni->WriteInteger("Irregular", "ValueDot", LimitDot); PRIni->WriteInteger("Irregular", "ValueDeg", LimitDeg); EditCountChange(NULL); PRIni->WriteInteger("Irregular", "ValueCount", LimitCount); PRIni->WriteBool("Irregular", "ValueCountUse", rzckCount->Checked); PRIni->WriteInteger("Shape","Value",Shape); PRIni->WriteInteger("Shape","Position",PosState); delete PRIni; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::FunctionClick(TObject *Sender) { BEGIN_LOG(""); if (rzRegular->Down) { ExitFunction(); Item = T_REGULAR; PanelRegular->BringToFront(); PanelRegular->Visible = true; is_startpoint = false; rzbtnSelectPos->Down = false; rzckContinuous->Checked = false; rzbtnRun->Visible = false; //lhskys run ¼û±â±â } else if (rzIrregular->Down) { ExitFunction(); Item = T_IRREGULAR; //PanelIrregular->BringToFront(); PanelRegular->Visible = false; PanelImg->Visible = false; rzckContinuous->Checked = false; rzbtnRun->Visible = false; //lhskys run ¼û±â±â } else if (rzImgSpray->Down) { ExitFunction(); Item = T_IMGSPRAY; PanelImg->BringToFront(); PanelImg->Visible = true; } InitFunction(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageSprayMouseDown(int X, int Y) { BEGIN_LOG(""); mousedown++; //lhskys ¸¶¿ì½º·Î Ŭ¸¯À» üũ if(mousedown == 1){ //lhskys °¢ °æ¿ì¿¡ µû¶ó °áÁ¤ if(Shape==S_FREE) MainImageForm->DrawFreeLineLocate(Point(X,Y));///////by jeegeo //Á¡Çϳª¸¦ ±×¸°´Ù if(Shape==S_CURVE) MainImageForm->DrawFreeLineLocate(Point(X,Y),0); InitData();///ÀúÀåµÈ Á¡À» ¸ðµÎÁö¿î´Ù Pos[0].x=X; // »ç¼±À» ±×¸®±âÀ§ÇÑ ½ÃÀÛÁ¡ ÃʱâÈ­ Pos[0].y=Y; Pos[1].x=X; Pos[1].y=Y; POINT *p = new POINT; *p = Point(X, Y); DrawLocate(*p, *p); if (Shape == S_ELLIPSE || Shape == S_CIRCLE) delete p; else { pstore->Add(p); prepoint = *p; } /*if(Shape==S_CURVE)*/CurvePoint[0]=Point(X,Y); mdown = true; } else if(mousedown==2){ if(Shape != S_CURVE)ImageSprayMouseUp(X,Y); //lhskys mouseup È£Ãâ else if(Shape==S_CURVE)CurvePoint[1]=Point(X,Y); } else if(mousedown==3){ if(rzckContinuous->Checked){ DrawCurve(CurvePoint[0],CurvePoint[1],Point(X,Y)); mousedown=1; CurvePoint[0]=CurvePoint[1]; } else if(Shape==S_CURVE)ImageSprayMouseUp(X,Y); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageSprayMouseMove(int X, int Y, bool leave) { POINT l; // ¼öÁ÷¼öÆò¸·´ë »óÅ ǥ½Ã(¼öÁ÷À¸·Î ±×¸±°ÍÀÎÁö ¾Æ´Ï¸é ¼öÆòÀ¸·Î±×¸±°ÍÀÎÁö) // °è»êÀ» À§ÇÑ Àӽà º¯¼ö int len; if(mousedown !=0){ if(pstore->Count>1&&mousedown==1)rzbtnRun->Enabled=true; else rzbtnRun->Enabled=false; if (!MainImageForm->iMainImage->Cross)MainImageForm->iMainImage->Cursor = crCross; if (leave) { if (mdown) { switch(Shape) { case S_OBLIQUE : Pos[1].x = X ; Pos[1].y = Y; DrawShape(Pos[0].x, Pos[0].y ,Pos[1].x, Pos[1].y); break; case S_H_V : l.x = Pos[0].x - X; l.y = Pos[0].y - Y; if (abs(l.x) > abs(l.y)){ Pos[1].y = Pos[0].y; Pos[1].x = X; } else{ Pos[1].x = Pos[0].x; Pos[1].y = Y; } DrawShape(Pos[0].x, Pos[0].y ,Pos[1].x, Pos[1].y); break; case S_RECT : case S_ELLIPSE : Pos[1].x = X ; Pos[1].y = Y; DrawShape(Pos[0].x, Pos[0].y ,Pos[1].x, Pos[1].y); break; case S_CIRCLE : // len = abs(X-Pos[0].x) < abs(Y-Pos[0].y) ? abs(X-Pos[0].x) : abs(Y-Pos[0].y); // Pos[1].x = (X-Pos[0].x > 0) ? Pos[0].x + len : Pos[0].x - len; // Pos[1].y = (Y-Pos[0].y > 0) ? Pos[0].y + len : Pos[0].y - len; Pos[1].x = X ; Pos[1].y = Y; DrawShape(Pos[0].x, Pos[0].y ,Pos[1].x, Pos[1].y); break; case S_CURVE : GetLimitDot(pstore); //by linuxjun if(mousedown==1)DrawCurve(CurvePoint[0],Point(X,Y),Point(X,Y)); else if(mousedown==2)DrawCurve(CurvePoint[0],CurvePoint[1],Point(X,Y)); break; } if(Shape == S_FREE ) { // »ç¼±Àϰæ¿ì´Â ½ÇÇàÇÏÁö ¾ÊÀ½ POINT *p = new POINT; *p = Point(X, Y); pstore->Add(p); static int x=X,y=Y; if(x!=X||y!=Y) MainImageForm->DrawFreeLineLocate(Point(X,Y)); x=X; y=Y; prepoint = *p; } } } //* //by linuxjun //ºñÁî°³¼ö ¶óÀÎ ¹ÛÀ¸·Î »ßÁ®³ª°¬À»¶§ »ý±â´Â ¿¡·¯ ¼öÁ¤À» À§ÇÔ. else { if (mdown) { MainImageForm->BtnClick = true; //by linuxjun //ºñÁî°³¼ö ¶óÀÎ ¹ÛÀ¸·Î »ßÁ®³ª°¬À»¶§ »ý±â´Â ¿¡·¯ ¼öÁ¤À» À§ÇÔ. /*//by linuxjun //ºñÁî°³¼ö ¶óÀÎ ¹ÛÀ¸·Î »ßÁ®³ª°¬À»¶§ »ý±â´Â ¿¡·¯ ¼öÁ¤À» À§ÇÔ. EraseLine(); ImageSpray(); mdown = false; */ } } //*/ } } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageSprayMouseUp(int X, int Y) { BEGIN_LOG(""); int len; check = false; // Ellipse ÇüÅ·Π±×¸±°æ¿ì ¸¶¿ì½º ´Ù¿î½Ã ½ÃÀÛÁ¡ ÀúÀå ¿©ºÎ ¼³Á¤ MainImageForm->DrawFreeLineLocate(Point(X,Y),0); if (mdown) { POINT *p = new POINT; switch (Shape) { case S_FREE : case S_OBLIQUE : *p = Point(X, Y); DrawLocate(prepoint, *p); pstore->Add(p); EraseLine(); ImageSpray(); break; case S_H_V : *p = Pos[1]; DrawLocate(prepoint, *p); pstore->Add(p); EraseLine(); ImageSpray(); break; case S_RECT : // »ç°¢Çü ÇüÅÂÀÇ ÆÐÅÏ ¹Ýº¹ ±¸Çö delete p; RectDraw(Pos[0].x, Pos[0].y, X, Y); ImageSpray(); break; case S_ELLIPSE : // Ÿ¿ø ÇüÅÂÀÇ ÆÐÅÏ ¹Ýº¹ ±¸Çö delete p; if(mousedown==2)EllipseDraw(Pos[0].x, Pos[0].y, X, Y); ImageSpray(); break; case S_CIRCLE : delete p;//20061010(¹Ú¼¼¿î) // len = abs(X-Pos[0].x) < abs(Y-Pos[0].y) ? abs(X-Pos[0].x) : abs(Y-Pos[0].y); // Pos[1].x = (X-Pos[0].x > 0) ? Pos[0].x + len : Pos[0].x - len; // Pos[1].y = (Y-Pos[0].y > 0) ? Pos[0].y + len : Pos[0].y - len; // if(mousedown==2)EllipseDraw(Pos[0].x, Pos[0].y, Pos[1].x, Pos[1].y); Pos[1].x = X; Pos[1].y = Y; ImageSpray(); break; case S_CURVE : delete p; if(rzckCount->Checked){ GetLimitDot(pstore); } DrawCurve( CurvePoint[0] , CurvePoint[1], Point(X,Y)); ImageSpray(); break; } } mdown = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageSprayMouseLeave() { if (mdown) { if( Shape == S_ELLIPSE ){ POINT *p = new POINT; *p = Point(Pos[0].x, Pos[0].y); pstore->Add(p); prepoint = *p; } DrawShape(Pos[0].x, Pos[0].y ,Pos[1].x, Pos[1].y); EraseLine(); //ImageSpray(); mdown = false; } } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageSprayMouseEnter() { /* if(mdown) { start = false; Button2Click(NULL); } */ } //--------------------------------------------------------------------------- bool __fastcall TPatternRepeatForm::SetStartPoint(int X, int Y) { BEGIN_LOG(""); if (rzbtnSelectPos->Down) { if (L_IsPtInBitmapRgn(MainImageForm->iMainImage->uBitmap->RgnBitmap->Handle, Y, X)) { rzbtnSelectPos->Down = false; RECT rc = MainImageForm->WorkArea->Range; switch (rzckComboDirection->ItemIndex) { case 0: margin.x = X - rc.left; margin.y = Y - rc.top; break; case 1: margin.x = rc.right - X; margin.y = Y - rc.top; break; case 2: margin.x = X - rc.left; margin.y = rc.bottom - Y; break; case 3: margin.x = rc.right - X; margin.y = rc.bottom - Y; break; } is_startpoint = true; } END_LOG; return true; } else { if (is_startpoint) { FStart.x = X - margin.x; FStart.y = Y - margin.y; is_startpoint = false; } END_LOG; return false; } } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ChangeUnit(TUnit CUnit) { if (Item == T_IMGSPRAY) { if (Shape != S_CIRCLE) { rzckUnit->Caption = MainImageForm->UnitName(CUnit); if (CUnit==uDot) { currentUnit = 1; EditDot->Value = (int)LimitDot; } else if (CUnit==uInch) { currentUnit = 2; EditDot->Value = (double)LimitDot/ 160.0; } else if (CUnit==uCm) { currentUnit = 0; EditDot->Value = (double)LimitDot/160 * 2.54; } } else if (Shape == S_CIRCLE) { rzckUnit->Caption = IDS_UNITDEG; EditDot->Value = LimitDeg; } } } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::EditDotChange(TObject *Sender) { BEGIN_LOG(""); if (EditDot->Value > 0) { if (Shape != S_CIRCLE) { if (currentUnit == 0) { LimitDot = 160 * EditDot->Value / 2.54; } else if (currentUnit == 1) { try{ LimitDot = EditDot->IntValue; }catch(EConvertError &ec){ LimitDot = 80; EXCEPTION_MESSAGE_OK(EC_NOT_INTEGER); // ShowException(&ec); } } else if (currentUnit == 2) { LimitDot = 160 * EditDot->Value; } if (LimitDot <= 0) LimitDot = 1; // 0 À϶§ ÇÁ·Î±×·¥ ´Ù¿îµÇ¼­.. by celberus } else if (Shape == S_CIRCLE) { LimitDeg = EditDot->IntValue; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::EditCountChange(TObject *Sender) { BEGIN_LOG(""); /* if (EditCount->Text != "") { if (Shape != S_CIRCLE) { LimitCount = StrToInt(EditCount->Text); if (LimitCount <= 0) LimitCount = 1; // 0 À϶§ ÇÁ·Î±×·¥ ´Ù¿îµÇ¼­.. } else if (Shape == S_CIRCLE) { LimitDeg = StrToInt(EditCount->Text); } } */ if (EditCount->Value > 0) { try{ LimitCount = EditCount->IntValue; if (LimitCount <= 0) LimitCount = 1; // 0 À϶§ ÇÁ·Î±×·¥ ´Ù¿îµÇ¼­.. }catch(EConvertError &ec){ LimitCount = 1; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::SetHLine(int x, int y, int len, COLORREF c) { BEGIN_LOG(""); if (MainImageForm->iMainImage->LayerMask) { if (Item == T_REGULAR) { RegularSetHLine_LAYER(x, y, len); } else if (Item == T_IRREGULAR) { IrregularSetHLine_LAYER(x, y, len); } } else { if (Item == T_REGULAR) { RegularSetHLine_NONE(x, y, len); } else if (Item == T_IRREGULAR) { IrregularSetHLine_NONE(x, y, len); } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::RegularSetHLine_LAYER(int x, int y, int len) { BEGIN_LOG(""); int xx, yy, i; Byte *dsl = 0, *ssl = 0, *ssl24 = 0, *lml = 0; COLORREF dc; TChoiceColor *ChoiceColor = PenManagerForm->Selector->ChoiceColor; TPException ec = EC_NONE; if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } xx = (x - FStart.x) % FSize.x; if (xx < 0) xx = FSize.x + xx; yy = (y - FStart.y) % FSize.y; if (yy < 0) yy = FSize.y + yy; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { dsl = MainImageForm->iMainImage->uBitmap->GetScanLine(y); lml = MainImageForm->iMainImage->LayerMask->GetScanLine(y); ssl = TempBitmap->GetScanLine(yy); for (i = x; i < x + len; i++, xx++) { xx = xx % FSize.x; if (PenManagerForm->acolor == 2) { if (ChoiceColor->Number[*(dsl+i)] < 255) if (*(ssl+xx)) { *(dsl+i) = *(ssl+xx); *(lml+i) = 0; } } else { if (*(ssl+xx)) { *(dsl+i) = *(ssl+xx); *(lml+i) = 0; } } } MainImageForm->iMainImage->LayerMask->PutScanLine(y,x,len); MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,len); } else { //24bit true color bitmap/////////////////////////////////////// dsl = MainImageForm->iMainImage->uBitmap->GetScanLine(y) + 3*x; lml = MainImageForm->iMainImage->LayerMask->GetScanLine(y); ssl = TempBitmap->GetScanLine(yy); for (i = x; i < x + len; i++, xx++, dsl += 3) { xx = xx % FSize.x; ssl24 = ssl; ssl24 += 3*xx; GetPixel24(ssl24, dc); if (dc != FillColor) { SetPixel24(dsl, dc); lml[i >> 3] &= ~(0x80 >> (i & 7)); } } MainImageForm->iMainImage->LayerMask->PutScanLine(y,x,len); MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,len); } TempBitmap->StopScanLine(); END_LOG; return; fail : TempBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::RegularSetHLine_NONE(int x, int y, int len) { BEGIN_LOG(""); int xx, yy, i; Byte *dsl = 0, *ssl = 0, *ssl24 = 0, *lml = 0; COLORREF dc; TChoiceColor *ChoiceColor = PenManagerForm->Selector->ChoiceColor; TPException ec = EC_NONE; if (TempBitmap->StartScanLine() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } xx = (x - FStart.x) % FSize.x; if (xx < 0) xx = FSize.x + xx; yy = (y - FStart.y) % FSize.y; if (yy < 0) yy = FSize.y + yy; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { dsl = MainImageForm->iMainImage->uBitmap->GetScanLine(y); ssl = TempBitmap->GetScanLine(yy); for (i = x; i < x + len; i++, xx++) { xx = xx % FSize.x; if (PenManagerForm->acolor == 2) { if (ChoiceColor->Number[*(dsl+i)] < 255) if (*(ssl+xx)) *(dsl+i) = *(ssl+xx); } else { if (*(ssl+xx)) *(dsl+i) = *(ssl+xx); } } MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,len); } else { //24bit true color bitmap/////////////////////////////////////// dsl = MainImageForm->iMainImage->uBitmap->GetScanLine(y) + 3*x; ssl = TempBitmap->GetScanLine(yy); for (i = x; i < x + len; i++, xx++, dsl += 3) { xx = xx % FSize.x; ssl24 = ssl; ssl24 += 3*xx; GetPixel24(ssl24, dc); if (dc != FillColor) { SetPixel24(dsl, dc); } } MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,len); } TempBitmap->StopScanLine(); END_LOG; return; fail : TempBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::IrregularSetHLine_LAYER(int x, int y, int len) { BEGIN_LOG(""); int col; Byte *dsl, *ssl, *ssl24, *lml = 0; COLORREF dc; TChoiceColor *ChoiceColor = PenManagerForm->Selector->ChoiceColor; TPException ec = EC_NONE; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { dsl = MainImageForm->iMainImage->uBitmap->GetScanLine(y); lml = MainImageForm->iMainImage->LayerMask->GetScanLine(y); for (int i = x; i < x + len; i++) { col = random(CColor->Count); if (PenManagerForm->acolor == 2) { if (ChoiceColor->Number[*(dsl+i)] < 255) if (CColor->Code[col]) { *(dsl+i) = CColor->Code[col]; *(lml+i) = 0; } } else { if (CColor->Code[col]) { *(dsl+i) = CColor->Code[col]; *(lml+i) = 0; } } } MainImageForm->iMainImage->LayerMask->PutScanLine(y,x,len); MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,len); } else { if (!(sBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } dsl = MainImageForm->iMainImage->uBitmap->GetScanLine(y) + 3*x; lml = MainImageForm->iMainImage->LayerMask->GetScanLine(y); ssl = sBitmap->GetScanLine(random(FSize.y)); for (int i = x; i < x + len; i++, dsl += 3) { ssl24 = ssl; ssl24 += 3*random(FSize.x); GetPixel24(ssl24, dc); SetPixel24(dsl, dc); lml[i >> 3] &= ~(0x80 >> (i & 7)); } MainImageForm->iMainImage->LayerMask->PutScanLine(y,x,len); MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,len); sBitmap->StopScanLine(); } END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::IrregularSetHLine_NONE(int x, int y, int len) { BEGIN_LOG(""); int col; Byte *dsl, *ssl, *ssl24, *lml = 0; COLORREF dc; TChoiceColor *ChoiceColor = PenManagerForm->Selector->ChoiceColor; TPException ec = EC_NONE; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel == 8) { dsl = MainImageForm->iMainImage->uBitmap->GetScanLine(y); for (int i = x; i < x + len; i++) { col = random(CColor->Count); if (PenManagerForm->acolor == 2) { if (ChoiceColor->Number[*(dsl+i)] < 255) if (CColor->Code[col]) *(dsl+i) = CColor->Code[col]; } else { if (CColor->Code[col]) *(dsl+i) = CColor->Code[col]; } } MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,len); } else { if (!(sBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } dsl = MainImageForm->iMainImage->uBitmap->GetScanLine(y) + 3*x; /* ssl = sBitmap->GetScanLine(random(FSize.y)); for (int i = x; i < x + len; i++, dsl += 3) { ssl24 = ssl; ssl24 += 3*random(FSize.x); GetPixel24(ssl24, dc); SetPixel24(dsl, dc); } */ int offsetX = 0; for (int i = x; i < x + len; i++, dsl += 3) { offsetX = 3*random(FSize.x); // ssl24 = sBitmap->GetScanLine(random(FSize.y),offsetX,len+1)+offsetX; ssl24 = sBitmap->GetScanLine(random(FSize.y))+offsetX; // ssl24 = ssl; // ssl24 += GetPixel24(ssl24, dc); SetPixel24(dsl, dc); } MainImageForm->iMainImage->uBitmap->PutScanLine(y,x,len); sBitmap->StopScanLine(); } END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::DrawLocate(POINT F, POINT S) { // POINT l; // double r; // if (Shape==S_OBLIQUE) { // l.x = Pos[1].x-Pos[0].x; // l.y = Pos[1].y-Pos[0].y; // r = sqrt(l.x*l.x+l.y*l.y); // MainImageForm->DrawEllipseLocate(Rect(Pos[1].x-r, Pos[1].y-r, Pos[1].x+r, Pos[1].y+r)); // } else { MainImageForm->DrawLineLocate(F,S); // } } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::DrawShape(int x, int y, int x2 , int y2) { BEGIN_LOG(""); POINT pt,pt2; double r; int oldBrushStyle = MainImageForm->iMainImage->Canvas->Brush->Style; //by jeegeo º¹±¸À§Çؼ­ int oldPenMode = MainImageForm->iMainImage->Canvas->Pen->Mode; int oldPenStyle = MainImageForm->iMainImage->Canvas->Pen->Style; MainImageForm->iMainImage->Canvas->Brush->Style = bsClear; MainImageForm->iMainImage->Canvas->Pen->Mode =pmNotXor; MainImageForm->iMainImage->Canvas->Pen->Style = psSolid; switch( Shape) { case S_OBLIQUE: case S_H_V: // pt.x= MainImageForm->iMainImage->uBitmapToCanvasX(x); // pt.y =MainImageForm->iMainImage->uBitmapToCanvasY(y); // MainImageForm->iMainImage->Canvas->MoveTo(pt.x,pt.y); // pt.x= MainImageForm->iMainImage->uBitmapToCanvasX(x2); // pt.y =MainImageForm->iMainImage->uBitmapToCanvasY(y2); // MainImageForm->iMainImage->Canvas->LineTo(pt.x,pt.y); MainImageForm->DrawLineLocate(Point(x,y),Point(x2,y2));/////by jeegeo break; case S_RECT: // pt.x= MainImageForm->iMainImage->uBitmapToCanvasX(x); // pt.y =MainImageForm->iMainImage->uBitmapToCanvasY(y); // pt2.x= MainImageForm->iMainImage->uBitmapToCanvasX(x2); // pt2.y =MainImageForm->iMainImage->uBitmapToCanvasY(y2); // MainImageForm->iMainImage->Canvas->Rectangle(pt.x,pt.y,pt2.x,pt2.y); MainImageForm->DrawRectangleLocate(Rect(x,y,x2,y2));///////by jeegeo break; case S_CIRCLE: // pt.x= MainImageForm->iMainImage->uBitmapToCanvasX(x); // pt.y =MainImageForm->iMainImage->uBitmapToCanvasY(y); // pt2.x= MainImageForm->iMainImage->uBitmapToCanvasX(x2); // pt2.y =MainImageForm->iMainImage->uBitmapToCanvasY(y2); // MainImageForm->iMainImage->Canvas->Ellipse(pt.x,pt.y,pt2.x,pt2.y); r = sqrt((x-x2)*(x-x2) + (y-y2)*(y-y2)); pt.x = x - r; pt.y = y - r; pt2.x= x + r; pt2.y= y + r; MainImageForm->DrawEllipseLocate(Rect(pt.x,pt.y,pt2.x,pt2.y));///////by jeegeo break; case S_ELLIPSE: // pt.x= MainImageForm->iMainImage->uBitmapToCanvasX(x); // pt.y =MainImageForm->iMainImage->uBitmapToCanvasY(y); // pt2.x= MainImageForm->iMainImage->uBitmapToCanvasX(x2); // pt2.y =MainImageForm->iMainImage->uBitmapToCanvasY(y2); // MainImageForm->iMainImage->Canvas->Ellipse(pt.x,pt.y,pt2.x,pt2.y); MainImageForm->DrawEllipseLocate(Rect(x,y,x2,y2));///////by jeegeo break; } MainImageForm->iMainImage->Canvas->Brush->Style=(TBrushStyle)oldBrushStyle; MainImageForm->iMainImage->Canvas->Pen->Mode=(TPenMode)oldPenMode; MainImageForm->iMainImage->Canvas->Pen->Style=(TPenStyle)oldPenStyle; END_LOG; } //----------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::RectDraw(int x, int y, int x2, int y2) { long int b; // a , k,s; //a = x2-x; b = y2-y; /* // Á÷»ç°¢ÇüÀ» À§ÇÑ ÄÚµå if( b < 0 ) { ImageSprayMouseDown(x,y); LineDraw(x,y2); ImageSpray(); ImageSprayMouseDown(x,y2); LineDraw(x2,y2); ImageSpray(); ImageSprayMouseDown(x2,y2); LineDraw(x2,y); ImageSpray(); ImageSprayMouseDown(x2,y); LineDraw(x,y); //ImageSpray(); }else { ImageSprayMouseDown(x,y); LineDraw(x2,y); ImageSpray(); ImageSprayMouseDown(x2,y); LineDraw(x2,y2); ImageSpray(); ImageSprayMouseDown(x2,y2); LineDraw(x,y2); ImageSpray(); ImageSprayMouseDown(x,y2); LineDraw(x,y); //ImageSpray(); } */ // ²ÀÁöÁ¡ºÎ±ÙÀÇ ¸ð¾çÀÌ ±¸ºÎ·¯Áü.... if( b < 0){ LineDraw(x,y2); LineDraw(x2,y2); LineDraw(x2,y); LineDraw(x,y); } else { LineDraw(x2,y); LineDraw(x2,y2); LineDraw(x, y2); LineDraw(x,y); } /* for(int i = a ; i >= -a ; i--){ k = ( 1 - ( (i*i) / (a*a) ) ) / (b*b) ; s = sqrt(k) ; POINT *p = new POINT; *p = Point( Pos[0].x+i , Pos[0].y+s ); pstore->Add(p); DrawLocate(prepoint, *p); prepoint = *p; } */ /* POINT *p = new POINT; //*p = Point(x, y); pstore->Add(p); DrawLocate(prepoint, *p); prepoint = *p; */ } //----------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::EllipseDraw(int x, int y, int x2, int y2) { double b , a, k, i,l,s ; // k´Â y ÁÂÇ¥ a = x2-x; // i´Â x ÁÂÇ¥ if (a == 0) a++; b = y2-y; a = a / 2; b = b / 2; if( a > 0) { l = a+x; s = b+y; // check = true; // ¸¶¿ì½º ´Ù¿î½Ã Ãʱ⠽ÃÀÛÁÂÇ¥ ÀúÀå ¼³Á¤ ¿©ºÎ // ImageSprayMouseDown(x,y+b); for( i = -a ; i <= a ; i+=2){ k = (b*b) - (b*b*i*i)/(a*a) ; k = sqrt(k); LineDraw( (l+i) , (s-k) ); } for(i = a ; i >= -a ; i-=2){ k = (b*b) - (b*b*i*i)/(a*a) ; k = sqrt(k); LineDraw( (l+i), (s+k) ); if( i == -a ) LineDraw(x,y+b); } } else { l = a+x; s = b+y; // check = true; // ¸¶¿ì½º ´Ù¿î½Ã Ãʱ⠽ÃÀÛÁÂÇ¥ ÀúÀå ¼³Á¤ ¿©ºÎ ImageSprayMouseDown(x,y+b); for( i = -a ; i >= a ; i-=2){ k = (b*b) - (b*b*i*i)/(a*a) ; k = sqrt(k); LineDraw( (l+i) , (s-k) ); } for(i = a ; i <= -a ; i+=2){ k = (b*b) - (b*b*i*i)/(a*a) ; k = sqrt(k); LineDraw( (l+i), (s+k) ); if( i == -a ) LineDraw(x,y+b); } } } //----------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::LineDraw(int X, int Y) { POINT *p = new POINT; *p = Point(X, Y); pstore->Add(p); //DrawLocate(prepoint, *p); prepoint = *p; //EraseLine(); } //----------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::ImageSprayFreeLineMouseUp(int X, int Y) //lhskys freeline¿¡¼­´Â µå·¡±×·Î ±×¸®°Ô.. { BEGIN_LOG(""); if (mdown) { // check = false; // Ellipse ÇüÅ·Π±×¸±°æ¿ì ¸¶¿ì½º ´Ù¿î½Ã ½ÃÀÛÁ¡ ÀúÀå ¿©ºÎ ¼³Á¤ switch (Shape) { case S_FREE : MainImageForm->DrawFreeLineLocate(Point(X,Y),0); mdown = false; ImageSpray(); } } END_LOG; } //----------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::DrawCurve(POINT First, POINT Second, POINT Third) { BEGIN_LOG(""); static int oldp=0,oldl=0; if(rzckContinuous->Checked==false){ InitData(); oldp=0;oldl=0; } if(pstore->Count==1&&mousedown==1){oldp=1;oldl=0;} if(pstore->Count==0)MainImageForm->DrawFreeLineLocate(First,0); MainImageForm->DrawFreeLineLocate(First,oldl); int x2,y2,mx,my,sx2,sy2,ex2,ey2; int sx=First.x,sy=First.y,ex=Second.x,ey=Second.y,tx=Third.x,ty=Third.y; int t; double Theta,c,s; double alphas,alphae,tangent; double m; double d1,d2,d3; int a, dx, dy, x1, y1; double rad, len, deg; bool first; d1 = sqrt((double)(sx - tx) * (sx - tx) + (sy - ty) * (sy - ty)); d2 = sqrt((double)(ex - tx) * (ex - tx) + (ey - ty) * (ey - ty)); d3 = sqrt((double)(ex - sx) * (ex - sx) + (ey - sy) * (ey - sy)); if(d1+d2==0){ //END_LOG; return; } if(d1==d2+d3||d2==d1+d3||d3==d1+d2){ POINT *p1 = new POINT; *p1 = Point(sx,sy); pstore->Add(p1); MainImageForm->DrawFreeLineLocate(Point(sx,sy),-2); POINT *p2 = new POINT; *p2 = Point(ex,ey); pstore->Add(p2); MainImageForm->DrawFreeLineLocate(Point(ex,ey)); //°¢µµ dx = ex - sx; dy = ey - sy; len = calculatelength(Point(ex, ey), Point(sx, sy)); sumlength = len; if (dx) { deg = atanl((double)dy/dx) + (ex>sx ? 0 : M_PI); } else { if (dy>0) deg = M_PI_2; else deg = -M_PI_2; } deg = 180 * deg/M_PI * 100; if (deg<0) deg += 36000; if (deg>35999) deg -= 36000; first = true; while (sumlength > LimitDot) { if (first) { a = LimitDot - (sumlength - len); sumlength = len - a; } else { sumlength = sumlength - LimitDot; } dx = (sumlength*sx+(len-sumlength)*ex)/len; dy = (sumlength*sy+(len-sumlength)*ey)/len; TPoint_Deg *pd = new TPoint_Deg; pd->pt = Point(dx, dy); pd->deg = deg; pdstore->Add(pd); first = false; } //°¢µµ goto next; } m=d1/(d1+d2); mx = ex * m + sx * (1-m); my = ey * m + sy * (1-m); if ((tx - mx) == 0) { Theta = 0; } else { tangent = (double)(my - ty) / (mx - tx); Theta = M_PI / 2.0 - atan(tangent); // if(mx-tx<0)Theta+=M_PI; } c = cos(Theta); s = sin(Theta); sx2 = (sx-tx)*c-(sy-ty)*s+0.5; sy2 = (sx-tx)*s+(sy-ty)*c+0.5; ex2 = (ex-tx)*c-(ey-ty)*s+0.5; ey2 = (ex-tx)*s+(ey-ty)*c+0.5; if((double)sx2*(double)sx2==0)alphas=sy2*0xFFFFFFFF; else alphas = (double)sy2/((double)sx2*(double)sx2); if((double)ex2*(double)ex2==0)alphae=ey2*0xFFFFFFFF; else alphae = (double)ey2/((double)ex2*(double)ex2); if(alphas*alphae<0){ POINT *p1 = new POINT; *p1 = Point(sx,sy); pstore->Add(p1); MainImageForm->DrawFreeLineLocate(Point(sx,sy),-2); POINT *p2 = new POINT; *p2 = Point(ex,ey); pstore->Add(p2); MainImageForm->DrawFreeLineLocate(Point(ex,ey),-2); //°¢µµ dx = ex - sx; dy = ey - sy; len = calculatelength(Point(ex, ey), Point(sx, sy)); sumlength = len; if (dx) { deg = atanl((double)dy/dx) + (ex>sx ? 0 : M_PI); } else { if (dy>0) deg = M_PI_2; else deg = -M_PI_2; } deg = 180 * deg/M_PI * 100; if (deg<0) deg += 36000; if (deg>35999) deg -= 36000; first = true; while (sumlength > LimitDot) { if (first) { a = LimitDot - (sumlength - len); sumlength = len - a; } else { sumlength = sumlength - LimitDot; } dx = (sumlength*sx+(len-sumlength)*ex)/len; dy = (sumlength*sy+(len-sumlength)*ey)/len; TPoint_Deg *pd = new TPoint_Deg; pd->pt = Point(dx, dy); pd->deg = deg; pdstore->Add(pd); first = false; } //°¢µµ goto next; } { t=1; POINT *p1 = new POINT; *p1 = Point(sx,sy); pstore->Add(p1); MainImageForm->DrawFreeLineLocate(Point(sx,sy),-2); while (t>=1&&t<=20) { x2 = (double)sx2*(double)(20-t)/20.0; y2 = alphas * ((double)x2*(double)x2); POINT *p = new POINT; *p = Point(tx+c*x2+s*y2,ty-s*x2+c*y2); pstore->Add(p); MainImageForm->DrawFreeLineLocate(Point(tx+c*x2+s*y2,ty-s*x2+c*y2),-2); t++; //°¢µµ x1 = (double)sx2*(double)(20-t+2)/20.0; y1 = alphas * ((double)x1*(double)x1); len = calculatelength(Point(x2, y2), Point(x1, y1)); sumlength += len; first = true; while (sumlength > LimitDot) { if (first) { a = LimitDot - (sumlength - len); sumlength = len - a; } else { sumlength = sumlength - LimitDot; } dx = (sumlength*x1+(len-sumlength)*x2)/len; dy = (sumlength*y1+(len-sumlength)*y2)/len; deg = atanl(2*alphas*x1) + (x2>x1 ? 0 : M_PI) - Theta; deg = 180 * deg/M_PI * 100; if (deg<0) deg += 36000; if (deg>35999) deg -= 36000; TPoint_Deg *pd = new TPoint_Deg; pd->pt = Point(tx+c*dx+s*dy,ty-s*dx+c*dy); pd->deg = deg; pdstore->Add(pd); first = false; } //°¢µµ } t=1; MainImageForm->DrawFreeLineLocate(Point(tx,ty),-2); while (t>=1&&t<=19) { x2 = (double)ex2*(double)t/20.0; y2 = alphae * ((double)x2*(double)x2); POINT *p = new POINT; *p = Point(tx+c*x2+s*y2,ty-s*x2+c*y2); pstore->Add(p); MainImageForm->DrawFreeLineLocate(Point(tx+c*x2+s*y2,ty-s*x2+c*y2),-2); t++; //°¢µµ x1 = (double)ex2*(double)(t-2)/20.0; y1 = alphae * ((double)x1*(double)x1); len = calculatelength(Point(x2, y2), Point(x1, y1)); sumlength += len; first = true; while (sumlength > LimitDot) { if (first) { a = LimitDot - (sumlength - len); sumlength = len - a; } else { sumlength = sumlength - LimitDot; } dx = (sumlength*x1+(len-sumlength)*x2)/len; dy = (sumlength*y1+(len-sumlength)*y2)/len; deg = atanl(2*alphae*x1) + (x2>x1 ? 0 : M_PI) - Theta; deg = 180 * deg/M_PI * 100; if (deg<0) deg += 36000; if (deg>35999) deg -= 36000; TPoint_Deg *pd = new TPoint_Deg; pd->pt = Point(tx+c*dx+s*dy,ty-s*dx+c*dy); pd->deg = deg; pdstore->Add(pd); first = false; } //°¢µµ } POINT *p2 = new POINT; *p2 = Point(ex,ey); pstore->Add(p2); MainImageForm->DrawFreeLineLocate(Point(ex,ey)); } next: if(rzckContinuous->Checked==true){ if(mousedown!=3){ POINT *p = NULL; while (pdstore->Count>oldp-1) { p = (POINT *) pdstore->Last(); pdstore->Remove(p); if (p) { delete p; p = NULL; } } } else { oldp=pdstore->Count; oldl=MainImageForm->GetLineListCount(); } } END_LOG; return; } //----------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::iMainImageKeyDown(WORD Key, TShiftState Shift) //lhskys ¿£ÅÍŰ·Î ½ÇÇàÇϱâ { if (Key == VK_RETURN && rzbtnRun->Enabled && rzbtnRun->Visible && rzImgSpray->Down)rzbtnRunClick(this); } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::subRegular1Click(TObject *Sender) { rzRegular->Down = true; FunctionClick(rzRegular); } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::subIrregular1Click(TObject *Sender) { rzIrregular->Down = true; FunctionClick(rzIrregular); } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::subImageSpray1Click(TObject *Sender) { TSpeedButton *sp = (TSpeedButton *)Sender; switch (sp->Tag){ case 0 : rzImgSpray->Down = true; rzckShape->ItemIndex = 0; break; case 1 : rzImgSpray->Down = true; rzckShape->ItemIndex = 1; break; case 2 : rzImgSpray->Down = true; rzckShape->ItemIndex = 2; break; case 3 : rzImgSpray->Down = true; rzckShape->ItemIndex = 3; break; case 4 : rzImgSpray->Down = true; rzckShape->ItemIndex = 4; break; case 5 : rzImgSpray->Down = true; rzckShape->ItemIndex = 5; break; case 6 : rzImgSpray->Down = true; rzckShape->ItemIndex = 6; break; } FunctionClick(rzImgSpray); rzckShapeChange(Sender); } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::rzckCountClick(TObject *Sender) { if (rzckCount->Checked) rzckUnit->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::rzckContinuousClick(TObject *Sender) { BEGIN_LOG(""); if(rzckContinuous->Checked==true){ rzbtnRun->Visible=true; mousedown =0 ; MainImageForm->DrawFreeLineLocate(Point(0,0),0); InitData(); } else { rzbtnRun->Visible=false; mousedown =0 ; MainImageForm->DrawFreeLineLocate(Point(0,0),0); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::rzbtnRunClick(TObject *Sender) { BEGIN_LOG(""); if(pstore && pstore->Count>1){ ImageSpray(); } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::rzckComboDirectionChange(TObject *Sender) { BEGIN_LOG(""); TempBitmap->Copy(sBitmap, SRCCOPY); if (TempMask) TempMask->Copy(MainImageForm->WorkArea->Mask, SRCCOPY); switch (rzckComboDirection->ItemIndex) { case 1: L_ReverseBitmap(TempBitmap->Handle); if (TempMask) L_ReverseBitmap(TempMask->Handle); break; case 2: L_FlipBitmap(TempBitmap->Handle); if (TempMask) L_FlipBitmap(TempMask->Handle); break; case 3: L_ReverseBitmap(TempBitmap->Handle); L_FlipBitmap(TempBitmap->Handle); if (TempMask) { L_ReverseBitmap(TempMask->Handle); L_FlipBitmap(TempMask->Handle); } break; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::rzckShapeChange(TObject *Sender) { BEGIN_LOG(""); mousedown = 0; Shape = (TShapeItem)rzckShape->ItemIndex; switch (Shape) { case S_FREE : case S_OBLIQUE : case S_H_V : case S_RECT : case S_ELLIPSE : case S_CIRCLE : rzckContinuous->Visible = false; rzckContinuous->Checked = false; rzbtnRun->Visible = false; break; case S_CURVE : rzckContinuous->Visible = true; if (rzckContinuous->Checked) rzbtnRun->Visible = true; break; } if(rzckCount->Checked==false){ } else{ EditCountChange(NULL); } ChangeUnit(MainImageForm->CurrentUnit); MainImageForm->DrawFreeLineLocate(Point(0,0),0); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::rzckUnitClick(TObject *Sender) { if (rzckUnit->Checked) rzckCount->Checked = false; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::EditCountKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if(Key == VK_RETURN) { GetLimitDot(pstore); //by linuxjun g_FocusControl->SetFocus(); } } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::FormClose(TObject *Sender, TCloseAction &Action) { BEGIN_LOG(""); HWND hWnd = ((TWinControl *)Owner)->Handle; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TPatternRepeatForm::EditDotKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if(Key == VK_RETURN) { GetLimitDot(pstore); //by linuxjun g_FocusControl->SetFocus(); } } //---------------------------------------------------------------------------