//--------------------------------------------------------------------------- #include #pragma hdrstop #include "MainMenu.h" #include "Repeat_F.h" #include "FullView.h" #include "MainImage.h" #include "Undo.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPSpin" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_MATCHNORMAL StringTable[0] #define IDS_HALFDROPVER StringTable[1] #define IDS_MATCHVER StringTable[2] #define IDS_HALFDROPHOR StringTable[3] #define IDS_MATCHHOR StringTable[4] #define IDS_FALSE StringTable[5] #define IDS_TRUE StringTable[6] #define IDS_SIZE StringTable[7] //--------------------------------------------------------------------------- TRepeatForm *RepeatForm; //--------------------------------------------------------------------------- __fastcall TRepeatForm::TRepeatForm(TComponent* Owner) : TForm(Owner) { hWnd = ((TWinControl *)Owner)->Handle; //========================================================================== StringTable.Create(DirectoryBin, Language, "Repeat"); SetSmallFont(Font); SetSmallFont(LabelW->Font); SetSmallFont(LabelH->Font); SetSmallFont(Label1->Font); SetSmallFont(LabelSize->Font); SetSmallFont(LabelMax->Font); sbNormal->Caption = IDS_COMMON_NORMAL; sbMatchNormal->Caption = IDS_MATCHNORMAL; sbHDVer->Caption = IDS_COMMON_HDVER; sbMatchVer->Caption = IDS_MATCHVER; sbHDHor->Caption = IDS_COMMON_HDHOR; sbMatchHor->Caption = IDS_MATCHHOR; Label1->Caption = AnsiString(IDS_SIZE) + " : "; LabelSize->Caption = IDS_FALSE; LabelMax->Caption = IDS_COMMON_MAX; //========================================================================== } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::FormCreate(TObject *Sender) { dncount = 0; } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::RepeatABCDDown(TObject *Sender) { int Wd, Hd; bool undoSw = false; TPoint half, rest, rWH; TTexpiaBitmap *TempImage = NULL; TCursor OldCursor; HDC imageDC = NULL, TempDC = NULL; int ec = EC_NONE; HRGN hRgn = NULL; dncount++; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; if ((undoSw = MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height))) == false) goto fail; Wdiv = spEditW->Value; Hdiv = spEditH->Value; half = Point(window.size.x / 2.0, window.size.y / 2.0); rest = Point(window.size.x - half.x, window.size.y - half.y); if (WInd == 0) { Wd = Wdiv - half.x; rWH.x = rest.x - Wd; } else { Wd = Wdiv; rWH.x = half.x - Wd; } if (HInd == 0) { Hd = Hdiv - half.y; rWH.y = rest.y - Hd; } else { Hd = Hdiv; rWH.y = half.y - Hd; } if ((TempImage = new TTexpiaBitmap) == NULL) {ec = EC_MEMORY_LACK; goto fail;} if (Image->Bitmap->BitsPerPixel==8) { if (!TempImage->Create(window.size.x, window.size.y, 8, rgb)) {ec = EC_MEMORY_LACK; goto fail;} } else { if (!TempImage->Create(window.size.x, window.size.y, 24)) {ec = EC_MEMORY_LACK; goto fail;} } if ((TempDC = TempImage->CreateDC()) == NULL) {ec = EC_RESOURCE_LACK; goto fail;} hRgn = Image->Bitmap->GetRegion(true); if ((imageDC = Image->Bitmap->CreateDC()) == NULL) {ec = EC_RESOURCE_LACK; goto fail;} if (Item == TREPEAT_MNORMAL) { //A BitBlt(TempDC, rest.x, rest.y, half.x, half.y, imageDC, window.s.x, window.s.y, SRCCOPY); //B BitBlt(TempDC, rest.x, 0, half.x, rest.y, imageDC, window.s.x, window.s.y + half.y, SRCCOPY); //C BitBlt(TempDC, 0, rest.y, rest.x, half.y, imageDC, window.s.x + half.x, window.s.y, SRCCOPY); //D BitBlt(TempDC, 0, 0, rest.x, rest.y, imageDC, window.s.x + half.x, window.s.y + half.y, SRCCOPY); BitBlt(imageDC, window.s.x, window.s.y, window.size.x, window.size.y, TempDC, 0, 0, SRCCOPY); stNormal->Caption = dncount; } else if (Item == TREPEAT_MHOR) { if (WInd == 0) { //A BitBlt(TempDC, Wd, rest.y, half.x, half.y, imageDC, window.s.x, window.s.y, SRCCOPY); //C1 BitBlt(TempDC, half.x + Wd, rest.y, rWH.x, half.y, imageDC, window.s.x + half.x, window.s.y, SRCCOPY); //C2 BitBlt(TempDC, 0, rest.y, Wd, half.y, imageDC, window.s.x + half.x + rWH.x, window.s.y, SRCCOPY); } else { //A1 BitBlt(TempDC, rest.x + Wd, rest.y, rWH.x, half.y, imageDC, window.s.x, window.s.y, SRCCOPY); //A2 BitBlt(TempDC, 0, rest.y, Wd, half.y, imageDC, window.s.x + rWH.x, window.s.y, SRCCOPY); //C BitBlt(TempDC, Wd, rest.y, rest.x, half.y, imageDC, window.s.x + half.x, window.s.y, SRCCOPY); } //B BitBlt(TempDC, rest.x, 0, half.x, rest.y, imageDC, window.s.x, window.s.y + half.y, SRCCOPY); //D BitBlt(TempDC, 0, 0, rest.x, rest.y, imageDC, window.s.x + half.x, window.s.y + half.y, SRCCOPY); BitBlt(imageDC, window.s.x, window.s.y, window.size.x, window.size.y, TempDC, 0, 0, SRCCOPY); stHorizontal->Caption = dncount; } else if (Item == TREPEAT_MVER) { if (HInd == 0) { //A BitBlt(TempDC, rest.x, Hd, half.x, half.y, imageDC, window.s.x, window.s.y, SRCCOPY); //B1 BitBlt(TempDC, rest.x, half.y + Hd, half.x, rWH.y, imageDC, window.s.x, window.s.y + half.y, SRCCOPY); //B2 BitBlt(TempDC, rest.x, 0, half.x, Hd, imageDC, window.s.x, window.s.y + half.y + rWH.y, SRCCOPY); } else { //A1 BitBlt(TempDC, rest.x, rest.y+Hd, half.x, rWH.y, imageDC, window.s.x, window.s.y, SRCCOPY); //A2 BitBlt(TempDC, rest.x, 0, half.x, Hd, imageDC, window.s.x, window.s.y + rWH.y, SRCCOPY); //B BitBlt(TempDC, rest.x, Hd, half.x, rest.y, imageDC, window.s.x, window.s.y + half.y, SRCCOPY); } //C BitBlt(TempDC, 0, rest.y, rest.x, half.y, imageDC, window.s.x + half.x, window.s.y, SRCCOPY); //D BitBlt(TempDC, 0, 0, rest.x, rest.y, imageDC, window.s.x + half.x, window.s.y + half.y, SRCCOPY); BitBlt(imageDC, window.s.x, window.s.y, window.size.x, window.size.y, TempDC, 0, 0, SRCCOPY); stVertical->Caption = dncount; } TempImage->DeleteDC(TempDC); Image->Bitmap->DeleteDC(imageDC); if (hRgn) { Image->Bitmap->PutRegion(hRgn); DeleteObject(hRgn); } delete TempImage; ::RepaintImage(); Screen->Cursor = OldCursor; return; fail: if (undoSw == true) { if (TempImage) { if (TempDC) { if (imageDC) Image->Bitmap->DeleteDC(imageDC); if (hRgn) { Image->Bitmap->PutRegion(hRgn); DeleteObject(hRgn); } TempImage->DeleteDC(TempDC); } delete TempImage; } Undo->RemoveLast(); } Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::RecoverABCDDown(TObject *Sender) { int Wd, Hd; TPoint half, rest, rWH; TTexpiaBitmap *TempImage = NULL; TCursor OldCursor; HDC imageDC = NULL, TempDC = NULL; int ec = EC_NONE; bool undoSw = false; HRGN hRgn = NULL; dncount--; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; if ((undoSw = MainImageForm->UndoSave(UK_PATTERN, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height))) == false) goto fail; Wdiv = spEditW->Value; Hdiv = spEditH->Value; half = Point(window.size.x / 2.0, window.size.y / 2.0); rest = Point(window.size.x - half.x, window.size.y - half.y); if (WInd == 0) { Wd = Wdiv - half.x; rWH.x = rest.x - Wd; } else { Wd = Wdiv; rWH.x = half.x - Wd; } if (HInd == 0) { Hd = Hdiv - half.y; rWH.y = rest.y - Hd; } else { Hd = Hdiv; rWH.y = half.y - Hd; } if ((TempImage = new TTexpiaBitmap) == NULL) {ec = EC_MEMORY_LACK; goto fail;} if (Image->Bitmap->BitsPerPixel==8) { if (!TempImage->Create(window.size.x, window.size.y, 8, rgb)) {ec = EC_MEMORY_LACK; goto fail;} } else { if (!TempImage->Create(window.size.x, window.size.y, 24)) {ec = EC_MEMORY_LACK; goto fail;} } if ((TempDC = TempImage->CreateDC()) == NULL) {ec = EC_RESOURCE_LACK; goto fail;} hRgn = Image->Bitmap->GetRegion(true); if ((imageDC = Image->Bitmap->CreateDC()) == NULL) {ec = EC_RESOURCE_LACK; goto fail;} if (Item == TREPEAT_MNORMAL) { //A BitBlt(TempDC, 0, 0, half.x, half.y, imageDC, window.s.x + rest.x, window.s.y + rest.y, SRCCOPY); //B BitBlt(TempDC, 0, half.y, half.x, rest.y, imageDC, window.s.x + rest.x, window.s.y, SRCCOPY); //C BitBlt(TempDC, half.x, 0, rest.x, half.y, imageDC, window.s.x, window.s.y + rest.y, SRCCOPY); //D BitBlt(TempDC, half.x, half.y, rest.x, rest.y, imageDC, window.s.x, window.s.y, SRCCOPY); BitBlt(imageDC, window.s.x, window.s.y, window.size.x, window.size.y, TempDC, 0, 0, SRCCOPY); stNormal->Caption = dncount; } else if (Item == TREPEAT_MHOR) { if (WInd == 0) { //A BitBlt(TempDC, 0, 0, half.x, half.y, imageDC, window.s.x + Wd, window.s.y + rest.y, SRCCOPY); //C1 BitBlt(TempDC, half.x, 0, rWH.x, half.y, imageDC, window.s.x + half.x + Wd, window.s.y + rest.y, SRCCOPY); //C2 BitBlt(TempDC, half.x + rWH.x, 0, Wd, half.y, imageDC, window.s.x, window.s.y + rest.y, SRCCOPY); } else { //A1 BitBlt(TempDC, 0, 0, rWH.x, half.y, imageDC, window.s.x + Wd + rest.x, window.s.y + rest.y, SRCCOPY); //A2 BitBlt(TempDC, rWH.x, 0, Wd, half.y, imageDC, window.s.x, window.s.y + rest.y, SRCCOPY); //C BitBlt(TempDC, half.x, 0, rest.x, half.y, imageDC, window.s.x + Wd, window.s.y + rest.y, SRCCOPY); } //B BitBlt(TempDC, 0, half.y, half.x, rest.y, imageDC, window.s.x + rest.x, window.s.y, SRCCOPY); //D BitBlt(TempDC, half.x, half.y, rest.x, rest.y, imageDC, window.s.x, window.s.y, SRCCOPY); BitBlt(imageDC, window.s.x, window.s.y, window.size.x, window.size.y, TempDC, 0, 0, SRCCOPY); stHorizontal->Caption = dncount; } else if (Item == TREPEAT_MVER) { if (HInd == 0) { //A BitBlt(TempDC, 0, 0, half.x, half.y, imageDC, window.s.x + rest.x, window.s.y + Hd, SRCCOPY); //B1 BitBlt(TempDC, 0, half.y, half.x, rWH.y, imageDC, window.s.x + rest.x, window.s.y + half.y + Hd, SRCCOPY); //B2 BitBlt(TempDC, 0, half.y + rWH.y, half.x, Hd, imageDC, window.s.x + rest.x, window.s.y, SRCCOPY); } else { //A1 BitBlt(TempDC, 0, 0, half.x, rWH.y, imageDC, window.s.x + rest.x, window.s.y + Hd + rest.y, SRCCOPY); //A2 BitBlt(TempDC, 0, rWH.y, half.x, Hd, imageDC, window.s.x + rest.x, window.s.y, SRCCOPY); //B BitBlt(TempDC, 0, half.y, half.x, rest.y, imageDC, window.s.x + rest.x, window.s.y + Hd, SRCCOPY); } //C BitBlt(TempDC, half.x, 0, rest.x, half.y, imageDC, window.s.x, window.s.y + rest.y, SRCCOPY); //D BitBlt(TempDC, half.x, half.y, rest.x, rest.y, imageDC, window.s.x, window.s.y, SRCCOPY); BitBlt(imageDC, window.s.x, window.s.y, window.size.x, window.size.y, TempDC, 0, 0, SRCCOPY); stVertical->Caption = dncount; } TempImage->DeleteDC(TempDC); Image->Bitmap->DeleteDC(imageDC); if (hRgn) { Image->Bitmap->PutRegion(hRgn); DeleteObject(hRgn); } delete TempImage; ::RepaintImage(); Screen->Cursor = OldCursor; return; fail: if (undoSw) { if (TempImage) { if (TempDC) { if (imageDC) Image->Bitmap->DeleteDC(imageDC); if (hRgn) { Image->Bitmap->PutRegion(hRgn); DeleteObject(hRgn); } TempImage->DeleteDC(TempDC); } delete TempImage; } Undo->RemoveLast(); } Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::SelectFocus(TObject *Sender, TShiftState Shift, int X, int Y) { TImage *s; s = (TImage *)Sender; if (s == RepeatCell1) { StdArrowL->Visible = true; StdArrowR->Visible = false; } else if (s == RepeatCell2) { StdArrowL->Visible = false; StdArrowR->Visible = true; } else if (s == RepeatCell3) { HozArrowL->Visible = true; HozArrowR->Visible = false; } else if (s == RepeatCell4) { HozArrowL->Visible = false; HozArrowR->Visible = true; } else if (s == RepeatCell5) { VerArrowL->Visible = true; VerArrowR->Visible = false; } else if (s == RepeatCell6) { VerArrowL->Visible = false; VerArrowR->Visible = true; } else if (s == RepeatCell7) { HozArrowL->Visible = false; HozArrowR->Visible = true; } else if (s == RepeatCell8) { VerArrowL->Visible = false; VerArrowR->Visible = true; } } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::FunctionClick(TObject *Sender) { TSpeedButton *s; HDC imageDC; HRGN hRgn = NULL; s = (TSpeedButton *)Sender; hRgn = Image->Bitmap->GetRegion(true); if (s == sbNormal) { sbNormal->Down = true; RepeatImage->Visible = true; Item = TREPEAT_NORMAL; PreViewPanel->BringToFront(); ComboBoxWH->Enabled = false; LabelMax->Enabled = false; } else if (s == sbHDVer) { sbHDVer->Down = true; RepeatImage->Visible = true; Item = TREPEAT_HDVER; PreViewPanel->BringToFront(); ComboBoxWH->Enabled = true; ComboBoxWH->Text = Hdiv; LabelMax->Enabled = true; LabelMax->Caption = Format("Max : %d", OPENARRAY(TVarRec, ((int)spEditH->MaxValue))); } else if (s == sbHDHor) { sbHDHor->Down = true; RepeatImage->Visible = true; Item = TREPEAT_HDHOR; PreViewPanel->BringToFront(); ComboBoxWH->Enabled = true; ComboBoxWH->Text = Wdiv; LabelMax->Enabled = true; LabelMax->Caption = Format("Max : %d", OPENARRAY(TVarRec, ((int)spEditW->MaxValue))); } if ((imageDC = Image->Bitmap->CreateDC()) == NULL) goto fail; if (Image->Bitmap->BitsPerPixel==8) { Image1->Picture->Bitmap->PixelFormat = pf8bit; Image1->Picture->Bitmap->Width = window.size.x; Image1->Picture->Bitmap->Height = window.size.y; SetDIBColorTable(Image1->Picture->Bitmap->Canvas->Handle, 0, 256, rgb); } else { Image1->Picture->Bitmap->PixelFormat = pf24bit; Image1->Picture->Bitmap->Width = window.size.x; Image1->Picture->Bitmap->Height = window.size.y; } BitBlt(Image1->Picture->Bitmap->Canvas->Handle, 0, 0, window.size.x, window.size.y, imageDC, window.s.x, window.s.y, SRCCOPY); Image->Bitmap->DeleteDC(imageDC); if (hRgn) { Image->Bitmap->PutRegion(hRgn); DeleteObject(hRgn); } SetRepeatImage(); m_type = 0; return; fail: if (hRgn) { Image->Bitmap->PutRegion(hRgn); DeleteObject(hRgn); } EXCEPTION_MESSAGE_OK(EC_RESOURCE_LACK); } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::FunctionMatchClick(TObject *Sender) { TSpeedButton *s = (TSpeedButton *) Sender; if (s == sbMatchNormal) { sbMatchNormal->Down = true; RepeatImage->Visible = false; Item = TREPEAT_MNORMAL; NormalPanel->BringToFront(); if (bChange) dncount = 0; stNormal->Caption = dncount; m_type = 1; } else if (s == sbMatchVer) { sbMatchVer->Down = true; RepeatImage->Visible = false; Item = TREPEAT_MVER; VerPanel->BringToFront(); spEditH->Value = Hdiv; LabelH->Caption = AnsiString(IDS_COMMON_HEIGHT) + Format(" (0 - %d)", OPENARRAY (TVarRec, ((int)spEditH->MaxValue))); if (bChange) dncount = 0; stVertical->Caption = dncount; m_type = 2; spEditH->SetFocus(); } else if (s == sbMatchHor) { sbMatchHor->Down = true; RepeatImage->Visible = false; Item = TREPEAT_MHOR; HorPanel->BringToFront(); spEditW->Value = Wdiv; LabelW->Caption = AnsiString(IDS_COMMON_WIDTH) + Format(" (0 - %d)", OPENARRAY (TVarRec, ((int)spEditW->MaxValue))); if (bChange) dncount = 0; stHorizontal->Caption = dncount; m_type = 3; spEditW->SetFocus(); } SetRepeatImage(); } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::spEditClick(TObject *Sender) { ((TPSpinEdit *) Sender)->SelectAll(); ((TPSpinEdit *) Sender)->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::spEditChange(TObject *Sender) { TPSpinEdit *s = (TPSpinEdit *) Sender; if (s->Text.Length()>0) { int w = window.size.x / 2; int h = window.size.y / 2; int val = s->Value; if (s->Tag) { if (val < h) { HInd = 1; Panel3->Visible = false; Panel4->Visible = true; } else { HInd = 0; Panel3->Visible = true; Panel4->Visible = false; } Hdiv = val; } else { if (val < w) { WInd = 1; Panel1->Visible = false; Panel2->Visible = true; } else { WInd = 0; Panel1->Visible = true; Panel2->Visible = false; } Wdiv = val; } } } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::ComboBoxWHChange(TObject *Sender) { if (Item == TREPEAT_HDHOR) { switch (ComboBoxWH->ItemIndex) { case 0: Wdiv = window.size.x / 8; break; case 1: Wdiv = window.size.x / 4; break; case 2: Wdiv = window.size.x / 2; break; case 3: Wdiv = 3 * window.size.x / 4; break; case 4: Wdiv = 7 * window.size.x / 8; break; } spEditW->Value = Wdiv; } else if (Item == TREPEAT_HDVER) { switch (ComboBoxWH->ItemIndex) { case 0: Hdiv = window.size.y / 8; break; case 1: Hdiv = window.size.y / 4; break; case 2: Hdiv = window.size.y / 2; break; case 3: Hdiv = 3 * window.size.y / 4; break; case 4: Hdiv = 7 * window.size.y / 8; break; } spEditH->Value = Hdiv; } if (ComboBoxWH->ItemIndex >= 0) SetRepeatImage(); } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::ComboBoxWHKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == VK_RETURN) { if (InvalidInput() == false) return; int value = StrToInt(ComboBoxWH->Text); if (sbHDVer->Down) { if (value > spEditH->MaxValue) { value = spEditH->MaxValue; ComboBoxWH->Text = value; } Hdiv = value; spEditH->Value = value; } if (sbHDHor->Down) { if (value > spEditW->MaxValue) { value = spEditW->MaxValue; ComboBoxWH->Text = value; } Wdiv = value; spEditW->Value = value; } SetRepeatImage(); } } //--------------------------------------------------------------------------- bool __fastcall TRepeatForm::InvalidInput() { AnsiString str = ComboBoxWH->Text; for (int i = 0; i < ComboBoxWH->Items->Count; i++) { if (str == ComboBoxWH->Items->Strings[i]) return false; } return true; } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::LabelSizeClick(TObject *Sender) { if (selectsize) { selectsize = false; LabelSize->Caption = IDS_FALSE; spEditX->Enabled = false; spEditY->Enabled = false; LabelCross->Enabled = false; } else { selectsize = true; LabelSize->Caption = IDS_TRUE; spEditX->Enabled = true; spEditY->Enabled = true; LabelCross->Enabled = true; } } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::ComboBoxWHDblClick(TObject *Sender) { ComboBoxWH->SetFocus(); ComboBoxWH->SelectAll(); } //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- bool __fastcall TRepeatForm::MakeRepeatImage(TTexpiaBitmap *Mask, TTexpiaBitmap *Bitmap) { HDC dcDst = NULL, dcSrc = NULL, dcMask = NULL, dcBitmap = NULL; int x, y, p, Gap; if((dcDst = RepeatImage->Bitmap->CreateDC()) == NULL) goto fail; if ((dcSrc = Image->Bitmap->CreateDC()) == NULL) goto fail; if ((dcMask = Mask->CreateDC()) == NULL) goto fail; if ((dcBitmap = Bitmap->CreateDC()) == NULL) goto fail; if (Item == TREPEAT_NORMAL) { y = window.s.y%window.size.y; if (y) y -= window.size.y; for (; yBitmap->Height; y+=window.size.y) { x = window.s.x%window.size.x; if (x) x -= window.size.x; for (; xBitmap->Width; x+=window.size.x) { BitBlt(dcDst, x, y, window.size.x, window.size.y, dcSrc, x, y, SRCCOPY); BitBlt(dcDst, x, y, window.size.x, window.size.y, dcMask, 0, 0, SRCAND); BitBlt(dcDst, x, y, window.size.x, window.size.y, dcBitmap, 0, 0, SRCPAINT); } } } else if (Item == TREPEAT_HDHOR) { Gap = spEditW->Value; p = window.s.x-((window.s.y-1)/window.size.y+1)*Gap; y = window.s.y%window.size.y; y -= window.size.y; for (; yBitmap->Height; y+=window.size.y, p+=Gap) { x = p%window.size.x; if (x) x -= window.size.x; for (; xBitmap->Width; x+=window.size.x) { BitBlt(dcDst, x, y, window.size.x, window.size.y, dcSrc, x, y, SRCCOPY); BitBlt(dcDst, x, y, window.size.x, window.size.y, dcMask, 0, 0, SRCAND); BitBlt(dcDst, x, y, window.size.x, window.size.y, dcBitmap, 0, 0, SRCPAINT); } } } else if (Item == TREPEAT_HDVER) { Gap = spEditH->Value; p = window.s.y-((window.s.x-1)/window.size.x+1)*Gap; x = window.s.x%window.size.x; x -= window.size.x; for (; xBitmap->Width; x+=window.size.x, p+=Gap) { y = p%window.size.y; if (y) y -= window.size.y; for (; yBitmap->Height; y+=window.size.y) { BitBlt(dcDst, x, y, window.size.x, window.size.y, dcSrc, x, y, SRCCOPY); BitBlt(dcDst, x, y, window.size.x, window.size.y, dcMask, 0, 0, SRCAND); BitBlt(dcDst, x, y, window.size.x, window.size.y, dcBitmap, 0, 0, SRCPAINT); } } } Bitmap->DeleteDC(dcBitmap); Mask->DeleteDC(dcMask); Image->Bitmap->DeleteDC(dcSrc); RepeatImage->Bitmap->DeleteDC(dcDst); return true; fail: if (dcBitmap) Bitmap->DeleteDC(dcBitmap); if (dcMask) Mask->DeleteDC(dcMask); if (dcSrc) Image->Bitmap->DeleteDC(dcSrc); if (dcDst) RepeatImage->Bitmap->DeleteDC(dcDst); return false; } //--------------------------------------------------------------------------- bool __fastcall TRepeatForm::SubMouseDown(int X, int Y) { Byte *IP = 0, *RP = 0, *MP = 0; bool undoSw = false; COLORREF color, ic, rc, bgc; int i, j; MainImageForm->WorkArea->PushUndo(); if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0, 0, Image->Bitmap->Width, Image->Bitmap->Height))) == false) goto fail; if (MainImageForm->MaskArea) { if (!Image->Bitmap->StartScanLine()) goto fail; if (!Image->Mask->StartScanLine()) goto fail; if (!RepeatImage->Bitmap->StartScanLine()) goto fail; if (FullViewForm->Super==sOverlap) { MainImageForm->InitOverlap(); if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (i=RepeatRect.s.y; iBitmap->GetScanLine(i)+RepeatRect.s.x; MP = Image->Mask->GetScanLine(i)+RepeatRect.s.x; RP = RepeatImage->Bitmap->GetScanLine(i)+RepeatRect.s.x; for (j=RepeatRect.s.x; jPalette->ColorData[*IP]->Protect==0 && (*MP == 0)) { if (*IP > 1) { color = MainImageForm->Overlap(*IP, *RP); if (color==0xFF) { MainImageForm->ExitOverlap(); RepeatImage->Bitmap->StopScanLine(); Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); return false; } else { *IP = color; } } else *IP = *RP; } } Image->Bitmap->PutScanLine(i); } } else { for (i=RepeatRect.s.y; iBitmap->GetScanLine(i)+RepeatRect.s.x; MP = Image->Mask->GetScanLine(i)+RepeatRect.s.x; RP = RepeatImage->Bitmap->GetScanLine(i)+RepeatRect.s.x; for (j=RepeatRect.s.x; j 1) { color = MainImageForm->Overlap(*IP, *RP); if (color==0xFF) { MainImageForm->ExitOverlap(); RepeatImage->Bitmap->StopScanLine(); Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); return false; } else { *IP = color; } } else *IP = *RP; } } Image->Bitmap->PutScanLine(i); } } } else { bgc = MainImageForm->Palette->Color[1]; for (i=RepeatRect.s.y; iBitmap->GetScanLine(i)+3*RepeatRect.s.x; MP = Image->Mask->GetScanLine(i); RP = RepeatImage->Bitmap->GetScanLine(i)+3*RepeatRect.s.x; for (j=RepeatRect.s.x; j> 3] & (0x80 >> (j & 7))) == 0) { GetPixel24(IP, ic); if (ic != bgc) { GetPixel24(RP, rc); color = MainImageForm->Overlap(ic, rc); SetPixel24(IP, color); } else CopyPixel24(IP, RP); } } Image->Bitmap->PutScanLine(i); } } MainImageForm->ExitOverlap(); } else { if (Image->Bitmap->BitsPerPixel==8) { for (i=RepeatRect.s.y; iBitmap->GetScanLine(i)+RepeatRect.s.x; MP = Image->Mask->GetScanLine(i)+RepeatRect.s.x; RP = RepeatImage->Bitmap->GetScanLine(i)+RepeatRect.s.x; for (j=RepeatRect.s.x; jBitmap->PutScanLine(i); } } else { for (i=RepeatRect.s.y; iBitmap->GetScanLine(i)+3*RepeatRect.s.x; MP = Image->Mask->GetScanLine(i); RP = RepeatImage->Bitmap->GetScanLine(i)+3*RepeatRect.s.x; for (j=RepeatRect.s.x; j> 3] & (0x80 >> (j & 7))) == 0) { GetPixel24(RP, color); SetPixel24(IP, color); } } Image->Bitmap->PutScanLine(i); } } } RepeatImage->Bitmap->StopScanLine(); Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); } else { if (FullViewForm->Super==sOverlap) { if (!Image->Bitmap->StartScanLine()) goto fail; if (!RepeatImage->Bitmap->StartScanLine()) goto fail; MainImageForm->InitOverlap(); if (Image->Bitmap->BitsPerPixel==8) { if (MainImageForm->Protect) { for (i=RepeatRect.s.y; iBitmap->GetScanLine(i)+RepeatRect.s.x; RP = RepeatImage->Bitmap->GetScanLine(i)+RepeatRect.s.x; for (j=RepeatRect.s.x; jPalette->ColorData[*IP]->Protect==0) { if (*IP > 1) { color = MainImageForm->Overlap(*IP, *RP); if (color==0xFF) { MainImageForm->ExitOverlap(); RepeatImage->Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); return false; } else { *IP = color; } } else *IP = *RP; } } Image->Bitmap->PutScanLine(i); } } else { for (i=RepeatRect.s.y; iBitmap->GetScanLine(i)+RepeatRect.s.x; RP = RepeatImage->Bitmap->GetScanLine(i)+RepeatRect.s.x; for (j=RepeatRect.s.x; j 1) { color = MainImageForm->Overlap(*IP, *RP); if (color==0xFF) { MainImageForm->ExitOverlap(); RepeatImage->Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); return false; } else { *IP = color; } } else *IP = *RP; } Image->Bitmap->PutScanLine(i); } } } else { bgc = MainImageForm->Palette->Color[1]; for (i=RepeatRect.s.y; iBitmap->GetScanLine(i)+3*RepeatRect.s.x; RP = RepeatImage->Bitmap->GetScanLine(i)+3*RepeatRect.s.x; for (j=RepeatRect.s.x; jOverlap(ic, rc); SetPixel24(IP, color); } else CopyPixel24(IP, RP); } Image->Bitmap->PutScanLine(i); } } MainImageForm->ExitOverlap(); RepeatImage->Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); } else { Image->Bitmap->Copy(RepeatRect.s.x, RepeatRect.s.y, RepeatRect.size.x, RepeatRect.size.y, RepeatImage->Bitmap, RepeatRect.s.x, RepeatRect.s.y, SRCCOPY); } } MainImageForm->WorkArea->SetRectangle(Rect(RepeatRect.s.x, RepeatRect.s.y, RepeatRect.e.x, RepeatRect.e.y)); MainImageForm->WorkAreaChange(); return true; fail: RepeatImage->Bitmap->StopScanLine(); Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); if (undoSw == true) Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return false; } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::SubMouseMove(int X, int Y) { int valueX = 1, valueY = 1; int limX = 0, limY = 0; if ((Item == TREPEAT_NORMAL) || (Item == TREPEAT_HDHOR) || (Item == TREPEAT_HDVER)) { if (X < 0) X = 0; else if (X > Image->Bitmap->Width) X = Image->Bitmap->Width; if (Y < 0) Y = 0; else if (Y > Image->Bitmap->Height) Y = Image->Bitmap->Height; if (selectsize) { valueX = spEditX->Value; valueY = spEditY->Value; if (X < (window.s.x + window.size.x / 2)) { limX = window.s.x - (window.size.x * (valueX - 1)); if (limX < 0) limX = 0; RepeatRect.s.x = limX; RepeatRect.e.x = window.e.x; } else { limX = window.s.x + (window.size.x * valueX); if (limX > Image->Bitmap->Width) limX = Image->Bitmap->Width; RepeatRect.s.x = window.s.x; RepeatRect.e.x = limX; } if (Y < (window.s.y + window.size.y / 2)) { limY = window.s.y - (window.size.y * (valueY - 1)); if (limY < 0) limY = 0; RepeatRect.s.y = limY; RepeatRect.e.y = window.e.y; } else { limY = window.s.y + (window.size.y * valueY); if (limY > Image->Bitmap->Height) limY = Image->Bitmap->Height; RepeatRect.s.y = window.s.y; RepeatRect.e.y = limY; } } else { if (X < window.s.x) { RepeatRect.s.x = X; RepeatRect.e.x = window.e.x; } else { RepeatRect.s.x = window.s.x; RepeatRect.e.x = X; } if (Y < window.s.y) { RepeatRect.s.y = Y; RepeatRect.e.y = window.e.y; } else { RepeatRect.s.y = window.s.y; RepeatRect.e.y = Y; } } RepeatRect.size.x = RepeatRect.e.x - RepeatRect.s.x; RepeatRect.size.y = RepeatRect.e.y - RepeatRect.s.y; RepeatImage->Left = Image->BitmapToCanvasX(RepeatRect.s.x); RepeatImage->Top = Image->BitmapToCanvasY(RepeatRect.s.y); RepeatImage->Width = RepeatRect.size.x * RepeatImage->ZoomIn / RepeatImage->ZoomOut; RepeatImage->Height = RepeatRect.size.y * RepeatImage->ZoomIn / RepeatImage->ZoomOut; #if defined(KNIT) RepeatImage->SetPosition(RepeatRect.s.x, Image->Bitmap->Height-RepeatRect.s.y-RepeatRect.size.y); #else RepeatImage->SetPosition(RepeatRect.s.x, RepeatRect.s.y); #endif } } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- void __fastcall TRepeatForm::InitForm() { TCursor OldCursor; int w, h; ParentHeight = Parent->Height+20; ClientHeight = 191; Parent->Height = ParentHeight+ClientHeight; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; Image = MainImageForm->iMainImage; RepeatImage = MainImageForm->iSelectImage; window.s.x = MainImageForm->WorkArea->Range.left; window.s.y = MainImageForm->WorkArea->Range.top; window.e.x = MainImageForm->WorkArea->Range.right; window.e.y = MainImageForm->WorkArea->Range.bottom; window.size.x = window.e.x - window.s.x; window.size.y = window.e.y - window.s.y; RepeatRect.s = window.s; RepeatRect.e = window.e; RepeatRect.size = window.size; RepeatRect.Bitmap = 0; RepeatRect.Mask = 0; RepeatRect.Back = 0; if (Image->Bitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); } RepeatImage->Left = Image->BitmapToCanvasX(window.s.x); RepeatImage->Top = Image->BitmapToCanvasY(window.s.y); selectsize = false; LabelSize->Caption = IDS_FALSE; spEditX->Enabled = false; spEditY->Enabled = false; LabelCross->Enabled = false; WInd = HInd = 0; spEditW->MaxValue = window.size.x - 1; spEditH->MaxValue = window.size.y - 1; Wdiv = window.size.x / 2; Hdiv = window.size.y / 2; ReadIniFile(w, h); if (bChange == false) { switch (m_type) { case 1: sbMatchNormal->Down = true; sbMatchNormal->Click(); break; case 2: Hdiv = h; sbMatchVer->Down = true; sbMatchVer->Click(); break; case 3: Wdiv = w; sbMatchHor->Down = true; sbMatchHor->Click(); break; default: sbNormal->Down = true; sbNormal->Click(); } } else { sbNormal->Down = true; sbNormal->Click(); } bChange = true; spEditW->Value = Wdiv; spEditH->Value = Hdiv; Screen->Cursor = OldCursor; } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::ExitForm(void) { WriteIniFile(); RepeatImage->Bitmap->Destroy(); RepeatImage->Width = 0; RepeatImage->Height = 0; RepeatImage->Visible = false; } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::ReadIniFile(int &mw, int &mh) { TIniFile *RepeatIni = NULL; int sx, sy, w, h, index; RepeatIni = new TIniFile(DirectoryItem + "\\Repeat.ini"); if (RepeatIni) { index = RepeatIni->ReadInteger("Key", "Index", -1); sx = RepeatIni->ReadInteger("WorkArea", "Left", 0); sy = RepeatIni->ReadInteger("WorkArea", "Top", 0); w = RepeatIni->ReadInteger("WorkArea", "Width", 0); h = RepeatIni->ReadInteger("WorkArea", "Height", 0); m_type = RepeatIni->ReadInteger("Match", "Type", 0); mw = RepeatIni->ReadInteger("Match", "Width", 0); mh = RepeatIni->ReadInteger("Match", "Height", 0); dncount = RepeatIni->ReadInteger("Match", "Count", 0); delete RepeatIni; } if (MainImageForm->Number == index && sx == window.s.x && sy == window.s.y && w == window.size.x && h == window.size.y) { bChange = false; } else { bChange = true; m_type = mw = mh = dncount = 0; } } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::WriteIniFile() { TIniFile *RepeatIni = NULL; RepeatIni = new TIniFile(DirectoryItem + "\\Repeat.ini"); if (RepeatIni) { RepeatIni->WriteInteger("Key", "Index", MainImageForm->Number); RepeatIni->WriteInteger("WorkArea", "Left", window.s.x); RepeatIni->WriteInteger("WorkArea", "Top", window.s.y); RepeatIni->WriteInteger("WorkArea", "Width", window.size.x); RepeatIni->WriteInteger("WorkArea", "Height", window.size.y); RepeatIni->WriteInteger("Match", "Type", m_type); RepeatIni->WriteInteger("Match", "Width", Wdiv); RepeatIni->WriteInteger("Match", "Height", Hdiv); RepeatIni->WriteInteger("Match", "Count", dncount); delete RepeatIni; } } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::SetRepeatImage(void) { TCursor OldCursor; int ww, hh, x, y, Gap; Byte *isp, *idp, *msp, *mdp, mm, *wp, *mp, *mmp; TTexpiaBitmap *Mask = NULL, *Bitmap = NULL; int cx, cy, lx, ly, xx, yy; COLORREF bgc, c; int ec = EC_NONE; OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; RepeatImage->Width = 0; RepeatImage->Height = 0; ww = Image->Bitmap->Width; hh = Image->Bitmap->Height; if (!RepeatImage->Bitmap->Create(ww, hh, Image->Bitmap->BitsPerPixel)) { MessageDlg(IDS_MESSAGE_NOTENOUGHSPACE, mtError, TMsgDlgButtons() << mbOK, 0); PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); } else { RepeatImage->SetPosition(0, 0); if (Image->Bitmap->BitsPerPixel==8) { RepeatImage->Bitmap->PutColors(0, 256, rgb); if ((Bitmap = new TTexpiaBitmap) == NULL) {ec = EC_MEMORY_LACK; goto fail;} if (!Bitmap->Create(window.size.x, window.size.y, 8, rgb)) {ec = EC_MEMORY_LACK; goto fail;} if ((Mask = new TTexpiaBitmap) == NULL) {ec = EC_MEMORY_LACK; goto fail;} if (!Mask->Create(window.size.x, window.size.y, 8, rgb)) {ec = EC_MEMORY_LACK; goto fail;} if (!Image->Bitmap->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!Bitmap->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!MainImageForm->WorkArea->Mask->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!Mask->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} switch (FullViewForm->Super) { case sOff: for (y=0; yBitmap->GetScanLine(window.s.y+y)+window.s.x; idp = Bitmap->GetScanLine(y); msp = MainImageForm->WorkArea->Mask->GetScanLine(y); mdp = Mask->GetScanLine(y); for (x=0; xPutScanLine(y); Mask->PutScanLine(y); } break; case sOverlap: case sNormal: for (y=0; yBitmap->GetScanLine(window.s.y+y)+window.s.x; idp = Bitmap->GetScanLine(y); msp = MainImageForm->WorkArea->Mask->GetScanLine(y); mdp = Mask->GetScanLine(y); for (x=0; x1) { *idp = *isp; *mdp = 0; } else { *idp = 0; *mdp = 0xFF; } } Bitmap->PutScanLine(y); Mask->PutScanLine(y); } break; case sGauze: for (y=0; yBitmap->GetScanLine(window.s.y+y)+window.s.x; idp = Bitmap->GetScanLine(y); msp = MainImageForm->WorkArea->Mask->GetScanLine(y); for (x=0; x1) *idp = *isp; else *idp = 0; } Bitmap->PutScanLine(y); } break; } Mask->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); if (MainImageForm->MaskArea) { if (!Image->Mask->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!RepeatImage->Bitmap->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (MainImageForm->Protect) { switch (FullViewForm->Super) { case sOff: case sOverlap: if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0) && (*mp == 0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0) && (*mp == 0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (x=0; xBitmap->GetScanLine(x); mp = Image->Mask->GetScanLine(x); idp = RepeatImage->Bitmap->GetScanLine(x); for (y=0; yGetScanLine(ly); if (wp[lx] && (MainImageForm->Palette->ColorData[*isp]->Protect==0) && (*mp == 0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(x); } } break; case sNormal: if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0) && *isp>1 && (*mp == 0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0) && *isp>1 && (*mp == 0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (x=0; xBitmap->GetScanLine(x); mp = Image->Mask->GetScanLine(x); idp = RepeatImage->Bitmap->GetScanLine(x); for (y=0; yGetScanLine(ly); if (wp[lx] && (MainImageForm->Palette->ColorData[*isp]->Protect==0) && *isp>1 && (*mp == 0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(x); } } break; case sGauze: if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0) && (*mp == 0)) { if (*isp > 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0) && (*mp == 0)) { if (*isp > 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (x=0; xBitmap->GetScanLine(x); mp = Image->Mask->GetScanLine(x); idp = RepeatImage->Bitmap->GetScanLine(x); for (y=0; yGetScanLine(ly); if (wp[lx] && (MainImageForm->Palette->ColorData[*isp]->Protect==0) && (*mp == 0)) { if (*isp > 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(x); } } break; } } else { if (FullViewForm->Super == sGauze) { if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else { *idp = wp[lx]; } } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xGetScanLine(ly); if (wp[lx] && (*mp == 0)) { if (*isp > 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } } else { if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xBitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xBitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xGetScanLine(ly); if (wp[lx] && (*mp == 0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(y); } } } } RepeatImage->Bitmap->StopScanLine(); Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); Image->Mask->StopScanLine(); } else { if (MainImageForm->Protect) { if (!RepeatImage->Bitmap->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} switch (FullViewForm->Super) { case sOff: case sOverlap: if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (x=0; xBitmap->GetScanLine(x); idp = RepeatImage->Bitmap->GetScanLine(x); for (y=0; yGetScanLine(ly); if (wp[lx] && (MainImageForm->Palette->ColorData[*isp]->Protect==0)) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(x); } } break; case sNormal: if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0) && *isp>1) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0) && *isp>1) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (x=0; xBitmap->GetScanLine(x); idp = RepeatImage->Bitmap->GetScanLine(x); for (y=0; yGetScanLine(ly); if (wp[lx] && (MainImageForm->Palette->ColorData[*isp]->Protect==0) && *isp>1) { *idp = wp[lx]; } else { *idp = *isp; } } RepeatImage->Bitmap->PutScanLine(x); } } break; case sGauze: if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0)) { if (*isp > 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xPalette->ColorData[*isp]->Protect==0)) { if (*isp > 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (x=0; xBitmap->GetScanLine(x); idp = RepeatImage->Bitmap->GetScanLine(x); for (y=0; yGetScanLine(ly); if (wp[lx] && (MainImageForm->Palette->ColorData[*isp]->Protect==0)) { if (*isp > 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(x); } } break; } RepeatImage->Bitmap->StopScanLine(); Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); } else { if (FullViewForm->Super == sGauze) { if (!RepeatImage->Bitmap->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (y=0; yBitmap->GetScanLine(y); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xGetScanLine(ly); if (wp[lx]) { if (*isp > 1) { if ((x+y)&1) { *idp = wp[lx]; } else { *idp = *isp; } } else *idp = wp[lx]; } else *idp = *isp; } RepeatImage->Bitmap->PutScanLine(y); } } RepeatImage->Bitmap->StopScanLine(); Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); } else { Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); if (!MakeRepeatImage(Mask, Bitmap)) {ec = EC_RESOURCE_LACK; goto fail;} } } } delete Bitmap; Bitmap = NULL; delete Mask; Mask = NULL; } else { if ((Bitmap = new TTexpiaBitmap) == NULL) {ec = EC_MEMORY_LACK; goto fail;} if (!Bitmap->Create(window.size.x, window.size.y, 24)) {ec = EC_MEMORY_LACK; goto fail;} if ((Mask = new TTexpiaBitmap) == NULL) {ec = EC_MEMORY_LACK; goto fail;} if (!Mask->Create(window.size.x, window.size.y, 1)) {ec = EC_MEMORY_LACK; goto fail;} if (!Image->Bitmap->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!Bitmap->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!MainImageForm->WorkArea->Mask->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!Mask->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} bgc = MainImageForm->Palette->Color[1]; switch (FullViewForm->Super) { case sOff: for (y=0; yBitmap->GetScanLine(window.s.y+y)+3*window.s.x; idp = Bitmap->GetScanLine(y); msp = MainImageForm->WorkArea->Mask->GetScanLine(y); mdp = Mask->GetScanLine(y); *mdp = 0; mm = 0x80; for (x=0; x>= 1; } Bitmap->PutScanLine(y); Mask->PutScanLine(y); } break; case sOverlap: case sNormal: case sGauze: bgc = MainImageForm->Palette->Color[1]; for (y=0; yBitmap->GetScanLine(window.s.y+y)+3*window.s.x; idp = Bitmap->GetScanLine(y); msp = MainImageForm->WorkArea->Mask->GetScanLine(y); mdp = Mask->GetScanLine(y); *mdp = 0; mm = 0x80; for (x=0; x>= 1; } Bitmap->PutScanLine(y); Mask->PutScanLine(y); } break; } Mask->StopScanLine(); if (MainImageForm->MaskArea) { if (!Image->Mask->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!RepeatImage->Bitmap->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!Mask->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (FullViewForm->Super==sGauze) { if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); mdp = Mask->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x> 3] & (0x80 >> (lx & 7))) == 0) && ((mp[x >> 3] & (0x80 >> (x & 7))) == 0)) { GetPixel24(isp, c); if (c != bgc) { if ((x+y)&1) { msp = wp + 3*lx; CopyPixel24(idp, msp); } else { CopyPixel24(idp, isp); } } else { msp = wp + 3*lx; CopyPixel24(idp, msp); } } else { CopyPixel24(idp, isp); } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); mdp = Mask->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x> 3] & (0x80 >> (lx & 7))) == 0) && ((mp[x >> 3] & (0x80 >> (x & 7))) == 0)) { GetPixel24(isp, c); if (c != bgc) { if ((x+y)&1) { msp = wp + 3*lx; CopyPixel24(idp, msp); } else { CopyPixel24(idp, isp); } } else { msp = wp + 3*lx; CopyPixel24(idp, msp); } } else { CopyPixel24(idp, isp); } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xGetScanLine(ly) + 3*lx; mdp = Mask->GetScanLine(ly); if (((mdp[lx >> 3] & (0x80 >> (lx & 7))) == 0) && ((mp[x >> 3] & (0x80 >> (x & 7))) == 0)) { GetPixel24(isp, c); if (c != bgc) { if ((x+y)&1) { CopyPixel24(idp, wp); } else { CopyPixel24(idp, isp); } } else { CopyPixel24(idp, wp); } } else { CopyPixel24(idp, isp); } } RepeatImage->Bitmap->PutScanLine(y); } } } else { if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); mdp = Mask->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x> 3] & (0x80 >> (lx & 7))) == 0) && ((mp[x >> 3] & (0x80 >> (x & 7))) == 0)) { msp = wp + 3*lx; GetPixel24(msp, c); SetPixel24(idp, c); } else { CopyPixel24(idp, isp); } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); wp = Bitmap->GetScanLine(ly); mdp = Mask->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x> 3] & (0x80 >> (lx & 7))) == 0) && ((mp[x >> 3] & (0x80 >> (x & 7))) == 0)) { msp = wp + 3*lx; GetPixel24(msp, c); SetPixel24(idp, c); } else { CopyPixel24(idp, isp); } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (y=0; yBitmap->GetScanLine(y); mp = Image->Mask->GetScanLine(y); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xGetScanLine(ly) + 3*lx; mdp = Mask->GetScanLine(ly); if (((mdp[lx >> 3] & (0x80 >> (lx & 7))) == 0) && ((mp[x >> 3] & (0x80 >> (x & 7))) == 0)) { GetPixel24(wp, c); SetPixel24(idp, c); } else { CopyPixel24(idp, isp); } } RepeatImage->Bitmap->PutScanLine(y); } } } RepeatImage->Bitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); Image->Mask->StopScanLine(); Mask->StopScanLine(); } else { if (FullViewForm->Super==sGauze) { if (!RepeatImage->Bitmap->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (!Mask->StartScanLine()) {ec = EC_MEMORY_LACK; goto fail;} if (Item==TREPEAT_NORMAL) { for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); mdp = Mask->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x>3] & (0x80 >> (lx & 7))) == 0) { GetPixel24(isp, c); if (c != bgc) { if ((x+y)&1) { msp = wp + 3*lx; CopyPixel24(idp, msp); } else { CopyPixel24(idp, isp); } } else { msp = wp + 3*lx; CopyPixel24(idp, msp); } } else { CopyPixel24(idp, isp); } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDHOR) { Gap = spEditW->Value; for (y=0; yBitmap->GetScanLine(y); wp = Bitmap->GetScanLine(ly); mdp = Mask->GetScanLine(ly); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; x>3] & (0x80 >> (lx & 7))) == 0) { GetPixel24(isp, c); if (c != bgc) { if ((x+y)&1) { msp = wp + 3*lx; CopyPixel24(idp, msp); } else { CopyPixel24(idp, isp); } } else { msp = wp + 3*lx; CopyPixel24(idp, msp); } } else { CopyPixel24(idp, isp); } } RepeatImage->Bitmap->PutScanLine(y); } } else if (Item==TREPEAT_HDVER) { Gap = spEditH->Value; for (y=0; yBitmap->GetScanLine(y); idp = RepeatImage->Bitmap->GetScanLine(y); for (x=0; xGetScanLine(ly) + 3*lx; mdp = Mask->GetScanLine(ly); if ((mdp[lx>>3] & (0x80 >> (lx & 7))) == 0) { GetPixel24(isp, c); if (c != bgc) { if ((x+y)&1) { CopyPixel24(idp, wp); } else { CopyPixel24(idp, isp); } } else { CopyPixel24(idp, wp); } } else { CopyPixel24(idp, isp); } } RepeatImage->Bitmap->PutScanLine(y); } } Mask->StopScanLine(); RepeatImage->Bitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); } else { MainImageForm->WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); Image->Bitmap->StopScanLine(); if (!MakeRepeatImage(Mask, Bitmap)) {ec = EC_RESOURCE_LACK; goto fail;} } } delete Bitmap; Bitmap = NULL; delete Mask; Mask = NULL; } } Screen->Cursor = OldCursor; return; fail: Mask->StopScanLine(); RepeatImage->Bitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); Bitmap->StopScanLine(); Image->Mask->StopScanLine(); if (Bitmap) delete Bitmap; if (Mask) delete Mask; Screen->Cursor = OldCursor; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::RepeatMouseDown(int X, int Y) { TCursor OldCursor; if ((Item == TREPEAT_NORMAL) || (Item == TREPEAT_HDHOR) || (Item == TREPEAT_HDVER)) { OldCursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (SubMouseDown(X, Y)) { PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); } else { PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); Undo->Read(); } #ifndef CARPET MainMenuForm->showfalse(); /////////////?? carpet¿¡¼­ ¾ÈµÇ±æ·¡ ´ëÃæ¸·¾ÒÀ½. Ç®°í½ÍÀ¸¸é Ǫ½Ã¿À. #endif // ::RepaintColor(); Screen->Cursor = OldCursor; } } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::RepeatMouseMove(int X, int Y) { SubMouseMove(X, Y); } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::iMainImageChange(void) { RepeatImage->Width = 0; RepeatImage->Height = 0; } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::spEditXChange(TObject *Sender) { if (spEditX->Text.Length() > 0) { if (spEditX->Value > spEditX->MaxValue) spEditX->Value = spEditX->MaxValue; else if (spEditX->Value < spEditX->MinValue) spEditX->Value = spEditX->MinValue; } } //--------------------------------------------------------------------------- void __fastcall TRepeatForm::spEditYChange(TObject *Sender) { if (spEditY->Text.Length() > 0) { if (spEditY->Value > spEditY->MaxValue) spEditY->Value = spEditY->MaxValue; else if (spEditY->Value < spEditY->MinValue) spEditY->Value = spEditY->MinValue; } } //---------------------------------------------------------------------------