//-------------------------,x1,,x1,33-------------------------------------------------- #include #include #include #pragma hdrstop #include "Stipple.h" #include "MainImage.h" #include "Palette.h" #include "StatusProgress.h" #include "Undo.h" #include "MainMenu.h" //lhskys Á¾·á½Ã Focus ¸¦ °¡Á®¿À±â À§ÇØ #include "LogData.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzEdit" #pragma link "RzSpnEdt" #pragma link "RzBckgnd" #pragma link "RzButton" #pragma link "RzRadChk" #pragma link "RzLabel" #pragma link "RzCmboBx" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_READYTODRAW StringTable[0] #define IDS_COLORSELECT StringTable[1] #define IDS_TYPE StringTable[2] #define IDS_USER StringTable[3] #define IDS_HOR StringTable[4] #define IDS_VER StringTable[5] #define IDS_ANGLE StringTable[6] #define IDS_PATTERN StringTable[7] //--------------------------------------------------------------------------- TStippleForm *StippleForm; //--------------------------------------------------------------------------- __fastcall TStippleForm::TStippleForm(TComponent* Owner) : TForm(Owner) { //=============================== 2001.9.11 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è StringTable.Create(DirectoryBin, Language, "Stipple"); /* SetSmallFont(Font); SetSmallFont(ColSelectText->Font); SetSmallFont(Label1->Font); SetSmallFont(Label4->Font); SetSmallFont(Label5->Font); SetSmallFont(Label2->Font); SetSmallFont(Label6->Font); SetSmallFont(Label7->Font); SetSmallFont(Label3->Font); SetSmallFont(ColSelectText->Font); SetSmallFont(Label9->Font); SetSmallFont(Label8->Font); */ //ColSelectText->Caption = IDS_READYTODRAW; sbNew->Hint = IDS_COMMON_NEW; sbAll->Hint = IDS_COMMON_ALL; sbOne->Hint = IDS_COMMON_BLOCKCOLOR; sbDelete->Hint = IDS_COMMON_INSERTCOLOR; sbBefore->Hint = IDS_COMMON_BEFORECOLOR; //Label9->Caption = IDS_TYPE; rzmtbtLine->Hint = IDS_COMMON_LINE; rzmtbtCircle->Hint = IDS_COMMON_CIRCLE; rzmtbtRectangle->Hint = IDS_COMMON_RECTANGLE; rzmtbtPattern->Hint = IDS_PATTERN; lbMax->Caption = IDS_COMMON_MAX; lbMin->Caption = IDS_COMMON_MIN; lbGapHorz->Caption = IDS_HOR; lbGapVert->Caption = IDS_VER; lbAngle->Caption = IDS_ANGLE; lbColor->Caption = IDS_USER; //TypeComboBox->Items->Clear(); //TypeComboBox->Items->Add(IDS_COMMON_LINE); //TypeComboBox->Items->Add(IDS_COMMON_CIRCLE); //TypeComboBox->Items->Add(IDS_COMMON_RECTANGLE); //TypeComboBox->Items->Add(IDS_PATTERN); //Label1->Caption = IDS_COMMON_SIZE; //Label4->Caption = IDS_COMMON_MAX; //Label5->Caption = IDS_COMMON_MIN; //Label2->Caption = IDS_COMMON_GAP; //Label6->Caption = IDS_HOR; //Label7->Caption = IDS_VER; //Label3->Caption = IDS_ANGLE; //Label8->Caption = IDS_USER; rzcbSelectColor->Caption = IDS_COLORSELECT; isHVLine = false; // ¼öÁ÷¼öÆò¼± //======== 2001.9.11 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è } //---------------------------------------------------------------------------- void __fastcall TStippleForm::FormCreate(TObject *Sender) { //========== 2001.9.11 lhskys FormCreate(TObject *Sender)³»¿ë ¿Å±è } //--------------------------------------------------------------------------- void __fastcall TStippleForm::ColSelectTextClick(TObject *Sender) { if(Step > 0){ if (IsDraw) MainImageForm->ResetDraw(true); Step = 0; } if (ItemCol==0) { //ColSelectText->Caption = IDS_READYTODRAW; ItemCol = 1; sbNew->Enabled = false; sbAll->Enabled = false; sbOne->Enabled = false; sbDelete->Enabled = false; sbBefore->Enabled = false; Draw = true; cbAngle->Enabled = true; } else { //ColSelectText->Caption = IDS_COLORSELECT; ItemCol = 0; sbNew->Enabled = true; sbOne->Enabled = true; sbAll->Enabled = true; sbDelete->Enabled = true; sbBefore->Enabled = true; Draw = false; cbAngle->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TStippleForm::sbNewClick(TObject *Sender) { stColorSelector->Initial(); } //--------------------------------------------------------------------------- void __fastcall TStippleForm::sbAllClick(TObject *Sender) { BEGIN_LOG(""); TCursor cursor; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->WorkArea->Mask) MainImageForm->SearchWorkAreaColor(stColorSelector->ChoiceColor); else MainImageForm->SearchWholeColor(stColorSelector->ChoiceColor); stColorSelector->Invalid(); Screen->Cursor = cursor; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TStippleForm::sbOneClick(TObject *Sender) { if (sbOne->Down) sbOne->Hint = IDS_COMMON_ONECOLOR; else sbOne->Hint = IDS_COMMON_BLOCKCOLOR; } //--------------------------------------------------------------------------- void __fastcall TStippleForm::sbDeleteClick(TObject *Sender) { if (sbDelete->Down) sbDelete->Hint = IDS_COMMON_DELETECOLOR; else sbDelete->Hint = IDS_COMMON_INSERTCOLOR; } //--------------------------------------------------------------------------- void __fastcall TStippleForm::spEditClick(TObject *Sender) { TRzSpinEdit *sp = (TRzSpinEdit*) Sender; sp->SetFocus(); sp->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TStippleForm::spEditKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == VK_RETURN) { TRzSpinEdit *sizeSpinEdit = dynamic_cast(Sender); if (sizeSpinEdit->Tag == 0) // spMaxEditÀÎ °æ¿ì { if (sizeSpinEdit->Value < SzMinValue) sizeSpinEdit->Value = SzMinValue; SzMaxValue = sizeSpinEdit->Value; } else // spMinEditÀÎ °æ¿ì { if (sizeSpinEdit->Value > SzMaxValue) sizeSpinEdit->Value = SzMaxValue; SzMinValue = sizeSpinEdit->Value; } } } //--------------------------------------------------------------------------- void __fastcall TStippleForm::sbBeforeClick(TObject *Sender) { BEGIN_LOG(""); stColorSelector->LoadFromFile(AppDataItem + "\\Stipple.Ini", "ColorSelect"); END_LOG; } //---------------------------------------------------------------------------//--------------------------------/Private Method/-------------------------// bool __fastcall TStippleForm::Fill_ReadSingle_none(Byte *p, int x) { return *(p+x)==FillColor; } //---------------------------------------------------------------------------- bool __fastcall TStippleForm::Fill_ReadMulti_none(Byte *p, int x) { return stColorSelector->Number[*(p+x)]<255; } //---------------------------------------------------------------------------- bool __fastcall TStippleForm::Fill_ReadSingle_layer_nonezero(Byte *p, Byte *lp, int x) { return *(p+x)==FillColor && (*(lp + x) != 0); } //---------------------------------------------------------------------------- bool __fastcall TStippleForm::Fill_ReadSingle_layer_zero(Byte *p, Byte *lp, int x) { return *(p+x)==FillColor && (*(lp + x) == 0); } //---------------------------------------------------------------------------- bool __fastcall TStippleForm::Fill_ReadMulti_layer_nonezero(Byte *p, Byte *lp, int x) { return stColorSelector->Number[*(p+x)]<255 && (*(lp + x) != 0); } //---------------------------------------------------------------------------- bool __fastcall TStippleForm::Fill_ReadMulti_layer_zero(Byte *p, Byte *lp, int x) { return stColorSelector->Number[*(p+x)]<255 && (*(lp + x) == 0); } //---------------------------------------------------------------------------- void __fastcall TStippleForm::Fill_Save(Byte *p, int x) { *(p+x) = 0xFF; } //---------------------------------------------------------------------------- void __fastcall TStippleForm::Drawing() { BEGIN_LOG(""); ///* //BeConverted by linuxjun Don't Forget!! Undo_Method int i, j, x, y, x1, y1; TRect rect, r; Byte *sl, *su, *sb, *lp, *sc, *mp, *pi; // TexpiaBitmap Byte *scan, *mask; TPoint min, max; THistoryData *ud; RGBQUAD rgb[256]; TTexpiaBitmap *Bitmap = NULL; TTexpiaBitmap *sMask = NULL; TTexpiaBitmap *PatternImage = NULL; TWindowData window; //pattern ±â´É À§ÇØ..ÀÛ¾÷±¸¿ª ¿µ¿ª qe 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; int g; double gap; int spt, dot_size, sx, sy, ex, ey, lx, ly; TPException ec = EC_NONE; int ps1, ps2, psy; // */ HDC /*udDC = NULL, dcCp = NULL,*/ dcMask = NULL, dcPattern = NULL; // /* //BeConverted by linuxjun Don't Forget!! Undo_Method TCanvas *cv = NULL; bool bMain = false, bBitmap = false, bUndo = false, bCp = false, bsMask = false, bPattern = false; TPItemImage *Image = MainImageForm->iMainImage; TCursor Cursor = Screen->Cursor; Screen->Cursor = crHourGlass; StatusProgress->Maximum = 10; spMaxEdit->Value = SzMaxValue; spMinEdit->Value = SzMinValue; // */ /*if((CpBitmap = new TTexpiaBitmap)==NULL) {ec = EC_MEMORY_LACK; goto fail;} if(!CpBitmap->Create(window.size.x, window.size.y, 8, rgb)) {ec = EC_MEMORY_LACK; goto fail;} CpBitmap->CopyFromRect(Image->uBitmap, window.s.x, window.s.y, SRCCOPY); */ ///* //BeConverted by linuxjun Don't Forget!! Undo_Method FillColor = Image->uBitmap->GetPixelColor(First.x, First.y); if (stColorSelector->Count==0) { if (Image->LayerMask) { if (Image->LayerMask->GetPixelColor(First.x, First.y)) { Image->FloodFill(First, Fill_ReadSingle_layer_nonezero, Fill_Save, rect); } else { Image->FloodFill(First, Fill_ReadSingle_layer_zero, Fill_Save, rect); } } else { Image->uBitmap->FloodFill(First, Fill_ReadSingle_none, Fill_Save, rect); } } else { if (stColorSelector->Number[FillColor]<255) if (Image->LayerMask) { if (Image->LayerMask->GetPixelColor(First.x, First.y)) { Image->FloodFill(First, Fill_ReadMulti_layer_nonezero, Fill_Save, rect); } else { Image->FloodFill(First, Fill_ReadMulti_layer_zero, Fill_Save, rect); } } else { Image->uBitmap->FloodFill(First, Fill_ReadMulti_none, Fill_Save, rect); } else { StatusProgress->End(); Screen->Cursor = Cursor; END_LOG; return; } } if (!(bMain = Image->uBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } StatusProgress->Position = 2; if (!directdraw) Theta(First, Second); max = Point(-32768, -32768); min = Point(32767, 32767); for (y=rect.Top; yuBitmap->GetScanLine(y,rect.left,rect.right-rect.left); for (x=rect.Left; xmax.x) max.x = i; if (imax.y) max.y = j; if (jPosition = 3; sx = min.x; sy = min.y; ex = max.x; ey = max.y; lx = ex-sx+1; ly = ey-sy+1; if ((Bitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (sType == TYPE_CIRCLE){// TypeComboBox->ItemIndex==1) { if (!Bitmap->Create(rect.Right-rect.Left, rect.Bottom-rect.Top, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((cv = Bitmap->CreateCanvas())==NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } cv->Brush->Color = (TColor)0x000000; cv->Pen->Color = (TColor)0x000000; if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_UNDO_NONE; goto fail; } if (!(bBitmap = Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(ud->FromRgb); MainImageForm->iMainImage->uBitmap->StartUndoScanLine(); for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetUndoScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; sb = Bitmap->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { sb[x] = sl[x]; } Bitmap->PutScanLine(y); } MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); Bitmap->StopScanLine(); spt = spMaxEdit->Value/2; gap = lx/(spMaxEdit->Value-spMinEdit->Value+1); x1 = spt; while (x1Value - g; if (dot_sizeValue) dot_size = spMinEdit->Value; y1 = spt; while (y1Ellipse(x-rect.Left-ps1, y-rect.Top-ps1, x-rect.Left+ps2, y-rect.Top+ps2); y1 = y1+spVertEdit->Value; } x1 = x1+spHorzEdit->Value; } Bitmap->DeleteCanvas(cv); cv = NULL; StatusProgress->Position = 5; if (!(bBitmap = Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; sb = Bitmap->GetScanLine(y); lp = Image->LayerMask->GetScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; for (x=0; x < rect.Right-rect.Left; x++) { if (sl[x]==0xFF) { if (sb[x] == 0) { sl[x] = Index; lp[x] = 0; } else { sl[x] = sb[x]; } } } Image->uBitmap->PutScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left); Image->LayerMask->PutScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left); } Image->LayerMask->StopScanLine(); } else { // MainImageForm->Undo->UndoRead(); // MainImageForm->Undo->RedoRead(); for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; sb = Bitmap->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { if (sl[x]==0xFF) { if (sb[x] == 0) { sl[x] = Index; } else { sl[x] = sb[x]; } } } Image->uBitmap->PutScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left); } } Bitmap->StopScanLine(); // ud->Bitmap->DeleteDC(udDC); udDC = NULL; // ud->Complete(); //blocked by linuxjun StatusProgress->Position = 7; } ///////////////////////////////////////////////////////////////////////////////added by qe(2000.11.10) else if(sType == TYPE_PATTERN){//TypeComboBox->ItemIndex == 3){ InitRange(); if (!Bitmap->Create(rect.Right-rect.Left, rect.Bottom-rect.Top, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((cv = Bitmap->CreateCanvas())==NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_UNDO_NONE; goto fail; } // if ((udDC = ud->Bitmap->CreateDC()) == NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } // BitBlt(cv->Handle, 0, 0, Bitmap->Width, Bitmap->Height, // udDC, rect.Left, rect.Top, SRCCOPY); /* Image->uBitmap->StopScanLine(); MainImageForm->Undo->UndoRead(); ud->uBitmap->UnionBitBlt(cv->Handle, 0, 0, Bitmap->Width, Bitmap->Height, rect.Left, rect.Top, SRCCOPY, false); // convert by celberus Image->uBitmap->StartScanLine(); MainImageForm->Undo->RedoRead(); */ if (!(bBitmap = Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(ud->FromRgb); MainImageForm->iMainImage->uBitmap->StartUndoScanLine(); for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetUndoScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; sb = Bitmap->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { sb[x] = sl[x]; } Bitmap->PutScanLine(y); } MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); Bitmap->StopScanLine(); if((sMask = new TTexpiaBitmap)==NULL) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if(!sMask->Create(window.size.x, window.size.y, 8, rgb)) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} //mask ±¸ÇÏ´Â ·ÎÁ÷ ä¿öÁú ºÎºÐÀº 0, ¹Ù±ùºÎºÐ 1 if(!(bCp = CpBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if(!(bsMask = sMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for(y=0; yHeight; y++){ sc = CpBitmap->GetScanLine(y); mp = sMask->GetScanLine(y); for(x=0; xWidth; x++){ if(*(sc+x) == 0){ *(mp+x) = 0xFF; }else{ *(mp+x) = 0; } } sMask->PutScanLine(y); } CpBitmap->StopScanLine(); sMask->StopScanLine(); spt = (spMaxEdit->Value)*window.size.x/100/2; gap = lx/((spMaxEdit->Value-spMinEdit->Value)*window.size.x/100 + 1); x1 = spt; PatternImage = new TTexpiaBitmap; PatternImage->Create(rect.Right - rect.Left, rect.Bottom - rect.Top, 8, rgb); dcPattern = PatternImage->CreateDC(); // if((dcCp = CpBitmap->CreateDC())==NULL){ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail;} if((dcMask = sMask->CreateDC())==NULL){ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail;} while (x1Value)*window.size.x/100 - g; if (dot_size<(spMinEdit->Value)*window.size.x/100) dot_size = (spMinEdit->Value)*window.size.x/100; y1 = spt; while (y1Handle,COLORONCOLOR); StretchBlt(cv->Handle, x-rect.Left-ps1, y-rect.Top-ps1, ps1+ps2, psy,//canvas¾Ö ¸¶½ºÅ©¿Í and¿¬»ê, ä¿ö¾ß ÇҺκÐÀº dcMask, 0, 0, window.size.x, window.size.y, SRCAND); // 0ÀÌ µÇ°í ³ª¸ÓÁö´Â º¯ÇÔ¾ø´Ù. SetStretchBltMode(dcPattern,COLORONCOLOR); // StretchBlt(dcPattern, x-rect.Left-ps1, y-rect.Top-ps1, ps1+ps2, psy, //PatternImage ¿¡ Á¡¹¦±â´ÉÈ¿°ú·Î // dcCp, 0, 0, window.size.x, window.size.y, SRCPAINT); // À̹ÌÁö¸¦ º¹»çÇØ ³Ö´Â´Ù CpBitmap->UnionStretchBlt(dcPattern, x-rect.Left-ps1, y-rect.Top-ps1, ps1+ps2, psy, //PatternImage ¿¡ Á¡¹¦±â´ÉÈ¿°ú·Î 0, 0, window.size.x, window.size.y, SRCPAINT); // À̹ÌÁö¸¦ º¹»çÇØ ³Ö´Â´Ù y1 = y1+spVertEdit->Value; } x1 = x1+spHorzEdit->Value; } Bitmap->DeleteCanvas(cv); cv = NULL; StatusProgress->Position = 5; if (!(bBitmap = Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if(!(bPattern = PatternImage->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_UNDO_NONE; goto fail; } MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(ud->FromRgb); if(!(bUndo = MainImageForm->iMainImage->uBitmap->StartUndoScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; sb = Bitmap->GetScanLine(y); su = MainImageForm->iMainImage->uBitmap->GetUndoScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; lp = Image->LayerMask->GetScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; pi = PatternImage->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { if (sl[x]==0xFF) { if(sb[x]==0) { sl[x] = pi[x]; lp[x] = 0; }else{ sl[x] = sb[x]; } } if(sl[x]==0){ sl[x] = su[x]; // lp[x] = 0; } } Image->uBitmap->PutScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left); Image->LayerMask->PutScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left); } Image->LayerMask->StopScanLine(); } else { for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; su = MainImageForm->iMainImage->uBitmap->GetUndoScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; sb = Bitmap->GetScanLine(y); pi = PatternImage->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { if (sl[x]==0xFF) { if(sb[x]==0) { sl[x] = pi[x]; }else{ sl[x] = sb[x]; } } if(sl[x]==0){ sl[x] = su[x]; } } Image->uBitmap->PutScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left); } } /*if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; sb = Bitmap->GetScanLine(y); lp = Image->LayerMask->GetScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; pi = PatternImage->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { if (sl[x]==0xFF) { if(sb[x]==0) { sl[x] = pi[x]; }else{ sl[x] = sb[x]; } } } Image->uBitmap->PutScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left); Image->LayerMask->PutScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left); } Image->LayerMask->StopScanLine(); } else { for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left) + rect.Left; sb = Bitmap->GetScanLine(y); pi = PatternImage->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { if(sl[x]==0){ sl[x] = pi[x]; } if (sl[x]==0xFF) { if(sb[x]==0) { sl[x] = pi[x]; }else{ sl[x] = sb[x]; } } } Image->uBitmap->PutScanLine(rect.Top+y,rect.Left,rect.Right-rect.Left); } }*/ Bitmap->StopScanLine(); PatternImage->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); // ud->Bitmap->DeleteDC(udDC); udDC = NULL; // CpBitmap->DeleteDC(dcCp); dcCp = NULL; sMask->DeleteDC(dcMask); dcMask = NULL; PatternImage->DeleteDC(dcPattern);dcPattern = NULL; // ud->Complete(); //blocked by linuxjun delete sMask; sMask = NULL; delete PatternImage; PatternImage = NULL; StatusProgress->Position = 7; } //////////////////////////////////////////////////////////////////////////////// else{ if (!Bitmap->Create(lx, ly, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(bBitmap = Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yHeight; y++) { memset(Bitmap->GetScanLine(y), 0xFE, Bitmap->Width); Bitmap->PutScanLine(y); } StatusProgress->Position = 5; gap = lx/(spMaxEdit->Value-spMinEdit->Value+1); if (sType == TYPE_LINE){ // TypeComboBox->ItemIndex==0) { spt = 0; x1 = spt; while (x1Value - g; if (dot_sizeValue) dot_size = spMinEdit->Value; ps1 = dot_size/2; ps2 = dot_size-ps1; for (j=0; jGetScanLine(j); for (i=x1-ps1; i<=x1+ps2; i++){ if ((i>=0)&&(iPutScanLine(j); } x1 = x1+spHorzEdit->Value; } StatusProgress->Position = 7; } else { spt = spMaxEdit->Value/2; x1 = spt; while (x1Value - g; if (dot_sizeValue) dot_size = spMinEdit->Value; y1 = spt; while (y1=0)&&(jGetScanLine(j); for (i=x1-ps1; i<=x1+ps2; i++) { if ((i>=0)&&(iPutScanLine(j); } } y1 = y1+spVertEdit->Value; } x1 = x1+spHorzEdit->Value; } StatusProgress->Position = 7; } if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=rect.Top; yuBitmap->GetScanLine(y,rect.Left,rect.Right-rect.Left); lp = Image->LayerMask->GetScanLine(y,rect.Left,rect.Right-rect.Left); for (x=rect.Left; x=0) && (y1Height) && (x1>=0) && (x1Width)) { *(sl+x) = *(Bitmap->GetScanLine(y1) + x1); if(*(sl+x) == Index) lp[x] = 0; } } } Image->uBitmap->PutScanLine(y,rect.Left,rect.Right-rect.Left); Image->LayerMask->PutScanLine(y,rect.Left,rect.Right-rect.Left); } Bitmap->StopScanLine(); bBitmap = false; StatusProgress->Position = 8; if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_UNDO_NONE; goto fail; } MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(ud->FromRgb); if(!(bUndo = MainImageForm->iMainImage->uBitmap->StartUndoScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=rect.Top; yuBitmap->GetScanLine(y); // su = (Byte*) ud->Bitmap->GetScanLine(y); sl = Image->uBitmap->GetScanLine(y,rect.Left,rect.Right-rect.Left); su = MainImageForm->iMainImage->uBitmap->GetUndoScanLine(y); lp = Image->LayerMask->GetScanLine(y); //qe qe for (x=rect.Left; xuBitmap->PutScanLine(y,rect.Left,rect.Right-rect.Left); Image->LayerMask->PutScanLine(y,rect.Left,rect.Right-rect.Left); //qe qe } MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); // ud->Complete(); Image->LayerMask->StopScanLine(); } else { for (y=rect.Top; yuBitmap->GetScanLine(y,rect.Left,rect.Right-rect.Left); for (x=rect.Left; x=0) && (y1Height) && (x1>=0) && (x1Width)) { *(sl+x) = *(Bitmap->GetScanLine(y1) + x1); } } } Image->uBitmap->PutScanLine(y,rect.Left,rect.Right-rect.Left); } Bitmap->StopScanLine(); bBitmap = false; StatusProgress->Position = 8; if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_UNDO_NONE; goto fail; } MainImageForm->iMainImage->uBitmap->PartialUndo->LoadLast(ud->FromRgb); if(!(bUndo = MainImageForm->iMainImage->uBitmap->StartUndoScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=rect.Top; yuBitmap->GetScanLine(y); // su = (Byte*) ud->Bitmap->GetScanLine(y); sl = Image->uBitmap->GetScanLine(y,rect.Left,rect.Right-rect.Left); su = MainImageForm->iMainImage->uBitmap->GetUndoScanLine(y,rect.Left,rect.Right-rect.Left); for (x=rect.Left; xuBitmap->PutScanLine(y,rect.Left,rect.Right-rect.Left); } MainImageForm->iMainImage->uBitmap->StopUndoScanLine(); // ud->Complete(); //blocked by linuxjun } StatusProgress->Position = 10; delete Bitmap; Bitmap = NULL; } Image->uBitmap->StopScanLine(); ::RepaintColor(); if(Bitmap) delete Bitmap; StatusProgress->End(); Screen->Cursor = Cursor; END_LOG; return; fail: if (bMain) { if (Bitmap) { if (bBitmap) Bitmap->StopScanLine(); // if (udDC) ud->Bitmap->DeleteDC(udDC); if (cv) Bitmap->DeleteCanvas(cv); if (bUndo) ud->uBitmap->StopScanLine(); if (bCp) CpBitmap->StopScanLine(); if (bsMask) sMask->StopScanLine(); // if (dcCp) CpBitmap->DeleteDC(dcCp); if (dcMask) sMask->DeleteDC(dcMask); delete Bitmap; } if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); } Screen->Cursor = Cursor; EXCEPTION_MESSAGE_OK(ec); END_LOG; /* //BeConverted by linuxjun Don't Forget!! Undo_Method int i, j, x, y, x1, y1; TRect rect, r; Byte *sl, *su, *sb, *lp, *sc, *mp, *pi; // TexpiaBitmap Byte *scan, *mask; TPoint min, max; TUndoData *ud; RGBQUAD rgb[256]; TTexpiaBitmap *Bitmap = NULL; TTexpiaBitmap *sMask = NULL; TTexpiaBitmap *PatternImage = NULL; TWindowData window; //pattern ±â´É À§ÇØ..ÀÛ¾÷±¸¿ª ¿µ¿ª qe 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; int g; double gap; int spt, dot_size, sx, sy, ex, ey, lx, ly, ec; int ps1, ps2, psy; */ // HDC /*udDC = NULL, dcCp = NULL,*/ dcMask = NULL, dcPattern = NULL; /* //BeConverted by linuxjun Don't Forget!! Undo_Method TCanvas *cv = NULL; bool bMain = false, bBitmap = false, bUndo = false, bCp = false, bsMask = false, bPattern = false; TPItemImage *Image = MainImageForm->iMainImage; TCursor Cursor = Screen->Cursor; Screen->Cursor = crHourGlass; StatusProgress->Maximum = 10; */ /*if((CpBitmap = new TTexpiaBitmap)==NULL) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if(!CpBitmap->Create(window.size.x, window.size.y, 8, rgb)) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} CpBitmap->CopyFromRect(Image->uBitmap, window.s.x, window.s.y, SRCCOPY); */ /* //BeConverted by linuxjun Don't Forget!! Undo_Method FillColor = Image->uBitmap->GetPixelColor(First.x, First.y); if (stColorSelector->Count==0) { if (Image->LayerMask) { if (Image->LayerMask->GetPixelColor(First.x, First.y)) { Image->FloodFill(First, Fill_ReadSingle_layer_nonezero, Fill_Save, rect); } else { Image->FloodFill(First, Fill_ReadSingle_layer_zero, Fill_Save, rect); } } else { Image->uBitmap->FloodFill(First, Fill_ReadSingle_none, Fill_Save, rect); } } else { if (stColorSelector->Number[FillColor]<255) if (Image->LayerMask) { if (Image->LayerMask->GetPixelColor(First.x, First.y)) { Image->FloodFill(First, Fill_ReadMulti_layer_nonezero, Fill_Save, rect); } else { Image->FloodFill(First, Fill_ReadMulti_layer_zero, Fill_Save, rect); } } else { Image->uBitmap->FloodFill(First, Fill_ReadMulti_none, Fill_Save, rect); } else { StatusProgress->End(); Screen->Cursor = Cursor; return; } } if (!(bMain = Image->uBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } StatusProgress->Position = 2; if (!directdraw) Theta(First, Second); max = Point(-32768, -32768); min = Point(32767, 32767); for (y=rect.Top; yuBitmap->GetScanLine(y); for (x=rect.Left; xmax.x) max.x = i; if (imax.y) max.y = j; if (jPosition = 3; sx = min.x; sy = min.y; ex = max.x; ey = max.y; lx = ex-sx+1; ly = ey-sy+1; if ((Bitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (TypeComboBox->ItemIndex==1) { if (!Bitmap->Create(rect.Right-rect.Left, rect.Bottom-rect.Top, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((cv = Bitmap->CreateCanvas())==NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } cv->Brush->Color = 0; cv->Pen->Color = 0; // cv->Brush->Color = TCol; // cv->Pen->Color = TCol; if ((ud = Undo->Last)==NULL) { ec = EC_UNDO_NONE; goto fail; } // if ((udDC = ud->Bitmap->CreateDC()) == NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } // BitBlt(cv->Handle, 0, 0, Bitmap->Width, Bitmap->Height, // udDC, rect.Left, rect.Top, SRCCOPY); ud->Bitmap->UnionBitBlt(cv->Handle, 0, 0, Bitmap->Width, Bitmap->Height, rect.Left, rect.Top, SRCCOPY, false); // convert by celberus spt = spMaxEdit->Value/2; gap = lx/(spMaxEdit->Value-spMinEdit->Value+1); x1 = spt; while (x1Value - g; if (dot_sizeValue) dot_size = spMinEdit->Value; y1 = spt; while (y1Ellipse(x-rect.Left-ps1, y-rect.Top-ps1, x-rect.Left+ps2, y-rect.Top+ps2); y1 = y1+spVertEdit->Value; } x1 = x1+spHorzEdit->Value; } Bitmap->DeleteCanvas(cv); cv = NULL; StatusProgress->Position = 5; if (!(bBitmap = Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y) + rect.Left; sb = Bitmap->GetScanLine(y); lp = Image->LayerMask->GetScanLine(rect.Top+y) + rect.Left; for (x=0; x < rect.Right-rect.Left; x++) { if (sl[x]==0xFF) { if (sb[x] == 0) { sl[x] = Index; lp[x] = 0; } else { sl[x] = sb[x]; } } } Image->uBitmap->PutScanLine(rect.Top+y); Image->LayerMask->PutScanLine(rect.Top+y); } Image->LayerMask->StopScanLine(); } else { for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y) + rect.Left; sb = Bitmap->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { if (sl[x]==0xFF) { if (sb[x] == 0) { sl[x] = Index; } else { sl[x] = sb[x]; } } } Image->uBitmap->PutScanLine(rect.Top+y); } } Bitmap->StopScanLine(); // ud->Bitmap->DeleteDC(udDC); udDC = NULL; ud->Complete(); StatusProgress->Position = 7; } ///////////////////////////////////////////////////////////////////////////////added by qe(2000.11.10) else if(TypeComboBox->ItemIndex == 3){ InitRange(); if (!Bitmap->Create(rect.Right-rect.Left, rect.Bottom-rect.Top, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((cv = Bitmap->CreateCanvas())==NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ud = Undo->Last)==NULL) { ec = EC_UNDO_NONE; goto fail; } // if ((udDC = ud->Bitmap->CreateDC()) == NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } // BitBlt(cv->Handle, 0, 0, Bitmap->Width, Bitmap->Height, // udDC, rect.Left, rect.Top, SRCCOPY); ud->Bitmap->UnionBitBlt(cv->Handle, 0, 0, Bitmap->Width, Bitmap->Height, rect.Left, rect.Top, SRCCOPY, false); // convert by celberus if((sMask = new TTexpiaBitmap)==NULL) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} if(!sMask->Create(window.size.x, window.size.y, 8, rgb)) {ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail;} //mask ±¸ÇÏ´Â ·ÎÁ÷ ä¿öÁú ºÎºÐÀº 0, ¹Ù±ùºÎºÐ 1 if(!(bCp = CpBitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if(!(bsMask = sMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for(y=0; yHeight; y++){ sc = CpBitmap->GetScanLine(y); mp = sMask->GetScanLine(y); for(x=0; xWidth; x++){ if(*(sc+x) == 0){ *(mp+x) = 0xFF; }else{ *(mp+x) = 0; } } sMask->PutScanLine(y); } CpBitmap->StopScanLine(); sMask->StopScanLine(); spt = (spMaxEdit->Value)*window.size.x/100/2; gap = lx/((spMaxEdit->Value-spMinEdit->Value)*window.size.x/100 + 1); x1 = spt; PatternImage = new TTexpiaBitmap; PatternImage->Create(rect.Right - rect.Left, rect.Bottom - rect.Top, 8, rgb); dcPattern = PatternImage->CreateDC(); // if((dcCp = CpBitmap->CreateDC())==NULL){ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail;} if((dcMask = sMask->CreateDC())==NULL){ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail;} while (x1Value)*window.size.x/100 - g; if (dot_size<(spMinEdit->Value)*window.size.x/100) dot_size = (spMinEdit->Value)*window.size.x/100; y1 = spt; while (y1Handle,COLORONCOLOR); StretchBlt(cv->Handle, x-rect.Left-ps1, y-rect.Top-ps1, ps1+ps2, psy,//canvas¾Ö ¸¶½ºÅ©¿Í and¿¬»ê, ä¿ö¾ß ÇҺκÐÀº dcMask, 0, 0, window.size.x, window.size.y, SRCAND); // 0ÀÌ µÇ°í ³ª¸ÓÁö´Â º¯ÇÔ¾ø´Ù. SetStretchBltMode(dcPattern,COLORONCOLOR); // StretchBlt(dcPattern, x-rect.Left-ps1, y-rect.Top-ps1, ps1+ps2, psy, //PatternImage ¿¡ Á¡¹¦±â´ÉÈ¿°ú·Î // dcCp, 0, 0, window.size.x, window.size.y, SRCPAINT); // À̹ÌÁö¸¦ º¹»çÇØ ³Ö´Â´Ù CpBitmap->UnionStretchBlt(dcPattern, x-rect.Left-ps1, y-rect.Top-ps1, ps1+ps2, psy, //PatternImage ¿¡ Á¡¹¦±â´ÉÈ¿°ú·Î 0, 0, window.size.x, window.size.y, SRCPAINT); // À̹ÌÁö¸¦ º¹»çÇØ ³Ö´Â´Ù y1 = y1+spVertEdit->Value; } x1 = x1+spHorzEdit->Value; } Bitmap->DeleteCanvas(cv); cv = NULL; StatusProgress->Position = 5; if (!(bBitmap = Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if(!(bPattern = PatternImage->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y) + rect.Left; sb = Bitmap->GetScanLine(y); lp = Image->LayerMask->GetScanLine(rect.Top+y) + rect.Left; pi = PatternImage->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { if (sl[x]==0xFF) { if(sb[x]==0) { sl[x] = pi[x]; }else{ sl[x] = sb[x]; } } } Image->uBitmap->PutScanLine(rect.Top+y); Image->LayerMask->PutScanLine(rect.Top+y); } Image->LayerMask->StopScanLine(); } else { for (y=0; y < rect.Bottom-rect.Top; y++) { sl = Image->uBitmap->GetScanLine(rect.Top+y) + rect.Left; sb = Bitmap->GetScanLine(y); pi = PatternImage->GetScanLine(y); for (x=0; x < rect.Right-rect.Left; x++) { if (sl[x]==0xFF) { if(sb[x]==0) { sl[x] = pi[x]; }else{ sl[x] = sb[x]; } } } Image->uBitmap->PutScanLine(rect.Top+y); } } Bitmap->StopScanLine(); PatternImage->StopScanLine(); // ud->Bitmap->DeleteDC(udDC); udDC = NULL; // CpBitmap->DeleteDC(dcCp); dcCp = NULL; sMask->DeleteDC(dcMask); dcMask = NULL; PatternImage->DeleteDC(dcPattern);dcPattern = NULL; ud->Complete(); delete sMask; sMask = NULL; delete PatternImage; PatternImage = NULL; StatusProgress->Position = 7; } //////////////////////////////////////////////////////////////////////////////// else{ if (!Bitmap->Create(lx, ly, 8, rgb)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!(bBitmap = Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yHeight; y++) { memset(Bitmap->GetScanLine(y), 0xFE, Bitmap->Width); Bitmap->PutScanLine(y); } StatusProgress->Position = 5; gap = lx/(spMaxEdit->Value-spMinEdit->Value+1); if (TypeComboBox->ItemIndex==0) { spt = 0; x1 = spt; while (x1Value - g; if (dot_sizeValue) dot_size = spMinEdit->Value; ps1 = dot_size/2; ps2 = dot_size-ps1; for (j=0; jGetScanLine(j); for (i=x1-ps1; i<=x1+ps2; i++){ if ((i>=0)&&(iPutScanLine(j); } x1 = x1+spHorzEdit->Value; } StatusProgress->Position = 7; } else { spt = spMaxEdit->Value/2; x1 = spt; while (x1Value - g; if (dot_sizeValue) dot_size = spMinEdit->Value; y1 = spt; while (y1=0)&&(jGetScanLine(j); for (i=x1-ps1; i<=x1+ps2; i++) { if ((i>=0)&&(iPutScanLine(j); } } y1 = y1+spVertEdit->Value; } x1 = x1+spHorzEdit->Value; } StatusProgress->Position = 7; } if (Image->LayerMask) { if (!(Image->LayerMask->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=rect.Top; yuBitmap->GetScanLine(y); lp = Image->LayerMask->GetScanLine(y); for (x=rect.Left; x=0) && (y1Height) && (x1>=0) && (x1Width)) { *(sl+x) = *(Bitmap->GetScanLine(y1) + x1); if(*(sl+x) == Index) lp[x] = 0; } } } Image->uBitmap->PutScanLine(y); Image->LayerMask->PutScanLine(y); } Bitmap->StopScanLine(); bBitmap = false; StatusProgress->Position = 8; if ((ud = Undo->Last)==NULL) { ec = EC_UNDO_NONE; goto fail; } if(!(bUndo = ud->Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=rect.Top; yuBitmap->GetScanLine(y); // su = (Byte*) ud->Bitmap->GetScanLine(y); sl = Image->uBitmap->GetScanLine(y); su = ud->Bitmap->GetScanLine(y); //lp = Image->LayerMask->GetScanLine(y); //qe for (x=rect.Left; xuBitmap->PutScanLine(y); //Image->LayerMask->PutScanLine(y); //qe } ud->Bitmap->StopScanLine(); ud->Complete(); Image->LayerMask->StopScanLine(); } else { for (y=rect.Top; yuBitmap->GetScanLine(y); for (x=rect.Left; x=0) && (y1Height) && (x1>=0) && (x1Width)) { *(sl+x) = *(Bitmap->GetScanLine(y1) + x1); } } } Image->uBitmap->PutScanLine(y); } Bitmap->StopScanLine(); bBitmap = false; StatusProgress->Position = 8; if ((ud = Undo->Last)==NULL) { ec = EC_UNDO_NONE; goto fail; } if(!(bUndo = ud->Bitmap->StartScanLine())) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=rect.Top; yuBitmap->GetScanLine(y); // su = (Byte*) ud->Bitmap->GetScanLine(y); sl = Image->uBitmap->GetScanLine(y); su = ud->Bitmap->GetScanLine(y); for (x=rect.Left; xuBitmap->PutScanLine(y); } ud->Bitmap->StopScanLine(); ud->Complete(); } StatusProgress->Position = 10; delete Bitmap; Bitmap = NULL; } Image->uBitmap->StopScanLine(); ::RepaintColor(); StatusProgress->End(); Screen->Cursor = Cursor; return; fail: if (bMain) { if (Bitmap) { if (bBitmap) Bitmap->StopScanLine(); // if (udDC) ud->Bitmap->DeleteDC(udDC); if (cv) Bitmap->DeleteCanvas(cv); if (bUndo) ud->Bitmap->StopScanLine(); if (bCp) CpBitmap->StopScanLine(); if (bsMask) sMask->StopScanLine(); // if (dcCp) CpBitmap->DeleteDC(dcCp); if (dcMask) sMask->DeleteDC(dcMask); delete Bitmap; } if (Image->LayerMask) Image->LayerMask->StopScanLine(); Image->uBitmap->StopScanLine(); } Screen->Cursor = Cursor; EXCEPTION_MESSAGE_OK(ec); */ } //---------------------------------------------------------------------------- void __fastcall TStippleForm::Theta(TPoint sp, TPoint ep) { double deg, dx, dy; dx = ep.x-sp.x; dy = ep.y-sp.y; if ((dy==0) && (dx==0)) { rad = 0; cbAngle->Text = "0.0"; } else { rad = atan2(dy, dx); if (rad == M_PI_2) { cbAngle->Text = "90.0"; } else if (rad == -M_PI_2) { cbAngle->Text = "270.0"; } else { deg = 180 * rad / M_PI; if (deg < 0) deg = 360 + deg; cbAngle->Text = Format("%.1f", OPENARRAY(TVarRec, (deg))); } } } //---------------------------------------------------------------------------- int __fastcall TStippleForm::xTransfer(int x, int y) { return (x*cos(rad)+y*sin(rad)); } //---------------------------------------------------------------------------- int __fastcall TStippleForm::yTransfer(int x, int y) { return (y*cos(rad)-x*sin(rad)); } //---------------------------------------------------------------------------- void __fastcall TStippleForm::ChangeItem(int i) { } //---------------------------------------------------------------------------- void __fastcall TStippleForm::ReadIniFile() { BEGIN_LOG(""); int max, min, hor, ver; TIniFile *StippleIni = new TIniFile(AppDataItem + "\\Stipple.ini"); //spMaxEdit->Value = StippleIni->ReadInteger("SizeMax", "s_max", 10); // spMaxEdit->Value = 20; //qe modifies for Designers' demand //spMinEdit->Value = StippleIni->ReadInteger("SizeMin", "s_min", 1); SzMaxValue = StippleIni->ReadInteger("SizeMax", "s_max", 10); SzMinValue = StippleIni->ReadInteger("SizeMin", "s_min", 1); spMaxEdit->Value = SzMaxValue; spMinEdit->Value = SzMinValue; spHorzEdit->Value = StippleIni->ReadInteger("GabHor", "g_hor", 20); spVertEdit->Value = StippleIni->ReadInteger("GabVer", "g_ver", 20); cbAngle->Text = StippleIni->ReadFloat("Degree", "deg", 0); //TypeComboBox->ItemIndex = StippleIni->ReadInteger("Type", "typ", 0); sType = StippleIni->ReadInteger("Type", "typ", 0); delete StippleIni; END_LOG; } //---------------------------------------------------------------------------- void __fastcall TStippleForm::WriteIniFile() { BEGIN_LOG(""); TIniFile *StippleIni = NULL; double dAngle; if (TryStrToFloat(cbAngle->Text, dAngle) == false) dAngle = 0.0; StippleIni = new TIniFile(AppDataItem + "\\Stipple.ini"); //StippleIni->WriteInteger("SizeMax", "s_max", spMaxEdit->Value); //StippleIni->WriteInteger("SizeMin", "s_min", spMinEdit->Value); StippleIni->WriteInteger("SizeMax", "s_max", SzMaxValue); StippleIni->WriteInteger("SizeMin", "s_min", SzMinValue); StippleIni->WriteInteger("GabHor", "g_hor", spHorzEdit->Value); StippleIni->WriteInteger("GabVer", "g_ver", spVertEdit->Value); StippleIni->WriteFloat("Degree", "deg", dAngle); StippleIni->WriteInteger("Type", "typ", sType);//TypeComboBox->ItemIndex); delete StippleIni; END_LOG; } //------------------------------/Public Method/-----------------------------// void __fastcall TStippleForm::InitForm() { //ParentHeight = Parent->Height+20; ClientHeight = 173; //200; //Parent->Height = ParentHeight+ClientHeight; stColorSelector->SetPalette(MainImageForm->Palette); Step = 0; Draw = true; //ItemCol = 0; rzcbSelectColor->Checked = false; //ColSelectTextClick(ColSelectText); sType = TYPE_LINE; //TypeComboBox->ItemIndex = 0; rzmtbtLine->Down = true; directdraw = false; FGChange(PaletteForm->DIB256Palette->ChoiceIndex); ReadIniFile(); SetButton(); TypeChange(); //TypeComboBoxChange(TypeComboBox); } //---------------------------------------------------------------------------- void __fastcall TStippleForm::ExitForm() { if (IsDraw) MainImageForm->ResetDraw(true); WriteIniFile(); stColorSelector->SaveToFile(AppDataItem + "\\Stipple.Ini", "ColorSelect"); if(CpBitmap) delete CpBitmap; CpBitmap = NULL; MainMenuForm->SetFocus(); //lhskys Á¾·á½Ã Focus ¸¦ °¡Á®¿À°í À§ÇØ } //---------------------------------------------------------------------------- void __fastcall TStippleForm::iMainImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); TRect r; Byte *scan, color; bool undoSw = false; int ix, iy; TPException ec = EC_NONE; TPItemImage *MainImage = (TPItemImage *) Sender; if (Draw) { if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { color = MainImage->uBitmap->GetPixelColor(X, Y); FGChange(color); } else if (Button==mbLeft) { if (directdraw) { if(sType == TYPE_PATTERN) InitPattern(); // TypeComboBox->ItemIndex==3)InitPattern(); First = Point(X, Y); if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0, 0, 0, 0))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Drawing(); directdraw = false; } else { if (Step>0) { if(sType == TYPE_PATTERN) InitPattern(); //TypeComboBox->ItemIndex==3)InitPattern(); Second = Point(X, Y); if(isHVLine){ if(abs(First.x - Second.x) > abs(First.y - Second.y)) Second = Point(X, First.y); else Second = Point(First.x, Y); MainImageForm->DrawLineLocate(First, Point(Second.x, Second.y)); } else MainImageForm->DrawLineLocate(First, Point(Second.x-1, Second.y)); // Second -> Point(...) ´«¼ÓÀÓÀÌ´Ù. IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo Step = 0; /* if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; }*/ if ((undoSw = MainImageForm->UndoSave(UK_ALL, Rect(0, 0, 0, 0))) == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } Drawing(); } else { First = Point(X, Y); Second = First; MainImageForm->DrawLineLocate(First, Point(Second.x-1, Second.y)); IsDraw = true; Step = 1; } } } } else { if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { if (sbOne->Down) { if (sbDelete->Down) { stColorSelector->DeleteColor(MainImageForm->iMainImage->uBitmap->GetPixelColor(X, Y)); } else { stColorSelector->AddColor(MainImageForm->iMainImage->uBitmap->GetPixelColor(X, Y)); } } else { if (Step>0) { Temp.right = X; Temp.bottom = Y; MainImageForm->DrawRectangleLocate(Temp); if (Temp.left>Temp.right) { r.Left = Temp.right; r.Right = Temp.left; } else { r.Left = Temp.left; r.Right = Temp.right; } if (Temp.top>Temp.bottom) { r.Top = Temp.bottom; r.Bottom = Temp.top; } else { r.Top = Temp.top; r.Bottom = Temp.bottom; } if (!MainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (sbDelete->Down) { for (iy=r.Top; iyuBitmap->GetScanLine(iy,r.Left,r.Right-r.Left); for (ix=r.Left; ixDeleteColor(*(scan+ix)); } } } else { for (iy=r.Top; iyuBitmap->GetScanLine(iy,r.Left,r.Right-r.Left); for (ix=r.Left; ixAddColor(*(scan+ix)); } } } MainImage->uBitmap->StopScanLine(); Step = 0; IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } else { Temp.left = X; Temp.top = Y; Temp.bottom = Temp.top; Temp.right = Temp.left; MainImageForm->DrawRectangleLocate(Temp); IsDraw = true; Step = 1; } } } } END_LOG; return; fail: MainImage->uBitmap->StopScanLine(); if (undoSw) MainImageForm->Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //---------------------------------------------------------------------------- void __fastcall TStippleForm::iMainImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (Draw) { if (Step>0) { if (IsDraw) MainImageForm->DrawLineLocate(First, Point(Second.x-1, Second.y)); Second = Point(X, Y); if(isHVLine){ if(abs(First.x - Second.x) > abs(First.y - Second.y)) Second = Point(X, First.y); else Second = Point(First.x, Y); MainImageForm->DrawLineLocate(First, Point(Second.x, Second.y)); } else MainImageForm->DrawLineLocate(First, Point(Second.x-1, Second.y)); Theta(First, Second); IsDraw = true; } } else { if (sbOne->Down==false) { if (Step>0) { if (IsDraw) MainImageForm->DrawRectangleLocate(Temp); Temp.right = X; Temp.bottom = Y; MainImageForm->DrawRectangleLocate(Temp); IsDraw = true; } } } } //---------------------------------------------------------------------------- void __fastcall TStippleForm::iMainImagePaint() { IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo } //---------------------------------------------------------------------------- void __fastcall TStippleForm::FGChange(int Value) { TColorData *ColorMap; Index = Value; ColorMap = MainImageForm->Palette->ColorData[Value]; TCol = RGB2TColor(ColorMap->RGB.rgbRed, ColorMap->RGB.rgbGreen, ColorMap->RGB.rgbBlue); if (sType != TYPE_PATTERN) UserShape->Brush->Color = TCol; //if(TypeComboBox->ItemIndex!=3)UserShape->Brush->Color = TCol; } //--------------------------------------------------------------------------- void __fastcall TStippleForm::cbAngleChange(TObject *Sender) { BEGIN_LOG(""); directdraw = true; if (IsDraw) { MainImageForm->DrawLineLocate(First, Point(Second.x-1, Second.y)); IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo Step = 0; } switch (cbAngle->ItemIndex) { case 0: rad = 0; break; case 1: rad = M_PI_4; break; case 2: rad = M_PI_2; break; case 3: rad = 3*M_PI_4; break; case 4: rad = M_PI; break; case 5: rad = -3*M_PI_4; break; case 6: rad = -M_PI_2; break; case 7: rad = -M_PI_4; break; } int deg = 0; if (TryStrToInt(cbAngle->Text, deg)){ if (deg < -360 || deg > 360){ deg = 0; cbAngle->Text = 0; } rad = DegToRad((Extended)deg); } else { cbAngle->Text = 0; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TStippleForm::cbAngleKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { if (Key == VK_RETURN) { int deg = 0; if (TryStrToInt(cbAngle->Text, deg)){ rad = DegToRad((Extended)deg); } else { cbAngle->Text = 0; } } } //--------------------------------------------------------------------------- void __fastcall TStippleForm::cbAngleDblClick(TObject *Sender) { cbAngle->SetFocus(); cbAngle->SelectAll(); } //--------------------------------------------------------------------------- void __fastcall TStippleForm::InitPattern() //added by qe ÆÐÅÏ ¼±Åýà ÀÛ¾÷±¸¿ª À̹ÌÁö¸¦ º¹»çÇÑ´Ù. { BEGIN_LOG(""); RECT rect = MainImageForm->WorkArea->Range; RGBQUAD rgb[256]; MainImageForm->Palette->ToRGBQUAD(rgb, 256); TPException ec = EC_NONE; if (CpBitmap){ delete CpBitmap; CpBitmap = NULL; } if((CpBitmap = new TUnionBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // convert by celberus if(!(CpBitmap->Create(rect.right - rect.left, rect.bottom - rect.top, 8, rgb))) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } CpBitmap->CopyFromRect(MainImageForm->iMainImage->uBitmap, rect.left, rect.top, SRCCOPY); MainImageForm->WorkArea->Mask->PutColors(0, 256, rgb); CpBitmap->Copy(MainImageForm->WorkArea->Mask, SRCAND); END_LOG; return; fail: if(CpBitmap) { delete CpBitmap; CpBitmap = NULL; } EXCEPTION_MESSAGE_OK(ec); END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TStippleForm::InitRange() //added by qe ÆÐÅÏ ¼±Åýà ÆÐÅÏÀÌ °ãÄ¡Áö ¾Ê°Ô ÃÖ¼Ò °£°Ý ¼³Á¤ { BEGIN_LOG(""); double Horz = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; double Vert = MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top; double RectTheta = atan2(Horz,Vert); double HorzMin; double VertMin; //if(spMaxEdit->Value > 100) spMaxEdit->Value = 100; //spMaxEditÀÇ ÃÖ´ë°ªÀº 100(½ÇÁ¦ ÆÐÅÏÀÇ Å©±â)ÀÌ´Ù. if(SzMaxValue > 100) { SzMaxValue = 100; //spMaxEditÀÇ ÃÖ´ë°ªÀº 100(½ÇÁ¦ ÆÐÅÏÀÇ Å©±â)ÀÌ´Ù. spMaxEdit->Value = SzMaxValue; } if(rad >= -M_PI && rad < -M_PI+RectTheta){ VertMin = Vert/fabs(cos(rad)); HorzMin = Horz/fabs(cos(rad)); }else if(rad >= -M_PI+RectTheta && rad < -M_PI_2+RectTheta){ VertMin = Horz/fabs(sin(rad)); HorzMin = Vert/fabs(sin(rad)); }else if(rad >= -M_PI_2+RectTheta && rad < RectTheta){ VertMin = Vert/fabs(cos(rad)); HorzMin = Horz/fabs(cos(rad)); }else if(rad >= RectTheta && rad < RectTheta+M_PI/2){ VertMin = Horz/fabs(sin(rad)); HorzMin = Vert/fabs(sin(rad)); }else if(rad >= RectTheta+M_PI/2 && rad < M_PI){ VertMin = Vert/fabs(cos(rad)); HorzMin = Horz/fabs(cos(rad)); } if(spHorzEdit->Value < HorzMin) spHorzEdit->Value = HorzMin; if(spVertEdit->Value < VertMin) spVertEdit->Value = VertMin; END_LOG; } //---------------------------------------------------------------------------- void __fastcall TStippleForm::subLine1Click(TObject *Sender) { TSpeedButton *sp = (TSpeedButton *)Sender; switch (sp->Tag){ case 0 : //TypeComboBox->ItemIndex = 0; rzmtbtLine->Down = true; rzmtbtTypeClick(rzmtbtLine); break; case 1 : //TypeComboBox->ItemIndex = 1; rzmtbtCircle->Down = true; rzmtbtTypeClick(rzmtbtCircle); break; case 2 : //TypeComboBox->ItemIndex = 2; rzmtbtRectangle->Down = true; rzmtbtTypeClick(rzmtbtRectangle); break; case 3 : //TypeComboBox->ItemIndex = 3; rzmtbtPattern->Down = true; rzmtbtTypeClick(rzmtbtPattern); break; } } //--------------------------------------------------------------------------- void __fastcall TStippleForm::iMainImageKeyDown(TObject *Sender, WORD Key, TShiftState Shift) { if (Key == 'Z') { isHVLine = true; } } //--------------------------------------------------------------------------- void __fastcall TStippleForm::iMainImageKeyUp(TObject *Sender, WORD Key, TShiftState Shift) { if (Key == 'Z') { isHVLine = false; } } //--------------------------------------------------------------------------- void __fastcall TStippleForm::rzmtbtTypeClick(TObject *Sender) { TRzMenuToolbarButton *bt = (TRzMenuToolbarButton *)Sender; sType = bt->Tag; TypeChange(); } //--------------------------------------------------------------------------- void __fastcall TStippleForm::TypeChange() { if (sType) { spVertEdit->Enabled = true; } else { spVertEdit->Enabled = false; } if(sType==3){ // by qe ÀÛ¾÷±¸¿ªÀÌ ÀâÇôÀÖÁö ¾ÊÀº »óÅ¿¡¼­ ÆÐÅÏ ¼±ÅÃÇÏÁö ¸øÇϵµ·Ï if(MainImageForm->WorkArea->Mask==NULL) { rzmtbtLine->Down = true; sType = TYPE_LINE; spVertEdit->Enabled = false; ShowMessage(IDS_MESSAGE_SETWINDOW); return; } }else{ if(CpBitmap) delete CpBitmap; CpBitmap = NULL; } if(sType==3){ // ÆÐÅϼ±Åýà Ä÷¯¼±Åñâ´É Á×À̰í,¼öÆò¼öÁ÷ °£°Ý ¼¼ÆÃ! UserShape->Brush->Color = (TColor)0x000000; UserShape->Enabled = false; spHorzEdit->Value = MainImageForm->WorkArea->Range.right - MainImageForm->WorkArea->Range.left; spVertEdit->Value = MainImageForm->WorkArea->Range.bottom - MainImageForm->WorkArea->Range.top; } else { UserShape->Brush->Color = TCol; UserShape->Enabled = true; } } //--------------------------------------------------------------------------- void __fastcall TStippleForm::SetButton() { if (sType == TYPE_LINE){ rzmtbtLine->Down = true; } else if (sType == TYPE_CIRCLE){ rzmtbtCircle->Down = true; } else if (sType == TYPE_RECTANGLE){ rzmtbtRectangle->Down = true; } else if (sType == TYPE_PATTERN){ rzmtbtPattern->Down = true; } } //--------------------------------------------------------------------------- void __fastcall TStippleForm::rzcbSelectColorClick(TObject *Sender) { if(Step > 0){ if (IsDraw) MainImageForm->ResetDraw(true); Step = 0; } if (false == rzcbSelectColor->Checked){ //ItemCol==0) { //ColSelectText->Caption = IDS_READYTODRAW; //ItemCol = 1; sbNew->Enabled = false; sbAll->Enabled = false; sbOne->Enabled = false; sbDelete->Enabled = false; sbBefore->Enabled = false; Draw = true; cbAngle->Enabled = true; } else { //ColSelectText->Caption = IDS_COLORSELECT; //ItemCol = 0; sbNew->Enabled = true; sbOne->Enabled = true; sbAll->Enabled = true; sbDelete->Enabled = true; sbBefore->Enabled = true; Draw = false; cbAngle->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TStippleForm::FormClose(TObject *Sender, TCloseAction &Action) { BEGIN_LOG(""); HWND hWnd = ((TWinControl *)Owner)->Handle; PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //---------------------------------------------------------------------------