//--------------------------------------------------------------------------- #include #include #include #pragma hdrstop #include "MainImage.h" #include "ColorLibrary_F.h" #include "FullView.h" #include "Layer_F.h" #include "History.h" #include "Main.h" #include "MainMenu.h" #include "Palette.h" #include "PenManager.h" #include "ProtectCard.h" #include "Undo.h" #include "AutoRepView.h" #include "Dialog_F.h" #include "Grouping_F.h" #include "PatternRepeat.h" #include "Text_F.h" #include "Draw_F.h" #include "TexWork_F.h" #include "Menu3D_F.h" #ifndef ACADEMY #include "UserColor_F.h" #endif #include "Autosave.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "TPImage" #pragma link "TPSelectImage" #pragma link "TPRuler2D" #pragma link "TPLayerImage" #pragma link "TPImage" #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_ZOOMIN StringTable[0] #define IDS_ZOOMOUT StringTable[1] #define IDS_GRID StringTable[2] #define IDS_RULER StringTable[3] #define IDS_PROTECTION StringTable[4] #define IDS_UNIT StringTable[5] #define IDS_AUTOREPEAT StringTable[6] //--------------------------------------------------------------------------- TMainImageForm *MainImageForm; int MainImageCount = 0; //--------------------------------------------------------------------------- __fastcall TMainImageForm::TMainImageForm(TComponent* Owner) : TForm(Owner) { Number = MainImageCount; MainImageCount++; memsize = 0; hMemLine = NULL; msx = NULL; BtnClick = false; DownState = false; bProtect = false; bMaskArea = false; bDrawPen = true; iMainImage->OnPaintDirectly=PaintDirectly; iMainImage->OnPaintCursor=NULL; iMainImage->OnPaintCrossLine=NULL; iMainImage->OnPaintZoom=NULL; iMainImage->OnPaintLocate=NULL; isPaintDirectlyClean=false; isFirst=true; LineList = new TList; DrawORStitch=false; MouseState = 0; CurrentUnit = uCm; cbTime = 0; Modify = false; Palette = NULL; WorkArea = NULL; TempBitmap = TempMask = NULL; #ifndef ACADEMY #ifndef N_3D Data3D = NULL; #endif #endif } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormActivate(TObject *Sender) { if (MainImageForm!=this) { if (MainImageForm) MainImageForm->iMainImage->Deactivate(); iMainImage->Activate(); if (MainImageForm) { #ifndef ACADEMY if (MainImageForm->AutoRepeat) { if (AutoRepViewForm) { MainImageForm->sbAutoRepView->Down = false; ARViewExitForm(); } } #endif } MainMenuForm->ExitForm(1); MainImageForm = this; PenManagerForm->InitPenForm(); } Undo->Set(Number, iMainImage, Palette, WorkArea); FullViewForm->InitForm(iMainImage); PaletteForm->UpdateForm(iMainImage->Bitmap->BitsPerPixel); #ifndef ACADEMY LayerForm->InitForm(); #endif ReviewStatusBar(); ReleaseCapture(); ShowZoomText(); //================================================= for Auto Repeat by kjs #ifndef ACADEMY if (AutoRepeat) { // if (AutoRepViewForm) // AutoRepViewForm->Visible = true; MainMenuForm->AutoRepUpdateItem(); } //================================================== #endif // bool cr = iMainImage->Cross, crl = iMainImage->CrossLine; // iMainImage->Cross = false; // iMainImage->CrossLine = false; // sbCrossLine->Down=false; iMainImage->Repaint(); // iMainImage->Cross=cr; // iMainImage->CrossLine=crl; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormClose(TObject *Sender, TCloseAction &Action) { delete LineList; Action = caFree; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormCloseQuery(TObject *Sender, bool &CanClose) { AnsiString msg, fn, ext; char *s; TGraphicFileFormat gff; #ifdef ACADEMY gff = gffTEX; ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; #else if (iMainImage->Bitmap->BitsPerPixel==8) { gff = gffTEX; ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; } else { #ifndef N_3D if (MainMenuForm->Item == T_3D) { if(MainForm->T3D_Item) { gff = gffT3D; ext = ".t3d"; MainForm->SaveDialog->Filter = "Texpro Textile 3D File (*.t3d)|*.t3d"; } else { gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; } } else { gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; } #else gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; #endif } #endif MainMenuForm->ExitForm(1); if (Modify) { msg = Format(" %s", OPENARRAY (TVarRec,(FileName))); int Btn = MessageDlg(IDS_MESSAGE_SAVECHANGE + msg, mtWarning, TMsgDlgButtons()<SaveDialog->InitialDir = IniFile->ReadString("FileManager", "DirectoryName", "C:\\"); delete IniFile; } if (MainForm->SaveDialog->Execute()) { s = AnsiStrScan(MainForm->SaveDialog->FileName.c_str(), '.'); if (s==NULL) fn = MainForm->SaveDialog->FileName+ext; else fn = MainForm->SaveDialog->FileName; DirName = ExtractFileDir(fn); FileName = ExtractFileName(fn); SaveToFile(DirName, FileName, gff, MainForm->CompressMethod); CanClose = true; } } else { SaveToFile(DirName, FileName, gff, MainForm->CompressMethod); CanClose = true; } } else if (Btn == mrNo) { CanClose = true; } else { CanClose = false; } } else { CanClose = true; } if (CanClose) { PaletteForm->DIB256Palette->ChoiceIndex = 2; if (FileExists(FileName)) { FileHistory->InsertHistory(DirName, ExtractFileName(FileName), 1, iMainImage->Bitmap->BitsPerPixel); } //====================================================== for Auto Repeat by kjs #ifndef ACADEMY if (AutoRepeat) { AutoRepUpdateMenu(true); AutoRepeat = false; if (AutoRepViewForm) ARViewExitForm(); } #endif //====================================================== } Modify = false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormCreate(TObject *Sender) { ////////////////////////////////////////////////////////////////////////////////by jeegeo // if(!MainMenuForm)MainMenuForm = new TMainMenuForm(this->Parent); // if(!PenManagerForm)PenManagerForm = new TPenManagerForm(this->Parent); // if(!FullViewForm)FullViewForm = new TFullViewForm(this->Parent); // if(!PaletteForm)PaletteForm = new TPaletteForm(this->Parent); MainMenuForm->Visible=true; PenManagerForm->Visible=true; FullViewForm->Visible=true; PaletteForm->Visible=true; ////////////////////////////////////////////////////////////////////////////////by jeegeo TGrid g; int unit; #ifndef LOCK_CRYPKEY #ifndef LOCK_IFC ProtectCard->Check(); #endif #endif //======================================== StringTable.Create(DirectoryItem, Language, "MainImage"); SetSmallFont(Font); SetSmallFont(TempLabel->Font); SetSmallFont(sbUnit->Font); sbZoomIn->Hint = IDS_ZOOMIN; sbZoomOut->Hint = IDS_ZOOMOUT; sbGrid->Hint = IDS_GRID; sbRuler->Hint = IDS_RULER; sbProtect->Hint = IDS_PROTECTION; sbMaskArea->Hint = IDS_COMMON_MASKAREA; sbMaskShow->Hint = IDS_COMMON_MASKSHOW; sbAutoRepView->Hint = IDS_AUTOREPEAT; TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { unit = IniFile->ReadInteger("MainImage", "Unit", 0); if (unit == 0) { sbUnit->Caption = AnsiString(IDS_UNIT) + " : Cm"; UnitChange(uCm); } else if (unit == 1) { sbUnit->Caption = AnsiString(IDS_UNIT) + " : Inch"; UnitChange(uInch); } else { sbUnit->Caption = AnsiString(IDS_UNIT) + " : Doc"; UnitChange(uDot); } delete IniFile; } //======================================== if ((WorkArea = new TWorkArea(&(iMainImage->Bitmap)))==NULL) goto fail; if ((Palette = new TPalette)==NULL) goto fail; //====================================== for Auto Repeat by kjs AutoRepeat = false; #ifndef ACADEMY AutoRepViewForm = NULL; #endif //====================================== MainImageForm = this; CanvasInfor.DotsPerInch = 160; CanvasInfor.SetExtFileOption(); ApplyEnvironment(); Panel->PopupMenu = MainMenuForm->PopupMenu1; iMainImage->Cursor = crPen; ZoomChange(1, 1); PaletteForm->InitForm(Palette); PenManagerForm->InitPenForm(); ReviewStatusBar(); initsave = true; return; fail: ::doDestroy(Palette); ::doDestroy(WorkArea); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormDestroy(TObject *Sender) { // MainImageForm->iMainImage->OnPaintLocate = NULL; MainMenuForm->ExitForm(1); #ifndef ACADEMY #ifndef N_3D ::doDestroy(Data3D); LayerForm->Visible = false; #endif #endif DelLineMem(); ::doDestroy(Palette); ::doDestroy(WorkArea); FullViewForm->InitForm(NULL); MainImageForm = NULL; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormPaint(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormResize(TObject *Sender) { Ruler->Width = ClientWidth-PanelVert->Width; Ruler->Height = ClientHeight-PanelHorz->Height; if (sbRuler->Down) { Panel->Left = Ruler->Thick; Panel->Top = Ruler->Thick; Panel->Width = Ruler->Width-Ruler->Thick; Panel->Height = Ruler->Height-Ruler->Thick; } else { Panel->Left = 0; Panel->Top = 0; Panel->Width = Ruler->Width; Panel->Height = Ruler->Height; } PanelHorz->Top = Ruler->Top+Ruler->Height+1; PanelHorz->Width = Ruler->Width; sbHorz->Width = PanelHorz->Width-sbHorz->Left-2; PanelVert->Left = Ruler->Left+Ruler->Width+1; PanelVert->Height = Ruler->Height; sbVert->Height = PanelVert->Height-sbVert->Top-2; iMainImage->SetPosition(); FullViewForm->SetSize(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) { MainMenuForm->iMainImageKeyDown(this, Key); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormKeyPress(TObject *Sender, char &Key) { #ifndef ACADEMY bool NotWork = false; //qe TexWork°¡ ¿­·ÁÀÖÁö ¾Ê°Å³ª Minimized µÇ¾úÀ»¶§¸¸ A,S ´ÜÃàŰ ½ÇÇàµÇµµ·Ï if(TexWork){ if(TexWork->WindowState == wsMinimized){ NotWork = true; }else { NotWork = false; } }else { NotWork = true; } if((Key == 65 || Key == 97 || Key == 83 || Key == 115)&& NotWork) //È®´ëÃà¼Ò MainImageForm->iMainImageKeyDown(Key); #else if(Key == 65 || Key == 97 || Key == 83 || Key == 115) MainImageForm->iMainImageKeyDown(Key); //È®´ëÃà¼Ò ´ÜÃàŰ·Î #endif MainMenuForm->iMainImageKeyPress(this, Key); // sbVert->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::FormKeyUp(TObject *Sender, WORD &Key, TShiftState Shift) { MainMenuForm->iMainImageKeyUp(this, Key); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::TempLabelMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { int x, y; if (Button == mbLeft) { x = iMainImage->CanvasToBitmapX(TempLabel->Left + X); y = iMainImage->CanvasToBitmapY(TempLabel->Top + Y); iMainImageMouseDown(this, Button, Shift, x, y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PaintDirectly(iMainImage->Canvas->Handle,iMainImage->Parent->Left,iMainImage->Parent->Top, iMainImage->Parent->Width,iMainImage->Parent->Height); isPaintDirectlyClean=true; TRect r; COLORREF c; Byte color; if (Active) { //if (Button==mbRight) return; // style imagedelete¶§¹®¿¡ ¸·À½ 99/10/01 if (X>=0 && XBitmap->Width && Y>=0 && YBitmap->Height) { DownState = true; if (Shift.Contains(ssCtrl) && Button==mbLeft) { MouseState = 1; iMainImage->Cursor = crHandPoint; ptFirst = Point(X, Y); } else { if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { c = iMainImage->Bitmap->GetPixelColor(X, Y); if (iMainImage->Bitmap->BitsPerPixel == 24) { PaletteForm->DIB256Palette->SetNormal(PaletteForm->DIB256Palette->ChoiceIndex, GetRValue(c), GetGValue(c), GetBValue(c)); color = PaletteForm->DIB256Palette->ChoiceIndex; PaletteForm->DIB256Palette->Repaint(); } else color = c; PenManagerForm->SelectColor(color); } if (MainMenuForm->iMainImageMouseDown(this, Button, Shift, X, Y)) { PaletteForm->iMainImageMouseDown(Sender, Button, Shift, X, Y); if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)) { // PenManagerForm->SelectColor(iMainImage->Bitmap->GetPixelColor(X, Y)); PenManagerForm->SpecialMouseDown(Button, Shift, X, Y); } else if (Button==mbLeft) { if (bDrawPen) { if (FullViewForm->iMainImageMouseDown(Sender, X, Y)) { PenManagerForm->SpecialMouseDown(Button, Shift, X, Y); BtnClick = true; } } } } } } } isPaintDirectlyClean=false; PaintDirectly(iMainImage->Canvas->Handle,iMainImage->Parent->Left,iMainImage->Parent->Top, iMainImage->Parent->Width,iMainImage->Parent->Height); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseLeave(TObject *Sender) { isFirst=true; if(iMainImage->OnPaintCursor) iMainImage->OnPaintCursor(iMainImage,iMainImage->Canvas->Handle,Pen.x,Pen.y); if(iMainImage->OnPaintCrossLine) iMainImage->OnPaintCrossLine(iMainImage,iMainImage->Canvas->Handle); // DrawArcLocate(Point(0,0),0, 0,0, 0,true, true,0); MainMenuForm->iMainImageMouseLeave(this); iMainImage->Cursor = crDefault; // iMainImage->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { PaintDirectly(iMainImage->Canvas->Handle,iMainImage->Parent->Left,iMainImage->Parent->Top, iMainImage->Parent->Width,iMainImage->Parent->Height); isPaintDirectlyClean=true; isFirst=false; Pen.x=iMainImage->BitmapToCanvasX(X);Pen.y=iMainImage->BitmapToCanvasY(Y); if (sbCrossLine->Down&&!DrawORStitch) { MainImageForm->iMainImage->OnPaintCrossLine = PaintCrossLine; MainImageForm->iMainImage->OnPaintCursor=NULL; } else { MainImageForm->iMainImage->OnPaintCrossLine = NULL; if(iMainImage->Cursor==crPen)MainImageForm->iMainImage->OnPaintCursor=PaintPenLocate; else MainImageForm->iMainImage->OnPaintCursor=NULL; } POINT pt; COLORREF color; int px, py; //<-- playzzang TCursor cursor,OldCursor; // --> playzzang if (Active) { if (X < 0 || X >= iMainImage->Bitmap->Width || Y < 0 || Y >= iMainImage->Bitmap->Height) { BtnClick = false; } px = (X - iMainImage->PositionX) * iMainImage->ZoomIn / iMainImage->ZoomOut; py = (Y - iMainImage->PositionY) * iMainImage->ZoomIn / iMainImage->ZoomOut; if (px < 0 || px >= iMainImage->Width || py < 0 || py >= iMainImage->Height) { MainMenuForm->iMainImageMouseLeave(this); iMainImage->Cursor = crDefault; } if (X>=0 && XBitmap->Width && Y>=0 && YBitmap->Height) { if (iMainImage->Cross) { iMainImage->SetCrossPos(Point(X, Y)); if(!DrawORStitch)iMainImage->Cursor = crNone; } else Screen->Cursor = NULL; CursorPosition.x = X; CursorPosition.y = Y; if (MouseState) { ptSecond = Point(X, Y); pt.x = ptSecond.x-ptFirst.x; pt.y = ptSecond.y-ptFirst.y; iMainImage->SetPosition(iMainImage->PositionX-pt.x, iMainImage->PositionY-pt.y); ptFirst.x = ptSecond.x-pt.x; ptFirst.y = ptSecond.y-pt.y; } else { if (DownState==false) { color = iMainImage->Bitmap->GetPixelColor(CursorPosition.x, CursorPosition.y); PaletteForm->DIB256Palette->CursorIndex = color; } if (MainMenuForm->iMainImageMouseMove(this, Shift, X, Y)) { if (bDrawPen) { if (FullViewForm->iMainImageMouseMove(Sender, X, Y)) { if (PenManagerForm->acolor == 1) { PenManagerForm->SpecialMouseMove(Shift, X, Y); if(!iMainImage->Cross)iMainImage->Cursor = crCross; } else { if (BtnClick) PenManagerForm->SpecialMouseMove(Shift, X, Y); if (!MainImageForm->iMainImage->Cross)iMainImage->Cursor = crPen; } } else { if(!iMainImage->Cross)iMainImage->Cursor = crCross; } } PaletteForm->iMainImageMouseMove(Sender, Shift, X, Y); } } } else { MainMenuForm->iMainImageMouseLeave(this); iMainImage->Cursor = crDefault; } } isPaintDirectlyClean=false; PaintDirectly(iMainImage->Canvas->Handle,iMainImage->Parent->Left,iMainImage->Parent->Top, iMainImage->Parent->Width,iMainImage->Parent->Height); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { PaintDirectly(iMainImage->Canvas->Handle,iMainImage->Parent->Left,iMainImage->Parent->Top, iMainImage->Parent->Width,iMainImage->Parent->Height); isPaintDirectlyClean=true; if (Active) { if (MouseState) { ptSecond = Point(X, Y); iMainImageChange(); iMainImage->SetPosition(iMainImage->PositionX-(ptSecond.x-ptFirst.x), iMainImage->PositionY-(ptSecond.y-ptFirst.y)); MouseState = 0; } else { if ((XBitmap->Width) && (YBitmap->Height)) { bool isNonePen; if (isNonePen=MainMenuForm->iMainImageMouseUp(this, Button, Shift, X, Y)) { PenManagerForm->SpecialMouseUp(Button, Shift, X, Y); if (AutoRepeat && (PaletteForm->Item != 6)) RedrawingRepeat(PenManagerForm->sbMask->Down, true); BtnClick = false; } if(MainImageForm->iMainImage->Bitmap->BitsPerPixel == 24){ if(!isNonePen){ MainImageForm->iMainImage->Repaint(); if(FullViewForm->Visible==true)FullViewForm->View(); #ifndef ACADEMY if(LayerForm->Visible==true){ ((TPLayer *)(iMainImage->LayerList->Items[iMainImage->Index])) ->UpdateMiniBitmap(iMainImage->Frgb); LayerForm->LayerGrid->Repaint(); } #endif /* RECT rc=Rect(MainImageForm->iMainImage->CanvasToBitmapX(0), MainImageForm->iMainImage->CanvasToBitmapY(0), MainImageForm->iMainImage->CanvasToBitmapX(MainImageForm->iMainImage->Parent->Width-1), MainImageForm->iMainImage->CanvasToBitmapY(MainImageForm->iMainImage->Parent->Height-1)); MainImageForm->iMainImage->RectPaint(rc);//by jeegeo*/ } } else { MainImageForm->iMainImage->Repaint(); if(FullViewForm->Visible==true)FullViewForm->View(); #ifndef ACADEMY if(LayerForm->Visible==true){ ((TPLayer *)(iMainImage->LayerList->Items[iMainImage->Index])) ->UpdateMiniBitmap(iMainImage->Frgb); LayerForm->LayerGrid->Repaint(); } #endif } DownState = false; } } } isPaintDirectlyClean=false; PaintDirectly(iMainImage->Canvas->Handle,iMainImage->Parent->Left,iMainImage->Parent->Top, iMainImage->Parent->Width,iMainImage->Parent->Height); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImagePaint(TObject *Sender) { // } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImagePositionChange(TObject *Sender) { UpdateImage(); Ruler->StartX = iMainImage->PositionX; Ruler->StartY = iMainImage->PositionY; sbHorz->Position = iMainImage->PositionX; sbVert->Position = iMainImage->PositionY; FullViewForm->SetPositionX(iMainImage->PositionX); FullViewForm->SetPositionY(iMainImage->PositionY); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbUnitClick(TObject *Sender) { if (CurrentUnit==uDot) UnitChange(uInch); else if (CurrentUnit==uInch) UnitChange(uCm); else if (CurrentUnit==uCm) UnitChange(uDot); //================================== for fit size by kjs //v7.1À» ÄÄÆÄÀÏÇϱâ À§ÇØ Àá½Ã ¸·¾Æ³ð.. if (MainMenuForm->sb3D->Enabled) MainMenuForm->Show_FabricSize(); //=================================== } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbHorzScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { iMainImageChange(); iMainImage->PositionX = sbHorz->Position; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbZoomInClick(TObject *Sender) { switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: ZoomChange(2, 1); break; case 2: ZoomChange(1, 1); break; case 4: ZoomChange(1, 2); break; case 8: ZoomChange(1, 4); break; case 16: ZoomChange(1, 8); break; } break; case 2: ZoomChange(4, 1); break; case 4: ZoomChange(8, 1); break; case 8: ZoomChange(16, 1); break; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbZoomOutClick(TObject *Sender) { switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: ZoomChange(1, 2); break; case 2: ZoomChange(1, 4); break; case 4: ZoomChange(1, 8); break; case 8: ZoomChange(1, 16); break; } break; case 2: ZoomChange(1, 1); break; case 4: ZoomChange(2, 1); break; case 8: ZoomChange(4, 1); break; case 16: ZoomChange(8, 1); break; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbRulerClick(TObject *Sender) { iMainImageChange(); FormResize(this); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbProtectClick(TObject *Sender) { TSpeedButton *s = (TSpeedButton *)Sender; if (s == sbProtect) { bProtect ^= 1; SetProtectBackGround(); MainMenuForm->SuperChange(Sender); } else if (s == sbMaskArea) { bMaskArea ^= 1; MainMenuForm->SuperChange(Sender); } else if (s == sbMaskShow) { SetMaskShow(sbMaskShow->Down); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbGridClick(TObject *Sender) { iMainImageChange(); iMainImage->Grid = sbGrid->Down; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbVertScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { iMainImageChange(); iMainImage->PositionY = sbVert->Position; } //--------------------------------------------------------------------------- // Private Function //--------------------------------------------------------------------------- int TMainImageForm::WMNCPaint(TMessage &msg) { DefWindowProc(Handle, WM_NCPAINT, msg.WParam, msg.LParam); return 0; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetCaption() { AnsiString fn = ExtractFileName(FileName); if (iMainImage->Bitmap->BitsPerPixel==8) { Caption = (DirName.Length()>0 ? DirName+"\\"+ fn: fn)+" - 256 Colors"; } else { Caption = (DirName.Length()>0 ? DirName+"\\"+ fn : fn)+" - Full Colors"; } #ifdef ACADEMY sbProtect->Enabled = false; sbMaskArea->Enabled = false; sbMaskShow->Enabled = false; #else if (iMainImage->Bitmap->BitsPerPixel==8) { sbProtect->Enabled = true; } else { sbProtect->Enabled = false; } #endif } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadFromFile(AnsiString FileName, TGraphicFileFormat Index, TTexpiaBitmap *pBitmap, TPalette *pPalette, TPCanvasInfor &ci, bool &layer, WORD bpp) { TEXPIAFILEHEADER tpfh; int x, y; RGBQUAD rgb[256]; Byte c[256], *bp; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; #ifdef ACADEMY if (Index==gffTEX) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap))!= EC_NONE) goto fail; ci = tpfh.CanvasInfor; CloseHandle(hFile); #else if (Index==gffTEX || Index==gffTFC) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap))!= EC_NONE) goto fail; UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T'&& tpfh.Version.Number >= 230) { if (!ReadFile(hFile, &layer, sizeof(bool), &dwRead, NULL)) goto fail; if (layer) { if (bpp == pBitmap->BitsPerPixel) { if (bpp == 8) { pPalette->ToRGBQUAD(rgb, 256); iMainImage->LoadFromLayerFile(hFile, rgb); } else { iMainImage->LoadFromLayerFile(hFile); } } else { layer = false; } } } CloseHandle(hFile); } else if (Index==gffWEA || Index==gffWAV || Index==gffKNT) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, false))!= EC_NONE) goto fail; UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; CloseHandle(hFile); #endif } else { if (!pBitmap->LoadFromFile(FileName.c_str())) { ec = EC_FILE_NOT_READ; goto fail; } ci.DotsPerInch = CanvasInfor.DotsPerInch ? CanvasInfor.DotsPerInch : 160; ci.SetSize(cstFree, pBitmap->Width, pBitmap->Height); if (pBitmap->BitsPerPixel==8) { pBitmap->GetColors(0, 256, rgb); pPalette->SetNormal(0, 0, 0, 0); for (x = 0; x < 250; x++) { pPalette->SetNormal(x+2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } pPalette->SetNormal(255, 255, 255, 255); } } return EC_NONE; fail: if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile); return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::LoadToSelectImage(AnsiString FileName, TGraphicFileFormat Index, TTexpiaBitmap *pBitmap, TPalette *pPalette, TPCanvasInfor &ci) { TEXPIAFILEHEADER tpfh; int x, y; RGBQUAD rgb[256]; Byte c[256], *bp; TPException ec = EC_NONE; HANDLE hFile = INVALID_HANDLE_VALUE; #ifdef ACADEMY if (Index==gffTEX) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap))!= EC_NONE) goto fail; ci = tpfh.CanvasInfor; CloseHandle(hFile); #else if (Index==gffTEX || Index==gffTFC) { if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap))!= EC_NONE) goto fail; UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; CloseHandle(hFile); } else if (Index==gffWEA || Index==gffWAV || Index==gffKNT) { if (!FileExists(FileName)) { ec = EC_FILE_NOT_EXIST; goto fail; } if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, false))!= EC_NONE) goto fail; UserColorLibForm->ThisFileHasUserColor(pPalette); ci = tpfh.CanvasInfor; CloseHandle(hFile); #endif } else { if (!pBitmap->LoadFromFile(FileName.c_str())) { ec = EC_FILE_NOT_READ; goto fail; } ci.DotsPerInch = CanvasInfor.DotsPerInch ? CanvasInfor.DotsPerInch : 160; ci.SetSize(cstFree, pBitmap->Width, pBitmap->Height); if (pBitmap->BitsPerPixel==8) { pBitmap->GetColors(0, 256, rgb); pPalette->SetNormal(0, 0, 0, 0); for (x=0; x<=249; x++) { pPalette->SetNormal(x+2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } pPalette->SetNormal(255, 255, 255, 255); } } return EC_NONE; fail: if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); return ec; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ReviewStatusBar() { MainForm->StatusBar->Panels->Items[StatusBarSize]->Text = "Size : " + CanvasInfor.Name(CurrentUnit, iMainImage->Bitmap->Width, iMainImage->Bitmap->Height); MainForm->StatusBar->Panels->Items[StatusBarDPI]->Text = Format("DPI : %d", OPENARRAY(TVarRec, (CanvasInfor.DotsPerInch))); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetProtectBackGround() { if (bProtect) { iMainImage->InitBackGround(0x10); } else { iMainImage->ExitBackGround(0x10); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetProtect(bool Value) { if (Value!=bProtect) { bProtect = Value; if (bProtect) sbProtect->Down = true; else sbProtect->Down = false; SetProtectBackGround(); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetMaskArea(bool Value) { if (Value!=bMaskArea) { bMaskArea = Value; sbMaskArea->Enabled = Value; sbMaskArea->Down = Value; sbMaskShow->Enabled = Value; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetMaskShow(bool Value) { if (iMainImage->MaskEnabled!=Value) { iMainImage->MaskEnabled = Value; sbMaskShow->Down = Value; } } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::AllocLineMem(int d) { if (d!=memsize) { DelLineMem(); if ((hMemLine = GlobalAlloc(GHND, 2*d*sizeof(int)))==NULL) goto fail; if ((msx = (int *)GlobalLock(hMemLine))==NULL) goto fail; mex = (int *)msx + d; memsize = d; } return true; fail: DelLineMem(); return false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::DelLineMem() { if (hMemLine) { if (msx) { GlobalUnlock(hMemLine); msx = NULL; } GlobalFree(hMemLine); hMemLine = NULL; } memsize = 0; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::pos_in(TLineData &ld, int by, int bsx, int bex, int ch) { double d; if ((by>=0) && (byBitmap->Height)) { if (*(msx+by)>bsx) { if (ch) { d = (ld.dx1 - bsx) * (ld.dx1 - bsx) + (ld.dy1 - by) * (ld.dy1 - by); if (dIsBackGround()) { case 0: if (!OpenItem_none(X, Y)) goto fail; break; case 1: if (!OpenItem_layer(X, Y)) goto fail; break; default: goto fail; } return true; fail: return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::OpenItem_none(int X, int Y) { RECT rc; Byte *dsl, *ssl, *mml, *bml, *sml, mm; COLORREF sc, dc, color, bgc; int x, y; RGBQUAD rgb[256]; TPItemImage *Image = iMainImage; Image->SubVisible = true; x = X - Center.x; if (x < 0) x = 0; else if (x + Image->SubBitmap->Width > Image->Bitmap->Width) x = Image->Bitmap->Width - Image->SubBitmap->Width; y = Y - Center.y; if (y < 0) y = 0; else if (y + Image->SubBitmap->Height > Image->Bitmap->Height) y = Image->Bitmap->Height - Image->SubBitmap->Height; rc = Rect(x, y, x + Image->SubBitmap->Width, y + Image->SubBitmap->Height); if (FullViewForm->Super==sOverlap) { FullViewForm->ReadyToOverlapChange(Image->SubBitmap, rc, MainImageForm->Palette->UseColor); } if (bMaskArea) { if (!Image->SubBitmap->StartScanLine()) goto fail; if (!Image->SubMask->StartScanLine()) goto fail; if (!Image->Bitmap->StartScanLine()) goto fail; if (!Image->Mask->StartScanLine()) goto fail; if (FullViewForm->Super==sOverlap) { if (!InitOverlap()) goto fail; if (Image->Bitmap->BitsPerPixel==8) { if (Image->SubBitmap->BitsPerPixel!=8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+rc.left; mml = Image->Mask->GetScanLine(y)+rc.left; for (x=rc.left; xColorData[*dsl]->Protect==0 && (*mml == 0)) { if (*dsl > 1) { if ((color = Overlap(*dsl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+rc.left; mml = Image->Mask->GetScanLine(y)+rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++, mml++) { if (*sml == 0xFF) continue; if (*mml == 0) { if (*dsl > 1) { if ((color = Overlap(*dsl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->Bitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Image->SubBitmap->BitsPerPixel==8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+3*rc.left; mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl+=3) { if (*sml== 0xFF) continue; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(dsl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+3*rc.left; mml = Image->Mask->GetScanLine(y); mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl+=3, dsl+=3) { if ((*sml & mm) == 0) { if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(dsl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->Bitmap->PutScanLine(y); } } } ExitOverlap(); } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); for (x=rc.left; xColorData[dsl[x]]->Protect==0 && (mml[x] == 0)) { dsl[x] = ssl[x-rc.left]; } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (mml[x] == 0) { dsl[x] = ssl[x-rc.left]; } } iMainImage->Bitmap->PutScanLine(y); } } } else { if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y) + 3*rc.left; mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl+=3) { if (*sml == 0xFF) continue; if ((*(mml +(x >> 3)) & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); SetPixel24(dsl, sc); } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y) + 3*rc.left; mml = Image->Mask->GetScanLine(y); mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl+=3, dsl+=3) { if ((*sml & mm) == 0) { if ((*(mml +(x >> 3)) & (0x80 >> (x & 7))) == 0) { CopyPixel24(dsl, ssl); } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->Bitmap->PutScanLine(y); } } } } Image->SubMask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); } else { if (!Image->SubBitmap->StartScanLine()) goto fail; if (!Image->SubMask->StartScanLine()) goto fail; if (!Image->Bitmap->StartScanLine()) goto fail; if (FullViewForm->Super==sOverlap) { if (!InitOverlap()) goto fail; if (Image->Bitmap->BitsPerPixel==8) { if (Image->SubBitmap->BitsPerPixel!=8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++) { if (*sml == 0xFF) continue; if (Palette->ColorData[*dsl]->Protect==0) { if (*bml > 1) { if ((color = Overlap(*dsl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+ rc.left; for (x=rc.left; x 1) { if ((color = Overlap(*dsl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } Image->Bitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Image->SubBitmap->BitsPerPixel==8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y) + 3*rc.left; for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl+=3) { if (*sml == 0xFF) continue; sc = RGBToTColor(rgb[*ssl]); GetPixel24(dsl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+3*rc.left; mm = 0x80; for (x=rc.left; x>= 1; } Image->Bitmap->PutScanLine(y); } } } ExitOverlap(); } else { if (Image->Bitmap->BitsPerPixel == 8) { if (Image->SubBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[dsl[x]]->Protect==0) { dsl[x] = ssl[x-rc.left]; } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; dsl[x] = ssl[x-rc.left]; } Image->Bitmap->PutScanLine(y); } } } else { if (Image->SubBitmap->BitsPerPixel==8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y) + 3*rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl+=3) { if (*sml == 0xFF) continue; sc = RGBToTColor(rgb[*ssl]); SetPixel24(dsl, sc); } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+3*rc.left; mm = 0x80; for (x=rc.left; x>= 1; } Image->Bitmap->PutScanLine(y); } } } } Image->SubMask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->Bitmap->StopScanLine(); } if (AutoRepeat) RedrawingRepeat(false, true); // for using clibboard to copy if (MainMenuForm->SubItem==0) { WorkArea->SetRectangle(rc); WorkAreaChange(); } return true; fail: if (FullViewForm->Super == sOverlap) { FullViewForm->ExitOverlapChange(); ExitOverlap(); } Image->Bitmap->StopScanLine(); if (bMaskArea) Image->Mask->StopScanLine(); Image->SubBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::OpenItem_layer(int X, int Y) { RECT rc; Byte *dsl, *ssl, *mml, *bml, *sml, mm; COLORREF sc, dc, color, bgc; int x, y; RGBQUAD rgb[256]; TPItemImage *Image = iMainImage; Image->SubVisible = true; x = X - Center.x; if (x < 0) x = 0; else if (x + Image->SubBitmap->Width > Image->Bitmap->Width) x = Image->Bitmap->Width - Image->SubBitmap->Width; y = Y - Center.y; if (y < 0) y = 0; else if (y + Image->SubBitmap->Height > Image->Bitmap->Height) y = Image->Bitmap->Height - Image->SubBitmap->Height; rc = Rect(x, y, x + Image->SubBitmap->Width, y + Image->SubBitmap->Height); if (FullViewForm->Super==sOverlap) { FullViewForm->ReadyToOverlapChange(Image->SubBitmap, rc, MainImageForm->Palette->UseColor); } if (bMaskArea) { if (!Image->SubBitmap->StartScanLine()) goto fail; if (!Image->SubMask->StartScanLine()) goto fail; if (!Image->Bitmap->StartScanLine()) goto fail; if (!Image->Mask->StartScanLine()) goto fail; if (!Image->BackGround->StartScanLine()) goto fail; if (FullViewForm->Super==sOverlap) { if (!InitOverlap()) goto fail; if (Image->Bitmap->BitsPerPixel==8) { if (Image->SubBitmap->BitsPerPixel!=8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+rc.left; mml = Image->Mask->GetScanLine(y)+rc.left; bml = Image->BackGround->GetScanLine(y)+rc.left; for (x=rc.left; xColorData[*bml]->Protect==0 && (*mml == 0)) { if (*bml > 1) { if ((color = Overlap(*bml, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+rc.left; mml = Image->Mask->GetScanLine(y)+rc.left; bml = Image->BackGround->GetScanLine(y)+rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++, mml++, bml++) { if (*sml == 0xFF) continue; if (*mml == 0) { if (*bml > 1) { if ((color = Overlap(*bml, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->Bitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Image->SubBitmap->BitsPerPixel==8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+3*rc.left; mml = Image->Mask->GetScanLine(y); bml = Image->BackGround->GetScanLine(y)+3*rc.left; for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl+=3, bml+=3) { if (*sml == 0xFF) continue; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(bml, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+3*rc.left; mml = Image->Mask->GetScanLine(y); bml = Image->BackGround->GetScanLine(y)+3*rc.left; mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl+=3, dsl+=3, bml+=3) { if ((*sml & mm) == 0) { if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(bml, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->Bitmap->PutScanLine(y); } } } ExitOverlap(); } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); bml = Image->BackGround->GetScanLine(y); for (x=rc.left; xColorData[bml[x]]->Protect==0 && (mml[x] == 0)) { dsl[x] = ssl[x-rc.left]; } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y); mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (mml[x] == 0) { dsl[x] = ssl[x-rc.left]; } } iMainImage->Bitmap->PutScanLine(y); } } } else { if (Image->SubBitmap->BitsPerPixel == 8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y) + 3*rc.left; mml = Image->Mask->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl+=3) { if (*sml == 0xFF) continue; if ((*(mml +(x >> 3)) & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); SetPixel24(dsl, sc); } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y) + 3*rc.left; mml = Image->Mask->GetScanLine(y); mm = 0x80; for (x = rc.left; x < rc.right; x++, ssl+=3, dsl+=3) { if ((*sml & mm) == 0) { if ((*(mml +(x >> 3)) & (0x80 >> (x & 7))) == 0) { CopyPixel24(dsl, ssl); } } if (mm == 1) { sml++; mm = 0x80; } else mm >>= 1; } Image->Bitmap->PutScanLine(y); } } } } Image->SubMask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->BackGround->StopScanLine(); Image->Mask->StopScanLine(); Image->Bitmap->StopScanLine(); } else { if (!Image->SubBitmap->StartScanLine()) goto fail; if (!Image->SubMask->StartScanLine()) goto fail; if (!Image->Bitmap->StartScanLine()) goto fail; if (!Image->BackGround->StartScanLine()) goto fail; if (FullViewForm->Super==sOverlap) { if (!InitOverlap()) goto fail; if (Image->Bitmap->BitsPerPixel==8) { if (Image->SubBitmap->BitsPerPixel!=8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+rc.left; bml = Image->BackGround->GetScanLine(y)+rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl++, bml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[*bml]->Protect==0) { if (*bml > 1) { if ((color = Overlap(*bml, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+ rc.left; bml = Image->BackGround->GetScanLine(y) + rc.left; for (x=rc.left; x 1) { if ((color = Overlap(*bml, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } Image->Bitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (Image->SubBitmap->BitsPerPixel==8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y) + 3*rc.left; bml = Image->BackGround->GetScanLine(y)+3*rc.left; for (x = rc.left; x < rc.right; x++, ssl++, sml++, dsl+=3, bml+=3) { if (*sml == 0xFF) continue; sc = RGBToTColor(rgb[*ssl]); GetPixel24(bml, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+3*rc.left; bml = Image->BackGround->GetScanLine(y)+3*rc.left; mm = 0x80; for (x=rc.left; x>= 1; } Image->Bitmap->PutScanLine(y); } } } ExitOverlap(); } else { if (Image->Bitmap->BitsPerPixel == 8) { if (Image->SubBitmap->BitsPerPixel != 8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y); bml = Image->BackGround->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; if (Palette->ColorData[bml[x]]->Protect==0) { dsl[x] = ssl[x-rc.left]; } } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y); for (x = rc.left; x < rc.right; x++, sml++) { if (*sml == 0xFF) continue; dsl[x] = ssl[x-rc.left]; } Image->Bitmap->PutScanLine(y); } } } else { if (Image->SubBitmap->BitsPerPixel==8) { Image->SubBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y) + 3*rc.left; for (x = rc.left; x < rc.right; x++, sml++, ssl++, dsl+=3) { if (*sml == 0xFF) continue; sc = RGBToTColor(rgb[*ssl]); SetPixel24(dsl, sc); } Image->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = Image->SubBitmap->GetScanLine(y-rc.top); sml = Image->SubMask->GetScanLine(y-rc.top); dsl = Image->Bitmap->GetScanLine(y)+3*rc.left; mm = 0x80; for (x=rc.left; x>= 1; } Image->Bitmap->PutScanLine(y); } } } } Image->SubMask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->BackGround->StopScanLine(); Image->Bitmap->StopScanLine(); } if (Image->LayerMask) Image->LayerMask->CopyToRect(rc.left, rc.top, Image->SubMask, SRCAND); if (AutoRepeat) RedrawingRepeat(false, true); // for using clibboard to copy if (MainMenuForm->SubItem==0) { WorkArea->SetRectangle(rc); WorkAreaChange(); } return true; fail: if (FullViewForm->Super == sOverlap) { FullViewForm->ExitOverlapChange(); ExitOverlap(); } Image->Bitmap->StopScanLine(); if (bMaskArea) Image->Mask->StopScanLine(); Image->SubBitmap->StopScanLine(); Image->BackGround->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); return false; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToClipboard() { RGBQUAD rgb[256]; BITMAPHANDLE bh, *pbh; int w, h, i, x, y; HDC dcSrc = NULL, dcMask = NULL, dcDst = NULL; HGLOBAL hMem = NULL; Byte *lpData = NULL; TClipboardInfo cbi; TColorData *cd; Byte *mp, *bp; COLORREF c; bool bClipboard = false; TPException ec = EC_NONE; if (WorkArea->Mask) { memset(&bh, 0, sizeof(BITMAPHANDLE)); w = WorkArea->Range.right-WorkArea->Range.left; h = WorkArea->Range.bottom-WorkArea->Range.top; // if (L_CreateBitmap(&bh, TYPE_CONV, w, h, iMainImage->Bitmap->BitsPerPixel, ORDER_BGR, NULL, TOP_LEFT)<1) goto next1; if (iMainImage->Bitmap->BitsPerPixel==8) { Palette->ToRGBQUAD(rgb, 256); L_PutBitmapColors(&bh, 0, 256, rgb); WorkArea->Mask->PutColors(0, 256, rgb); } if ((dcDst = L_CreateLeadDC(&bh))==NULL) goto next1; if ((dcSrc = iMainImage->Bitmap->CreateDC())==NULL) goto next1; BitBlt(dcDst, 0, 0, w, h, dcSrc, WorkArea->Range.left, WorkArea->Range.top, SRCCOPY); iMainImage->Bitmap->DeleteDC(dcSrc); dcSrc = NULL; if ((dcMask = WorkArea->Mask->CreateDC())==NULL) goto next1; BitBlt(dcDst, 0, 0, w, h, dcMask, 0, 0, SRCAND); WorkArea->Mask->DeleteDC(dcMask); dcMask = NULL; L_DeleteLeadDC(dcDst); dcDst = NULL; if (L_CopyToClipboard(MainForm->Handle, &bh)<1) goto next1; L_FreeBitmap(&bh); goto next2; next1: if (dcDst) { if (dcMask) WorkArea->Mask->DeleteDC(dcMask); if (dcSrc) iMainImage->Bitmap->DeleteDC(dcSrc); L_DeleteLeadDC(dcDst); } L_FreeBitmap(&bh); next2: // if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; goto fail; } bClipboard = true; if (MainForm->ClipboardFormat) { cbi.Version = 0; cbi.Time = clock(); cbi.Width = w; cbi.Height = h; cbi.Mask = true; if (iMainImage->Bitmap->BitsPerPixel==8) { cbi.BitsPerPixel = 8; cbi.Colors = Palette->UseColor; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo)+ cbi.Colors*sizeof(TColorData)+cbi.Width*cbi.Height))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); for (i=1; i<=cbi.Colors; i++) { cd = Palette->ColorData[i]; memcpy(lpData, cd, sizeof(TColorData)); lpData += sizeof(TColorData); } if (!iMainImage->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yBitmap->GetScanLine(WorkArea->Range.top+y); mp = WorkArea->Mask->GetScanLine(y); for (x=0; xRange.left+x); } else { *(lpData+x) = 0; } } lpData += cbi.Width; } iMainImage->Bitmap->StopScanLine(); WorkArea->Mask->StopScanLine(); GlobalUnlock(hMem); } else { cbi.BitsPerPixel = 24; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo)+sizeof(COLORREF)+ 3*cbi.Width*cbi.Height+WorkArea->Mask->BytesPerLine*cbi.Height))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); c = Palette->Color[1]; memcpy(lpData, &c, sizeof(COLORREF)); lpData += sizeof(COLORREF); if (!iMainImage->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yBitmap->GetScanLine(WorkArea->Range.top+y)+3*WorkArea->Range.left; memcpy(lpData, bp, 3*cbi.Width); lpData += 3*cbi.Width; } iMainImage->Bitmap->StopScanLine(); if (!WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yMask->GetScanLine(y); for (x=0; xMask->BytesPerLine; x++) { *(lpData+x) = ~*(mp+x); } lpData += WorkArea->Mask->BytesPerLine; } WorkArea->Mask->StopScanLine(); GlobalUnlock(hMem); } SetClipboardData(MainForm->ClipboardFormat, hMem); } CloseClipboard(); } else { if ((pbh = iMainImage->Bitmap->Handle)==NULL) { ec = EC_RESOURCE_LACK; goto fail; } // L_CopyToClipboard(MainForm->Handle, pbh); // if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; goto fail; } bClipboard = true; if (MainForm->ClipboardFormat) { cbi.Version = 0; cbi.Time = clock(); cbi.Width = iMainImage->Bitmap->Width; cbi.Height = iMainImage->Bitmap->Height; cbi.Mask = false; if (iMainImage->Bitmap->BitsPerPixel==8) { cbi.BitsPerPixel = 8; cbi.Colors = Palette->UseColor; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo)+ cbi.Colors*sizeof(TColorData)+cbi.Width*cbi.Height))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); for (i=1; i<=cbi.Colors; i++) { cd = Palette->ColorData[i]; memcpy(lpData, cd, sizeof(TColorData)); lpData += sizeof(TColorData); } if (!iMainImage->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yBitmap->GetScanLine(y); memcpy(lpData, bp, cbi.Width); lpData += cbi.Width; } iMainImage->Bitmap->StopScanLine(); GlobalUnlock(hMem); } else { cbi.BitsPerPixel = 24; if ((hMem = GlobalAlloc(GHND, sizeof(TClipboardInfo)+sizeof(COLORREF)+ 3*cbi.Width*cbi.Height))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((lpData = (Byte *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } memcpy(lpData, &cbi, sizeof(TClipboardInfo)); lpData += sizeof(TClipboardInfo); c = Palette->Color[1]; memcpy(lpData, &c, sizeof(COLORREF)); lpData += sizeof(COLORREF); if (!iMainImage->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yBitmap->GetScanLine(y); memcpy(lpData, bp, 3*cbi.Width); lpData += 3*cbi.Width; } iMainImage->Bitmap->StopScanLine(); GlobalUnlock(hMem); } SetClipboardData(MainForm->ClipboardFormat, hMem); } CloseClipboard(); } return EC_NONE; fail: if (bClipboard) { if (hMem) { if (lpData) { if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); iMainImage->Bitmap->StopScanLine(); GlobalUnlock(hMem); } GlobalFree(hMem); } CloseClipboard(); } return ec; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::ReadTexpiaFormatSuperOff(TClipboardInfo *cbi, Byte *Bitmap, int UseColor) { RGBQUAD rgb[256]; int x, y; Byte *sp, *bp, *mp; Palette->ToRGBQUAD(rgb, 256); TempBitmap->PutColors(0, 256, rgb); if (!TempBitmap->StartScanLine()) goto fail; if (cbi->Mask) { if ((TempMask = new TTexpiaBitmap)==NULL) goto fail; if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) goto fail; sp = Bitmap; if (!TempMask->StartScanLine()) goto fail; for (y=0; yHeight; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; x++, bp++, mp++) { if (*bp<1) { *bp = 0; *mp = 0xFF; } else { *bp += UseColor; *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempMask->StopScanLine(); } else { // TempMask = NULL; sp = Bitmap; for (y=0; yHeight; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); for (x=0; xWidth; x++) { if (*(bp+x)<1) { *(bp+x) = 0; } else { *(bp+x) += UseColor; } } TempBitmap->PutScanLine(y); sp += cbi->Width; } } TempBitmap->StopScanLine(); return true; fail: ::doDestroy(TempMask); TempBitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::ReadTexpiaFormatSuperNormal(TClipboardInfo *cbi, Byte *Bitmap, int UseColor) { RGBQUAD rgb[256]; int x, y; Byte *sp, *bp, *mp; Palette->ToRGBQUAD(rgb, 256); TempBitmap->PutColors(0, 256, rgb); if (!TempBitmap->StartScanLine()) goto fail; if ((TempMask = new TTexpiaBitmap)==NULL) goto fail; if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) goto fail; sp = Bitmap; if (!TempMask->StartScanLine()) goto fail; for (y=0; yHeight; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; x++, bp++, mp++) { if (*bp<2) { *bp = 0; *mp = 0xFF; } else { *bp += UseColor; *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempMask->StopScanLine(); TempBitmap->StopScanLine(); return true; fail: ::doDestroy(TempMask); TempBitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::ReadTexpiaFormatSuperGauge(TClipboardInfo *cbi, Byte *Bitmap, int UseColor) { RGBQUAD rgb[256]; int x, y; Byte *sp, *bp, *mp; Palette->ToRGBQUAD(rgb, 256); TempBitmap->PutColors(0, 256, rgb); if (!TempBitmap->StartScanLine()) goto fail; if ((TempMask = new TTexpiaBitmap)==NULL) goto fail; if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) goto fail; sp = Bitmap; if (!TempMask->StartScanLine()) goto fail; for (y=0; yHeight; y++) { bp = TempBitmap->GetScanLine(y); memcpy(bp, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; x++, bp++, mp++) { if (*bp<2 || ((x+y)&1)) { *bp = 0; *mp = 0xFF; } else { *bp += UseColor; *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempMask->StopScanLine(); TempBitmap->StopScanLine(); return true; fail: ::doDestroy(TempMask); TempBitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadTexpiaFormat8To8(TClipboardInfo *cbi) { TRect r; int i, x, y, bg; bool sw = false; TColorData *Color; Byte *Bitmap, *sp; TPException ec = EC_NONE; Color = (TColorData *)((Byte *)cbi+sizeof(TClipboardInfo)); Bitmap = (Byte *)Color+cbi->Colors*sizeof(TColorData); if ((TempBitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 8)) { ec = EC_MEMORY_LACK; goto fail; } switch (FullViewForm->Super) { case sOff: bg = 0; sp = Bitmap; for (y=0; yHeight; y++) { for (x=0; xWidth; x++) { if (*(sp+x)==1) { bg = 1; goto next1; } } sp += cbi->Width; } next1: if (cbTime==cbi->Time) { sw = true; if (Palette->UseColor==cbUseColor+cbi->Colors) { for (i=2-bg; i<=cbi->Colors; i++) { if (Palette->ColorData[cbUseColor+i]->Compare(Color+i-1)==false) { sw = false; break; } } } else { sw = false; } if (sw) { if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } } else { if (Palette->UseColor+cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i=2-bg; i<=cbi->Colors; i++) { Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } Palette->UseColor = cbUseColor+cbi->Colors; cbTime = cbi->Time; } } else { if (Palette->UseColor+cbi->Colors - 1 + bg >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i=2-bg; i<=cbi->Colors; i++) { Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperOff(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } Palette->UseColor = cbUseColor+cbi->Colors; cbTime = cbi->Time; } break; case sOverlap: case sNormal: if (cbTime==cbi->Time) { sw = true; if (Palette->UseColor==cbUseColor+cbi->Colors) { for (i=2; i<=cbi->Colors; i++) { if (Palette->ColorData[cbUseColor+i]->Compare(Color+i-1)==false) { sw = false; break; } } } else { sw = false; } if (sw) { if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } } else { if (Palette->UseColor + cbi->Colors - 1 >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor-1; for (i=2; i<=cbi->Colors; i++) { Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } Palette->UseColor = cbUseColor+cbi->Colors; cbTime = cbi->Time; } } else { if (Palette->UseColor+cbi->Colors-1 >= 251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor-1; for (i=2; i<=cbi->Colors; i++) { Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } Palette->UseColor = cbUseColor+cbi->Colors; cbTime = cbi->Time; } break; case sGauze: bg = 0; sp = Bitmap; for (y=0; yHeight; y++) { for (x=0; xWidth; x++) { if (*(sp+x)==1) { bg = 1; goto next2; } } sp += cbi->Width; } next2: if (cbTime==cbi->Time) { sw = true; if (Palette->UseColor==cbUseColor+cbi->Colors) { for (i=2-bg; i<=cbi->Colors; i++) { if (Palette->ColorData[cbUseColor+i]->Compare(Color+i-1)==false) { sw = false; break; } } } else { sw = false; } if (sw) { if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } } else { if (Palette->UseColor + cbi->Colors-1 + bg>=251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor-1+bg; for (i=2-bg; i<=cbi->Colors; i++) { Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } Palette->UseColor = cbUseColor+cbi->Colors; cbTime = cbi->Time; } } else { if (Palette->UseColor+cbi->Colors- 1 + bg>=251) { ec = EC_COLOR_OVERFLOW; goto fail; } cbUseColor = Palette->UseColor - 1 + bg; for (i=2-bg; i<=cbi->Colors; i++) { Palette->ColorData[cbUseColor+i]->Copy(Color+i-1); } if (ReadTexpiaFormatSuperNormal(cbi, Bitmap, cbUseColor) == false) { ec = EC_MEMORY_LACK; goto fail; } Palette->UseColor = cbUseColor+cbi->Colors; cbTime = cbi->Time; } break; } return EC_NONE; fail: ::doDestroy(TempBitmap); return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadTexpiaFormat8To24(TClipboardInfo *cbi) { TColorData *Color; int i, x, y; RGBQUAD rgb[256]; Byte *Bitmap, *sp, *ip, *mp; TPException ec = EC_NONE; Palette->ToRGBQUAD(rgb, 256); Color = (TColorData *)((Byte *)cbi+sizeof(TClipboardInfo)); for (i=1; i<=cbi->Colors; i++) { rgb[i] = Color[i-1].RGB; } Bitmap = (Byte *)Color+cbi->Colors*sizeof(TColorData); if ((TempBitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } switch (FullViewForm->Super) { case sOff: if (cbi->Mask) { if ((TempMask = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; x++, mp++) { if (*(ip+x)<1) { *mp = 0xFF; } else { *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempBitmap->StopScanLine(); TempMask->StopScanLine(); } else { sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); TempBitmap->PutScanLine(y); sp += cbi->Width; } TempBitmap->StopScanLine(); } break; case sOverlap: case sNormal: if ((TempMask = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; x++, ip++, mp++) { if (*ip<2) { *ip = 0; *mp = 0xFF; } else { *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } TempBitmap->StopScanLine(); TempMask->StopScanLine(); break; case sGauze: if ((TempMask = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } sp = Bitmap; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (cbi->Mask) { for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, cbi->Width); mp = TempMask->GetScanLine(y); for (x=0; xWidth; x++, ip++, mp++) { if (*ip<2) { *ip = 0; *mp = 0xFF; } else { *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += cbi->Width; } } TempBitmap->StopScanLine(); TempMask->StopScanLine(); break; } return EC_NONE; fail: if (TempBitmap) { ::doDestroy(TempMask); delete TempBitmap; TempBitmap = NULL; } return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadTexpiaFormat24To24(TClipboardInfo *cbi) { BYTE *sp, *ip, *mp, mm, b; WORD w; int x, y; COLORREF bgc, c; TPException ec = EC_NONE; sp = (Byte *)cbi+sizeof(TClipboardInfo); memcpy(&bgc, sp, sizeof(COLORREF)); sp += sizeof(COLORREF); if ((TempBitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(cbi->Width, cbi->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (cbi->BitsPerPixel==15) { for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); for (x=0; xWidth; x++, sp+=2) { w = *(WORD *)sp; b = w&0x1F; *ip = (b<<3)|((b&0x1C)>>2); ip++; w >>= 5; b = w&0x1F; *ip = (b<<3)|((b&0x1C)>>2); ip++; w >>= 5; b = w&0x1F; *ip = (b<<3)|((b&0x1C)>>2); ip++; } TempBitmap->PutScanLine(y); } } else { for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); memcpy(ip, sp, 3*cbi->Width); TempBitmap->PutScanLine(y); sp += 3*cbi->Width; } } TempBitmap->StopScanLine(); switch (FullViewForm->Super) { case sOff: if (cbi->Mask) { if ((TempMask = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); memcpy(mp, sp, TempMask->BytesPerLine); mm = 0x80; for (x=0; xWidth; x++, ip+=3) { if (*mp&mm) { SetPixel24(ip, 0); } if (mm==1) { mp++; mm = 0x80; } else mm >>= 1; } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += TempMask->BytesPerLine; } TempBitmap->StopScanLine(); TempMask->StopScanLine(); } break; case sOverlap: case sGauze: case sNormal: if ((TempMask = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(cbi->Width, cbi->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (cbi->Mask) { for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); memcpy(mp, sp, TempMask->BytesPerLine); mm = 0x80; for (x=0; xWidth; x++, ip+=3) { GetPixel24(ip, c); if ((*mp&mm) || c==bgc) { SetPixel24(ip, 0); *mp |= mm; } if (mm==1) { mp++; mm = 0x80; } else mm >>= 1; } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += TempMask->BytesPerLine; } } else { for (y=0; yHeight; y++) { ip = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); *mp = 0; mm = 0x80; //============================================================================== x=0; while(1) { GetPixel24(ip, c); if (c==bgc) { SetPixel24(ip, 0); *mp |= mm; } x++; if (x >= cbi->Width) break; ip+=3; if (mm==1) { mp++; *mp = 0; mm = 0x80; } else mm >>= 1; } /* for (x=0; xWidth; x++, ip+=3) { GetPixel24(ip, c); if (c==bgc) { SetPixel24(ip, 0); *mp |= mm; } if (mm==1) { mp++; *mp = 0; mm = 0x80; } else mm >>= 1; } */ //============================================================================== TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); sp += TempMask->BytesPerLine; } } TempBitmap->StopScanLine(); TempMask->StopScanLine(); break; } return EC_NONE; fail: if (TempBitmap) { ::doDestroy(TempMask); delete TempBitmap; TempBitmap = NULL; } return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadGeneralFormat8To8(BITMAPHANDLE *bh, int colors, short *color) { TRect r; int i, j, x, y; RGBQUAD rgb[256]; HANDLE hBuffer = NULL; Byte *pBuffer = NULL, *bp, *mp; TPException ec = EC_NONE; if (Palette->UseColor+colors-1>=252) { ec = EC_COLOR_OVERFLOW; goto fail; } L_GetBitmapColors(bh, 0, 256, rgb); cbUseColor = Palette->UseColor; for (i=0, j=cbUseColor+1; i<256; i++) { if (color[i]) { Palette->SetNormal(j, rgb[i].rgbRed, rgb[i].rgbGreen, rgb[i].rgbBlue); color[i] = j; j++; } } Palette->ToRGBQUAD(rgb, 256); if ((TempBitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(bh->Width, bh->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } L_AccessBitmap(bh); if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh->BytesPerLine))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((pBuffer = (Byte *)GlobalLock(hBuffer))==NULL) { ec = EC_MEMORY_LACK; goto fail; } switch (FullViewForm->Super) { case sOff: case sNormal: case sOverlap: case sGauze: if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); bp = TempBitmap->GetScanLine(y); memcpy(bp, pBuffer, bh->Width); for (x=0; xWidth; x++, bp++) { *bp = color[*bp]; } TempBitmap->PutScanLine(y); } TempBitmap->StopScanLine(); break; } Palette->UseColor = cbUseColor+colors; GlobalUnlock(hBuffer); GlobalFree(hBuffer); hBuffer = NULL; L_ReleaseBitmap(bh); return EC_NONE; fail: if (TempBitmap) { if (hBuffer) { if (pBuffer) { ::doDestroy(TempMask); GlobalUnlock(hBuffer); } GlobalFree(hBuffer); } delete TempBitmap; TempBitmap = NULL; } return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadGeneralFormat8To24(BITMAPHANDLE *bh, int colors, short *color) { HANDLE hBuffer = NULL; Byte *pBuffer = NULL; int i, x, y, nBlack, nWhite; RGBQUAD rgb[256], t; Byte *ip, *mp; TPException ec = EC_NONE; L_GetBitmapColors(bh, 0, 256, rgb); nBlack = -1; if (rgb[0].rgbRed!=0 || rgb[0].rgbGreen!=0 || rgb[0].rgbBlue!=0) { for (i=1; i<255; i++) { if (rgb[i].rgbRed==0 && rgb[i].rgbGreen==0 && rgb[i].rgbBlue==0) { nBlack = i; break; } } } else nBlack = 0; if (nBlack==-1) { for (i=1; i<255; i++) { if (color[i]==0) { nBlack = i; rgb[i].rgbRed = rgb[i].rgbGreen = rgb[i].rgbBlue = 0; color[i] = colors; colors++; break; } } if (i>=255) return EC_COLOR_OVERFLOW; } nWhite = -1; if (rgb[255].rgbRed!=255 || rgb[255].rgbGreen!=255 || rgb[255].rgbBlue!=255) { for (i=1; i<255; i++) { if (rgb[i].rgbRed==255 && rgb[i].rgbGreen==255 && rgb[i].rgbBlue==255) { nWhite = i; break; } } } else nWhite = 255; if (nWhite==-1) { for (i=1; i<255; i++) { if (color[i]==0) { nWhite = i; rgb[i].rgbRed = rgb[i].rgbGreen = rgb[i].rgbBlue = 255; color[i] = colors; colors++; break; } } if (i>=255) return EC_COLOR_OVERFLOW; } if (nBlack!=0) { t = rgb[0]; rgb[0] = rgb[nBlack]; rgb[nBlack] = t; } if (nWhite!=255) { t = rgb[255]; rgb[255] = rgb[nWhite]; rgb[nWhite] = t; } if ((TempBitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(bh->Width, bh->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh->BytesPerLine))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((pBuffer = (Byte *)GlobalLock(hBuffer))==NULL) { ec = EC_MEMORY_LACK; goto fail; } L_AccessBitmap(bh); if (nBlack!=0 || nWhite!=255) { for (y=0; yHeight; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); ip = pBuffer; for (x=0; xWidth; x++, ip++) { if (*ip==nBlack) *ip = 0; else if (*ip==0) *ip = nBlack; else if (*ip==nWhite) *ip = 255; else if (*ip==255) *ip = nWhite; } } } switch (FullViewForm->Super) { case sOff: case sNormal: case sOverlap: case sGauze: if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); ip = TempBitmap->GetScanLine(y); memcpy(ip, pBuffer, bh->Width); TempBitmap->PutScanLine(y); } TempBitmap->StopScanLine(); break; } L_ReleaseBitmap(bh); GlobalUnlock(hBuffer); GlobalFree(hBuffer); hBuffer = NULL; return EC_NONE; fail: if (TempBitmap) { if (hBuffer) { if (pBuffer) { ::doDestroy(TempMask); GlobalUnlock(hBuffer); } GlobalFree(hBuffer); } delete TempBitmap; TempBitmap = NULL; } return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::ReadGeneralFormat24To24(BITMAPHANDLE *bh) { HANDLE hBuffer = NULL; Byte *pBuffer = NULL; Byte *ip, *mp, mm; int x, y; TPException ec = EC_NONE; if ((TempBitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->Create(bh->Width, bh->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } L_AccessBitmap(bh); if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh->BytesPerLine))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((pBuffer = (Byte *)GlobalLock(hBuffer))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { L_GetBitmapRow(bh, pBuffer, y, bh->BytesPerLine); ip = TempBitmap->GetScanLine(y); memcpy(ip, pBuffer, 3*bh->Width); TempBitmap->PutScanLine(y); } TempBitmap->StopScanLine(); GlobalUnlock(hBuffer); pBuffer = NULL; GlobalFree(hBuffer); hBuffer = NULL; L_ReleaseBitmap(bh); return EC_NONE; fail: if (TempBitmap) { ::doDestroy(TempMask); if (hBuffer) { if (pBuffer) GlobalUnlock(hBuffer); GlobalFree(hBuffer); } delete TempBitmap; TempBitmap = NULL; } return ec; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::Irregularrect(HDC dcDst, TRect Src, TRect Dst) { TRect Msrc; RGBQUAD rgb[256]; TTexpiaBitmap *Mask = NULL; HDC dcSrc = NULL; if (iMainImage->Bitmap->BitsPerPixel == 8) { Palette->ToRGBQUAD(rgb, 256); Mask = WorkArea->Mask; Mask->PutColors(0, 256, rgb); } else { Mask = new TTexpiaBitmap; if (WorkArea->GetMask(Mask, 1) == false) goto fail; } Msrc.Left = Src.Left-WorkArea->Range.left; Msrc.Right = Src.Right-WorkArea->Range.left; Msrc.Top = Src.Top-WorkArea->Range.top; Msrc.Bottom = Src.Bottom-WorkArea->Range.top; if ((dcSrc = Mask->CreateDC())==NULL) goto fail; SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, Dst.Left, Dst.Top, Dst.Right-Dst.Left, Dst.Bottom-Dst.Top, dcSrc, Msrc.Left, Msrc.Top, Msrc.Right-Msrc.Left, Msrc.Bottom-Msrc.Top, MERGEPAINT); Mask->DeleteDC(dcSrc); if (Mask != WorkArea->Mask) ::doDestroy(Mask); return true; fail: if (dcSrc) Mask->DeleteDC(dcSrc); if (Mask && Mask!=WorkArea->Mask) ::doDestroy(Mask); return false; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::Repeat_Method(TTexpiaBitmap *Pattern, TSize r, TSize s, TRect Src, int len, int item, TTexpiaBitmap *Bitmap) { int P; TRect Source, Dst; int x, y; HDC dcSrc = NULL, dcDst = NULL; if ((dcSrc = Bitmap->CreateDC())==NULL) goto fail; if ((dcDst = Pattern->CreateDC())==NULL) goto fail; Source = Src; SetStretchBltMode(dcDst, COLORONCOLOR); switch (item) { // 0: Normal, 1: Half Drop Horizontal, 2: Half Drop Vertical case 0: for (y=0; yMask) { if (!Irregularrect(dcDst, Src, Dst)) goto fail; } } } break; case 1: for (y=0; yMask) { if (!Irregularrect(dcDst, Src, Dst)) goto fail; } } if (Dst.RightWidth) { Dst.Left = Dst.Right; Dst.Right = Pattern->Width; Src.Left = Source.Left; Src.Right = P; StretchBlt(dcDst, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), dcSrc, Src.Left, Src.Top, (Src.Right-Src.Left), (Src.Bottom-Src.Top), SRCCOPY); if (WorkArea->Mask) { if (!Irregularrect(dcDst, Src, Dst)) goto fail; } } } break; case 2: for (x=0; xMask) { if (!Irregularrect(dcDst, Src, Dst)) goto fail; } } if (Dst.BottomHeight) { Dst.Top = Dst.Bottom; Dst.Bottom = Pattern->Height; Src.Top = Source.Top; Src.Bottom = P; StretchBlt(dcDst, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), dcSrc, Src.Left, Src.Top, (Src.Right-Src.Left), (Src.Bottom-Src.Top), SRCCOPY); if (WorkArea->Mask) { if (!Irregularrect(dcDst, Src, Dst)) goto fail; } } } break; } Bitmap->DeleteDC(dcSrc); Pattern->DeleteDC(dcDst); return true; fail: if (dcSrc) Bitmap->DeleteDC(dcSrc); if (dcDst) Pattern->DeleteDC(dcDst); return false; } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::MosaicDraw8(TTexpiaBitmap *bm, int k, int m, int w, int h, int pi) { BYTE *p; TRect rect; int y, l; int mk = k*w; int mm = m*h; if (mk==0) mk = 1; if (mm==0) mm = 1; rect = Rect(mk-1, mm-1, (k+1)*w, (m+1)*h); bm->StartScanLine(); p = bm->GetScanLine(rect.Top) + rect.Left; memset(p, 0, rect.Right-rect.Left); bm->PutScanLine(rect.Top); for (y=rect.Top+1; yGetScanLine(y) + rect.Left; *p = 0; p++; l = rect.Right-rect.Left-2; memset(p, pi, l); p += l; *p = 0; bm->PutScanLine(y); } p = bm->GetScanLine(rect.Bottom - 1) + rect.Left; memset(p, 0, rect.Right - rect.Left); bm->PutScanLine(rect.Bottom - 1); bm->StopScanLine(); } //---------------------------------------------------------------------------- void __fastcall TMainImageForm::MosaicDraw24(TTexpiaBitmap *bm, int k, int m, int w, int h, RGBQUAD rgb) { BYTE *p; DWORD color = RGB(rgb.rgbRed, rgb.rgbGreen, rgb.rgbBlue); TRect rect; int y, l; int mk = k*w; int mm = m*h; if (mk==0) mk = 1; if (mm==0) mm = 1; rect = Rect(mk-1, mm-1, (k+1)*w, (m+1)*h); bm->StartScanLine(); p = bm->GetScanLine(rect.Top) + 3 * rect.Left; memset24(p, 0, rect.Right-rect.Left); bm->PutScanLine(rect.Top); for (y=rect.Top+1; yGetScanLine(y) + 3*rect.Left; SetPixel24(p, 0); p += 3; l = rect.Right-rect.Left-2; memset24(p, color, l); p += 3*l; SetPixel24(p, 0); bm->PutScanLine(y); } p = bm->GetScanLine(rect.Bottom - 1) + 3 * rect.Left; memset24(p, 0, rect.Right - rect.Left); bm->PutScanLine(rect.Bottom - 1); bm->StopScanLine(); } //--------------------------------------------------------------------------- // Public Function //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitForm(TPCanvasInfor &ci, WORD bpp) { // MainImageForm->iMainImage->OnPaintLocate = PaintRectangleLocate;/////////////////by jeegeo PALETTEENTRY peEntry[256]; RGBQUAD rgb[256]; if (Palette==NULL || WorkArea==NULL) return EC_MEMORY_LACK; if (!Palette->LoadFromFile((DirectoryColor+"\\Textile.fcr").c_str())) { GetSystemPaletteEntries(Canvas->Handle, 0, 256, peEntry); Palette->SetNormal(0, 0, 0, 0); Palette->SetNormal(1, 255, 255, 255); Palette->SetNormal(2, 0, 0, 0); for (int i=3; i<255; i++) { Palette->SetNormal(i, peEntry[i].peRed, peEntry[i].peGreen, peEntry[i].peBlue); } Palette->SetNormal(255, 255, 255, 255); } if (!ResizePattern(ci, bpp)) return EC_MEMORY_LACK; if (bpp==8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->Bitmap->PutColors(0, 256, rgb); FileName = Format("Noname%d.tex", OPENARRAY(TVarRec, (Number+1))); MaskPixel = 0x0F; PaletteForm->SpeedButtonProtect->Enabled = true; } else { FileName = Format("Noname%d.tfc", OPENARRAY(TVarRec, (Number+1))); MaskPixel = 0x80; PaletteForm->SpeedButtonProtect->Enabled = false; } iMainImage->Bitmap->FillRect(Rect(0, 0, CanvasInfor.Width, CanvasInfor.Height), PaletteForm->DIB256Palette->GetBGCOLORREF(iMainImage->Bitmap->BitsPerPixel)); if (bpp == 8) { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); } else { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); } if (WindowState == wsNormal) { Top = 0; Left = 0; ClientWidth = MainForm->ClientWidth-267; ClientHeight = MainForm->ClientHeight-MainForm->StatusBar->Height -GetSystemMetrics(SM_CYSMCAPTION)-GetSystemMetrics(SM_CYMENU)+3; } SetCaption(); iMainImage->SetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); return EC_NONE; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::InitFormFile(AnsiString dn, AnsiString fn, TGraphicFileFormat ExtIndex, WORD bpp) { int pw, ph, sw, sh, x, y; RGBQUAD rgb[256]; TTexpiaBitmap *tb = NULL; TPCanvasInfor ci; Byte c[256], *bp, *sp, *dp; TEXPIAFILEHEADER tpfh; TPException ec = EC_NONE; bool layer = false; HANDLE hFile = INVALID_HANDLE_VALUE; if (Palette==NULL || WorkArea==NULL) return false; sw = MainForm->ClientWidth-267; sh = MainForm->ClientHeight-MainForm->StatusBar->Height -GetSystemMetrics(SM_CYSMCAPTION)-GetSystemMetrics(SM_CYMENU)+3; if ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } #ifndef ACADEMY #ifndef N_3D if (ExtIndex==gffT3D) { if(MainForm->T3D_Item){ if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadFromTexpiaFile(hFile, Palette, tpfh, tb))!=EC_NONE) goto fail; ci = tpfh.CanvasInfor; if (!ResizePattern(ci, 24)) { ec = EC_MEMORY_LACK; goto fail; } MaskPixel = 0x80; if (!iMainImage->Bitmap->Copy(tb, SRCCOPY)) { ec = EC_RESOURCE_LACK; goto fail; } iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); pw = iMainImage->Bitmap->Width+PanelVert->Width; ph = iMainImage->Bitmap->Height+PanelHorz->Height; if (sbRuler->Down) { pw += Ruler->Thick; ph += Ruler->Thick; } if (pwSetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); if (Data3D) delete Data3D; if ((Data3D = new TData3D)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = MainMenuForm->LoadFrom3DFile(hFile, tpfh, tb))!=EC_NONE) goto fail; CloseHandle(hFile); if (iMainImage->Mask) MaskArea = true; } } else { #endif #endif if ((ec = LoadFromFile(fn, ExtIndex, tb, Palette, ci, layer, bpp))!=EC_NONE) goto fail; if (!ResizePattern(ci, bpp, layer)) { ec = EC_MEMORY_LACK; goto fail; } if (layer == false) { if (bpp==8) { if (tb->BitsPerPixel==8) { #ifndef ACADEMY if (ExtIndex == gffTEX || ExtIndex == gffTFC || ExtIndex == gffWEA || ExtIndex == gffWAV || ExtIndex == gffKNT) { #else if (ExtIndex == gffTEX) { #endif Palette->ToRGBQUAD(rgb, 256); iMainImage->Bitmap->PutColors(0, 256, rgb); if (!iMainImage->Bitmap->Copy(tb, SRCCOPY)) { ec = EC_RESOURCE_LACK; goto fail; } } else { goto next; } } else { tb->ColorResolution(8, CRF_OPTIMIZEDPALETTE, NULL, 250); tb->GetColors(0, 256, rgb); Palette->SetNormal(0, 0, 0, 0); for (x=0; x<250; x++) { Palette->SetNormal(x+2, rgb[x].rgbRed, rgb[x].rgbGreen, rgb[x].rgbBlue); } Palette->SetNormal(255, 255, 255, 255); next: Palette->ToRGBQUAD(rgb, 256); iMainImage->Bitmap->PutColors(0, 256, rgb); memset(c, 0, 256); if (!tb->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!iMainImage->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { sp = tb->GetScanLine(y); dp = iMainImage->Bitmap->GetScanLine(y); for (x=0; xWidth; x++, sp++, dp++) { *dp = *sp+2; c[*dp] = 1; } iMainImage->Bitmap->PutScanLine(y); } tb->StopScanLine(); iMainImage->Bitmap->StopScanLine(); for (x=251; x>=1; x--) { if (c[x]==1) { Palette->UseColor = x; break; } } } } else { if (!iMainImage->Bitmap->Copy(tb, SRCCOPY)) { ec = EC_RESOURCE_LACK; goto fail; } } } else { // LayerÀϰæ¿ì¿¡ iMainImage->LoadFromLayerFile¿¡¼­ ¸ðµç°Å ´ÙÇØ¿ä.... } if (bpp == 8) { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(8), rgb); MaskPixel = 0x0F; } else { iMainImage->SetBackgroundColor(PaletteForm->DIB256Palette->GetBGCOLORREF(24)); MaskPixel = 0x80; } pw = iMainImage->Bitmap->Width+PanelVert->Width; ph = iMainImage->Bitmap->Height+PanelHorz->Height; if (sbRuler->Down) { pw += Ruler->Thick; ph += Ruler->Thick; } if (pwSetPosition(0, 0); MainForm->UpdateMenuItems(NULL); PenManagerForm->SetColor(Palette); PenChange(); PaletteForm->DIB256Palette->ChoiceIndex = 2; #ifndef ACADEMY #ifndef N_3D } #endif #endif delete tb; return EC_NONE; fail: if (tb) { #ifndef ACADEMY #ifndef N_3D if(MainForm->T3D_Item){ if (ExtIndex==gffT3D) { if (hFile!=INVALID_HANDLE_VALUE) { ::doDestroy(Data3D); CloseHandle(hFile); } } } #endif #endif delete tb; } return ec; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ResizeCanvas(short dpi, int w, int h) { RGNXFORM XForm; HRGN rgn; double rx, ry; rx = (double)w/iMainImage->Bitmap->Width; ry = (double)h/iMainImage->Bitmap->Height; // iMainImage->Bitmap->ResizeStretch(w, h); iMainImage->ResizeStretchLayer(w, h); if (iMainImage->Mask) iMainImage->Mask->ResizeStretch(w, h); AllocLineMem(h); CanvasInfor.DotsPerInch = dpi; CanvasInfor.SetExtFileOption(); CanvasInfor.SetSize(cstFree, w, h); BITMAPHANDLE *bh = iMainImage->Bitmap->Handle; if (L_BitmapHasRgn(bh)) { XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; L_GetBitmapRgnHandle(bh, &XForm, &rgn); WorkArea->SetMask(rgn); DeleteObject(rgn); } #ifndef ACADEMY #ifndef N_3D if(MainForm->T3D_Item) { if (Data3D) { int btn = MessageDlg(IDS_MESSAGE_NEWMODEL, mtInformation, TMsgDlgButtons()<Source->Create(iMainImage->Bitmap->Width, iMainImage->Bitmap->Height, 24)) { iMainImage->Bitmap->ConvertColorSpace(csHLS); Data3D->Source->Copy(iMainImage->Bitmap, SRCCOPY); iMainImage->Bitmap->ConvertColorSpace(csRGB); } else { EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return; } } else { Data3D->Source->ResizeStretch(iMainImage->Bitmap->Width, iMainImage->Bitmap->Height); } Data3D->Resize(rx, ry); Data3D->waStart.x = Data3D->waStart.x*rx+0.5; Data3D->waStart.y = Data3D->waStart.y*ry+0.5; Data3D->waSize.x = Data3D->waSize.x*rx+0.5; Data3D->waSize.y = Data3D->waSize.y*ry+0.5; } } #endif #endif UpdateImage(); ::RepaintColor(); ReviewStatusBar(); Modify = false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::EnlargeCanvas(int w, int h) { BITMAPHANDLE *bh = iMainImage->Bitmap->Handle; RGNXFORM XForm; HRGN rgn; #ifndef ACADEMY #ifndef N_3D if(MainForm->T3D_Item){ if (Data3D) { POINT max = Data3D->MaxGridPoint(); if (w < max.x || h < max.y) { MessageDlg(IDS_MESSAGE_INPUTVALUE, mtInformation, TMsgDlgButtons()<DIB256Palette->GetBGCOLORREF(iMainImage->Bitmap->BitsPerPixel); CanvasInfor.SetSize(cstFree, w, h); // iMainImage->Bitmap->Resize(w, h, bc); iMainImage->ResizeLayer(w, h, bc); if (L_BitmapHasRgn(bh)) { XForm.uViewPerspective = TOP_LEFT; XForm.nXScalarNum = 1; XForm.nXScalarDen = 1; XForm.nYScalarNum = 1; XForm.nYScalarDen = 1; XForm.nXOffset = 0; XForm.nYOffset = 0; L_GetBitmapRgnHandle(bh, &XForm, &rgn); WorkArea->SetMask(rgn); DeleteObject(rgn); } #ifndef ACADEMY #ifndef N_3D if(MainForm->T3D_Item) { if (Data3D) { if (iMainImage->Mask) { iMainImage->Mask->Resize(w, h, clWhite); } int btn = MessageDlg(IDS_MESSAGE_NEWMODEL, mtInformation, TMsgDlgButtons()<Source->Create(iMainImage->Bitmap->Width, iMainImage->Bitmap->Height, 24)) { iMainImage->Bitmap->ConvertColorSpace(csHLS); Data3D->Source->Copy(iMainImage->Bitmap, SRCCOPY); iMainImage->Bitmap->ConvertColorSpace(csRGB); } else {EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return;} } else { Data3D->Source->Resize(iMainImage->Bitmap->Width, iMainImage->Bitmap->Height, bc); } } else { if (iMainImage->Mask) { iMainImage->Mask->Resize(w, h, 0); } } } #endif #else if (iMainImage->Mask) { iMainImage->Mask->Resize(w, h, 0); } #endif UpdateImage(); ::RepaintColor(); AllocLineMem(h); ReviewStatusBar(); Modify = false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::ResizePattern(TPCanvasInfor &pi, int bpp, bool layer) { RGBQUAD rgb[256]; if (pi.SizeType!=cstFree) { pi.Width = pi.GetWidth(); pi.Height = pi.GetHeight(); } CanvasInfor = pi; CanvasInfor.SetExtFileOption(); Ruler->DPI = CanvasInfor.DotsPerInch; if (layer == false) { if (!iMainImage->Bitmap->Create(CanvasInfor.Width, CanvasInfor.Height, bpp)) goto fail; } if (!AllocLineMem(CanvasInfor.Height)) goto fail; ReviewStatusBar(); return true; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::InitMerge(AnsiString FullFileName, TGraphicFileFormat Index) { int i, x, y, bg, UseColor; TPCanvasInfor ci; TRect r; RGBQUAD rgb[256]; AnsiString FileName; Byte *pp, *mp, mm; bool undoSw = false; TPalette *TempPalette = NULL; COLORREF bgc, c; TPException ec = EC_NONE; r = Rect(0, 0, iMainImage->Bitmap->Width, iMainImage->Bitmap->Height); if ((undoSw = UndoSave(UK_ALL, r)) == false) goto fail; iMainImage->SubEnabled = true; if ((TempPalette = new TPalette)==NULL) { ec = EC_MEMORY_LACK; goto fail; } switch (FullViewForm->Super) { case sOff: if ((ec = LoadToSelectImage(FullFileName, Index, iMainImage->SubBitmap, TempPalette, ci))!=EC_NONE) goto fail; if (iMainImage->SubBitmap->Width > iMainImage->Bitmap->Width || iMainImage->SubBitmap->Height > iMainImage->Bitmap->Height) { ec = EC_BIG_SIZE; goto fail; } if (iMainImage->Bitmap->BitsPerPixel==8) { if (iMainImage->SubBitmap->BitsPerPixel!=8) { ec = EC_COLOR_OVERFLOW; goto fail; } bg = 0; if (!iMainImage->SubBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; ySubBitmap->Height; y++) { pp = iMainImage->SubBitmap->GetScanLine(y); for (x = 0; x < iMainImage->SubBitmap->Width; x++) { if (*(pp+x)==1) { bg = 1; goto next1; } } iMainImage->SubBitmap->PutScanLine(y); } next1: iMainImage->SubBitmap->StopScanLine(); if (Palette->UseColor+TempPalette->UseColor-2+bg>=252) { ec = EC_COLOR_OVERFLOW; goto fail; } UseColor = Palette->UseColor-1+bg; if (!iMainImage->SubBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; ySubBitmap->Height; y++) { pp = iMainImage->SubBitmap->GetScanLine(y); for (x=0; x < iMainImage->SubBitmap->Width; x++) { *(pp+x) += UseColor; } iMainImage->SubBitmap->PutScanLine(y); } iMainImage->SubBitmap->StopScanLine(); for (i=2-bg; i<=TempPalette->UseColor; i++) { Palette->ColorData[UseColor+i] = TempPalette->ColorData[i]; } Palette->UseColor = UseColor+TempPalette->UseColor; if (Palette->UseColor > 251) Palette->UseColor = 251; Palette->ToRGBQUAD(rgb, 256); iMainImage->SubBitmap->PutColors(0, 256, rgb); if (!iMainImage->SubMask->Create(iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } iMainImage->SubMask->FillRect(Rect(0, 0, iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height), PALETTEINDEX(0)); } else { if (iMainImage->SubBitmap->BitsPerPixel == 8) { iMainImage->SubBitmap->GetColors(0, 256, rgb); if (!iMainImage->SubMask->Create(iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } iMainImage->SubMask->FillRect(Rect(0, 0, iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height), PALETTEINDEX(0)); } else { if (!iMainImage->SubMask->Create(iMainImage->SubBitmap->Width, iMainImage->SubBitmap->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } } } break; case sOverlap: case sNormal: case sGauze: if ((TempBitmap = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = LoadToSelectImage(FullFileName, Index, TempBitmap, TempPalette, ci))!=EC_NONE) goto fail; if (TempBitmap->Width > iMainImage->Bitmap->Width || TempBitmap->Height > iMainImage->Bitmap->Height) { ec = EC_BIG_SIZE; goto fail; } if (iMainImage->Bitmap->BitsPerPixel==8) { if (TempBitmap->BitsPerPixel!=8) { ec = EC_COLOR_OVERFLOW; goto fail; } if (Palette->UseColor+TempPalette->UseColor-2>=252) { ec = EC_COLOR_OVERFLOW; goto fail; } if ((TempMask = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; goto fail; } UseColor = Palette->UseColor-1; if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { pp = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); for (x=0; xWidth; x++, pp++, mp++) { if (*pp < 2) { *pp = 0; *mp = 0xFF; } else { *pp += UseColor; *mp = 0; } } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); } TempBitmap->StopScanLine(); TempMask->StopScanLine(); for (i=2; i<=TempPalette->UseColor; i++) { Palette->ColorData[UseColor+i] = TempPalette->ColorData[i]; } Palette->UseColor = UseColor+TempPalette->UseColor; if (Palette->UseColor > 251) Palette->UseColor = 251; Palette->ToRGBQUAD(rgb, 256); TempBitmap->PutColors(0, 256, rgb); TempMask->PutColors(0, 256, rgb); if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } } else { if ((TempMask = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (TempBitmap->BitsPerPixel==8) { TempBitmap->GetColors(0, 256, rgb); if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=0; yHeight; y++) { pp = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); for (x = 0; x < TempBitmap->Width; x++, pp++, mp++) { if (*pp<2) { *pp = 0; *mp = 0xFF; } else *mp = 0; } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); } TempBitmap->StopScanLine(); TempMask->StopScanLine(); } else { bgc = TempPalette->Color[1]; if (!TempMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } if (!TempBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!TempMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y = 0; y < TempBitmap->Height; y++) { pp = TempBitmap->GetScanLine(y); mp = TempMask->GetScanLine(y); x=0; *mp = 0; mm = 0x80; while(1) { GetPixel24(pp, c); if (c==bgc) { SetPixel24(pp, 0); *mp |= mm; } x++; if (x >= TempBitmap->Width) break; pp+=3; if (mm==1) { mp++; *mp = 0; mm = 0x80; } else mm >>= 1; } TempBitmap->PutScanLine(y); TempMask->PutScanLine(y); } TempBitmap->StopScanLine(); TempMask->StopScanLine(); } if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } } break; } iMainImage->InitBackGround(0x01); PenManagerForm->SetColor(Palette); Center.x = iMainImage->SubBitmap->Width/2; Center.y = iMainImage->SubBitmap->Height/2; FullViewForm->stSuper->Enabled = false; MainMenuForm->Item = T_MERGE; MainMenuForm->SubItem = 0; ::RepaintColor(); delete TempPalette; return true; fail: if (TempPalette) { if (TempBitmap) { ::doDestroy(TempMask); delete TempBitmap; TempBitmap = NULL; } delete TempPalette; } ExitMerge(); if (undoSw == true) Undo->RemoveLast(); EXCEPTION_MESSAGE_OK(ec); return false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ExitMerge() { iMainImage->SubEnabled = false; iMainImage->SubVisible = false; FullViewForm->stSuper->Enabled = true; iMainImage->ExitBackGround(0x01); ::doDestroy(TempBitmap); ::doDestroy(TempMask); } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToFile(AnsiString dn, AnsiString fn, TGraphicFileFormat Index, TCompressMethod cm) { HANDLE hFile = INVALID_HANDLE_VALUE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256]; TTexpiaBitmap *tag = NULL, *tb = NULL; HDC dcSrc = NULL, dcTmp = NULL; TPException ec = EC_NONE; bool layer; DWORD dwWrite; #ifdef ACADEMY if (Index == gffTEX) { #else if (Index == gffTEX || Index == gffTFC) { #endif if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; goto fail; } tpfh.Version = TexVersion('P', 'T', 230); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = iMainImage->Bitmap->BitsPerPixel; tpfh.Compress = cm; if (WorkArea->Mask) { src = WorkArea->Range; tpfh.CanvasInfor.DotsPerInch = tpfh.CanvasInfor.DotsPerInch; tpfh.CanvasInfor.SetSize(cstFree, src.Right-src.Left, src.Bottom-src.Top); } else { src.Left = 0; src.Top = 0; src.Right = iMainImage->Bitmap->Width; src.Bottom = iMainImage->Bitmap->Height; } if (iMainImage->LayerList->Count > 1) { if ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (iMainImage->Bitmap->BitsPerPixel == 8) { iMainImage->Bitmap->GetColors(0, 256, rgb); if (!tb->Create(iMainImage->Bitmap->Width, iMainImage->Bitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } } else { if (!tb->Create(iMainImage->Bitmap->Width, iMainImage->Bitmap->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } } if ((dcTmp = tb->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; goto fail; } iMainImage->FullViewPaint(dcTmp, 1, 1); tb->DeleteDC(dcTmp); dcTmp = NULL; if ((tag = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } MakeTexpiaTag(tag, tb, src, 0); if (WorkArea && WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, tb, &WorkArea->Range)) { ec = EC_FILE_NOT_WRITE; goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, tb)) { ec = EC_FILE_NOT_WRITE; goto fail; } } layer = true; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; if (WorkArea && WorkArea->Mask) { if (!iMainImage->SaveToLayerFile(hFile, WorkArea->Range)) goto fail; } else { if (!iMainImage->SaveToLayerFile(hFile)) goto fail; } delete tb; } else { if ((tag = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } MakeTexpiaTag(tag, iMainImage->Bitmap, src, 0); if (WorkArea && WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, iMainImage->Bitmap, &WorkArea->Range)) { ec = EC_FILE_NOT_WRITE; goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, iMainImage->Bitmap)) { ec = EC_FILE_NOT_WRITE; goto fail; } } layer = false; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; } CloseHandle(hFile); delete tag; DirName = dn; FileName = fn; #ifndef ACADEMY } else if (Index == gffT3D) { if(MainForm->T3D_Item){ if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; goto fail; } // tpfh.Version = TexVersion('P', 'T', 230); //for fit size and point by kjs.... 230 --> 232 tpfh.Version = TexVersion('P', 'T', 232); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = 24; tpfh.Compress = cm; src.Left = 0; src.Top = 0; src.Right = iMainImage->Bitmap->Width; src.Bottom = iMainImage->Bitmap->Height; if ((tag = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = MainMenuForm->SaveTo3DFile(hFile, tpfh, tag, iMainImage->Bitmap)) != EC_NONE) goto fail; CloseHandle(hFile); delete tag; DirName = dn; FileName = fn; } #endif } else { if (WorkArea->Mask) { src = WorkArea->Range; } else { src.Left = 0; src.Top = 0; src.Right = iMainImage->Bitmap->Width; src.Bottom = iMainImage->Bitmap->Height; } if ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (!tb->Create(src.Right-src.Left, src.Bottom-src.Top, iMainImage->Bitmap->BitsPerPixel)) { ec = EC_MEMORY_LACK; goto fail; } if (tb->BitsPerPixel==8) { Palette->ToRGBQUAD(rgb, 256); tb->PutColors(0, 256, rgb); } if (!tb->CopyFromRect(iMainImage->Bitmap, src.Left, src.Top, SRCCOPY)) { ec = EC_MEMORY_LACK; goto fail; } switch (Index) { case gffBMP: if (!tb->SaveToFile(fn, FILE_BMP)) goto fail; break; case gffTIF: if (!tb->SaveToFile(fn, FILE_TIF)) goto fail; break; #ifndef ACADEMY case gffJPG: if ((ec = SaveToJPEG(tb, fn)) != EC_NONE) goto fail; break; case gffPCT: if (!tb->SaveToFile(fn, FILE_PCT)) goto fail; break; case gffPCX: if (!tb->SaveToFile(fn, FILE_PCX)) goto fail; break; case gffPNG: if (!tb->SaveToFile(fn, FILE_PNG)) goto fail; break; case gffPSD: if (!tb->SaveToFile(fn, FILE_PSD)) goto fail; break; case gffRAS: if (!tb->SaveToFile(fn, FILE_RAS)) goto fail; break; case gffTGA: if (!tb->SaveToFile(fn, FILE_TGA)) goto fail; break; case gffEPS: if (!tb->SaveToFile(fn, FILE_EPS)) goto fail; break; #endif default: goto fail; } DirName = ""; if (iMainImage->Bitmap->BitsPerPixel==8) { StrMove(StrPos(fn.c_str(), "."), ".tex", 4); } else { StrMove(StrPos(fn.c_str(), "."), ".tfc", 4); } FileName = fn; delete tb; } SetCaption(); return EC_NONE; fail: if (tb) { if (dcTmp) tb->DeleteDC(dcTmp); delete tb; } if (dcSrc) iMainImage->Bitmap->DeleteDC(dcSrc); if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); if (ec == EC_NONE) ec = EC_FILE_NOT_WRITE; return ec; } //--------------------------------------------------------------------------- TPException __fastcall TMainImageForm::SaveToJPEG(TTexpiaBitmap *tb, AnsiString fn) { TDialogForm *Form = NULL; int nFormat, QFactor, ec = EC_NONE; Form = new TDialogForm(this); Form->Caption = "JPEG Option"; Form->PanelJPEG->BringToFront(); if (Form->ShowModal() == mrOk) { switch (Form->cbComKind->ItemIndex) { case 0: nFormat = FILE_JFIF; QFactor = 2; break; case 1: nFormat = FILE_LEAD2JFIF; QFactor = Form->spQFactor->Value; break; case 2: nFormat = FILE_LEAD1JFIF; QFactor = Form->spQFactor->Value; } if(!tb->SaveToFile(fn, nFormat, QFactor)) ec = EC_FILE_NOT_WRITE;; } return ec; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AutoSaveToFile(AnsiString dn, AnsiString fn, TGraphicFileFormat Index, TCompressMethod cm) { HANDLE hFile = INVALID_HANDLE_VALUE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256]; TTexpiaBitmap *tag = NULL, *tb = NULL; HDC dcTmp = NULL; TPException ec = EC_NONE; bool layer; DWORD dwWrite; #ifdef ACADEMY if (Index == gffTEX) { #else if (Index == gffTEX || Index == gffTFC) { #endif if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; goto fail; } tpfh.Version = TexVersion('P', 'T', 230); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = iMainImage->Bitmap->BitsPerPixel; tpfh.Compress = cm; src.Left = 0; src.Top = 0; src.Right = iMainImage->Bitmap->Width; src.Bottom = iMainImage->Bitmap->Height; if (iMainImage->LayerList->Count > 1) { if ((tb = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (iMainImage->Bitmap->BitsPerPixel == 8) { iMainImage->Bitmap->GetColors(0, 256, rgb); if (!tb->Create(iMainImage->Bitmap->Width, iMainImage->Bitmap->Height, 8, rgb)) { ec = EC_MEMORY_LACK; goto fail; } } else { if (!tb->Create(iMainImage->Bitmap->Width, iMainImage->Bitmap->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } } if ((dcTmp = tb->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; goto fail; } iMainImage->FullViewPaint(dcTmp, 1, 1); tb->DeleteDC(dcTmp); dcTmp = NULL; if ((tag = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } MakeTexpiaTag(tag, tb, src, 0); if (WorkArea && WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, tb, &WorkArea->Range)) { ec = EC_FILE_NOT_WRITE; goto fail; } } else { if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, tb)) { ec = EC_FILE_NOT_WRITE; goto fail; } } layer = true; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; if (!iMainImage->SaveToLayerFile(hFile)) goto fail; delete tb; } else { if ((tag = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } MakeTexpiaTag(tag, iMainImage->Bitmap, src, 0); if (!SaveToTexpiaFile(hFile, Palette, tpfh, tag, iMainImage->Bitmap)) { ec = EC_FILE_NOT_WRITE; goto fail; } layer = false; if (!WriteFile(hFile, &layer, sizeof(bool), &dwWrite, NULL)) goto fail; } CloseHandle(hFile); delete tag; DirName = dn; FileName = fn; #ifndef ACADEMY } else if (Index == gffT3D) { if(MainForm->T3D_Item){ if ((hFile = CreateFile(FullPathName(dn, fn).c_str(), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_FILE_NOT_CREATE; goto fail; } // tpfh.Version = TexVersion('P', 'T', 230); // for fit size and point by kjs.... 230 --> 232 tpfh.Version = TexVersion('P', 'T', 232); tpfh.CanvasInfor = CanvasInfor; tpfh.BitsPerPixel = 24; tpfh.Compress = cm; src.Left = 0; src.Top = 0; src.Right = iMainImage->Bitmap->Width; src.Bottom = iMainImage->Bitmap->Height; if ((tag = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((ec = MainMenuForm->SaveTo3DFile(hFile, tpfh, tag, iMainImage->Bitmap))!=EC_NONE) goto fail; CloseHandle(hFile); delete tag; DirName = dn; FileName = fn; } #endif } SetCaption(); return; fail: if (tb) { if (dcTmp) tb->DeleteDC(dcTmp); delete tb; } if (tag) delete tag; if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile); EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SubBitmapPosition(int X, int Y, bool paint) { TRect dst; RECT r; POINT p = Point(X - Center.x, Y - Center.y); paintrect = iMainImage->SubRange; if (p.x < 0) p.x = 0; else if (p.x>iMainImage->Bitmap->Width-iMainImage->SubBitmap->Width) p.x = iMainImage->Bitmap->Width-iMainImage->SubBitmap->Width; iMainImage->SubRange.left = p.x; if (p.y<0) p.y = 0; else if (p.y>iMainImage->Bitmap->Height-iMainImage->SubBitmap->Height) p.y = iMainImage->Bitmap->Height-iMainImage->SubBitmap->Height; iMainImage->SubRange.top = p.y; iMainImage->SubRange.right = p.x + iMainImage->SubBitmap->Width; iMainImage->SubRange.bottom = p.y + iMainImage->SubBitmap->Height; iMainImage->SubVisible = true; if (TempBitmap) IsMerge(p); if (paint) { r.left = paintrect.left < iMainImage->SubRange.left ? paintrect.left : iMainImage->SubRange.left; r.top = paintrect.top < iMainImage->SubRange.top ? paintrect.top : iMainImage->SubRange.top; r.right = paintrect.right > iMainImage->SubRange.right ? paintrect.right : iMainImage->SubRange.right; r.bottom = paintrect.bottom > iMainImage->SubRange.bottom ? paintrect.bottom : iMainImage->SubRange.bottom; iMainImage->RectPaint(r); } } //--------------------------------------------------------------------------- AnsiString __fastcall TMainImageForm::UnitName(TUnit unit) { if (unit==uDot) return "Dot"; else if (unit==uInch) return "Inch"; else if (unit==uCm) return "Cm"; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::UnitChange(TUnit unit) { CurrentUnit = unit; Ruler->AUnit = CurrentUnit; if (CurrentUnit==uDot) sbUnit->Caption = AnsiString(IDS_UNIT) + " : Dot"; else if (CurrentUnit==uInch) sbUnit->Caption = AnsiString(IDS_UNIT) + " : Inch"; else if (CurrentUnit==uCm) sbUnit->Caption = AnsiString(IDS_UNIT) + " : Cm"; FullViewForm->UnitChange(); MainMenuForm->UnitChange(); ReviewStatusBar(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChange(int zi, int zo, POINT *ptScreen) { POINT ptClient; AnsiString sbZoom; if (zi!=iMainImage->ZoomIn || zo!=iMainImage->ZoomOut) { iMainImageChange(); if (ptScreen) { ptClient = iMainImage->ScreenToClient(*ptScreen); iMainImage->SetZoom(zi, zo, &ptClient); } else { iMainImage->SetZoom(zi, zo); } Ruler->Zoom = (double)zi/zo; FullViewForm->SetZoom(); } ShowZoomText(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ShowZoomText() { AnsiString sbZoom; switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: sbZoom = "Zoom : 1"; break; case 2: sbZoom = "Zoom : 1/2"; break; case 4: sbZoom = "Zoom : 1/4"; break; case 8: sbZoom = "Zoom : 1/8"; break; case 16: sbZoom = "Zoom : 1/16"; break; } break; case 2: sbZoom = "Zoom : 2"; break; case 4: sbZoom = "Zoom : 4"; break; case 8: sbZoom = "Zoom : 8"; break; case 16: sbZoom = "Zoom : 16"; break; } MainForm->StatusBar->Panels->Items[StatusBarZoom]->Text = sbZoom; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChangeIn(POINT ptScreen) { switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: ZoomChange(2, 1, &ptScreen); break; case 2: ZoomChange(1, 1, &ptScreen); break; case 4: ZoomChange(1, 2, &ptScreen); break; case 8: ZoomChange(1, 4, &ptScreen); break; case 16: ZoomChange(1, 8, &ptScreen); break; } break; case 2: ZoomChange(4, 1, &ptScreen); break; case 4: ZoomChange(8, 1, &ptScreen); break; case 8: ZoomChange(16, 1, &ptScreen); break; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ZoomChangeOut(POINT ptScreen) { switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: ZoomChange(1, 2, &ptScreen); break; case 2: ZoomChange(1, 4, &ptScreen); break; case 4: ZoomChange(1, 8, &ptScreen); break; case 8: ZoomChange(1, 16, &ptScreen); break; } break; case 2: ZoomChange(1, 1, &ptScreen); break; case 4: ZoomChange(2, 1, &ptScreen); break; case 8: ZoomChange(4, 1, &ptScreen); break; case 16: ZoomChange(8, 1, &ptScreen); break; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::set_hline(int x, int y, int len, COLORREF c) { if (x >= iMainImage->Bitmap->Width || y < 0 || y >= iMainImage->Bitmap->Height) return; if (x < 0) { len += x; x = 0; if (len <= 0) return; } if (x + len > iMainImage->Bitmap->Width) len = iMainImage->Bitmap->Width-x; if (FOnSetHLine) FOnSetHLine(x, y, len, c); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLine8ColorNo(int x, int y, int len, COLORREF c) { Byte *bp, *mp, *lp, *gp; bp = iMainImage->Bitmap->GetScanLine(y); if (iMainImage->LayerMask) { lp = iMainImage->LayerMask->GetScanLine(y); if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y); if (bProtect) { gp = iMainImage->BackGround->GetScanLine(y); for (int i = 0; i < len; i++) { if ((Palette->ColorData[gp[x + i]]->Protect == 0) && (mp[x + i] == 0)) { bp[x + i] = c; lp[x + i] = 0; } } } else { for (int i = 0; i < len; i++) { if (mp[x + i] == 0) { bp[x + i] = c; lp[x + i] = 0; } } } } else { if (bProtect) { gp = iMainImage->BackGround->GetScanLine(y); for (int i = 0; i < len; i++) { if (Palette->ColorData[gp[x + i]]->Protect == 0) { bp[x + i] = c; lp[x + i] = 0; } } } else { memset(bp+x, c, len); memset(lp+x, 0, len); } } iMainImage->LayerMask->PutScanLine(y); } else { if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y); if (bProtect) { for (int i = 0; i < len; i++) { if ((Palette->ColorData[bp[x + i]]->Protect == 0) && (mp[x + i] == 0)) { bp[x + i] = c; } } } else { for (int i = 0; i < len; i++) { if (mp[x + i] == 0) bp[x + i] = c; } } } else { if (bProtect) { for (int i = 0; i < len; i++) { if (Palette->ColorData[bp[x + i]]->Protect == 0) { bp[x + i] = c; } } } else { memset(bp+x, c, len); } } } iMainImage->Bitmap->PutScanLine(y); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLine8ColorYes(int x, int y, int len, COLORREF c) { Byte *bp, *mp, *lp, *gp; bp = iMainImage->Bitmap->GetScanLine(y); if (iMainImage->LayerMask) { lp = iMainImage->LayerMask->GetScanLine(y); gp = iMainImage->BackGround->GetScanLine(y); if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y); if (bProtect) { for (int i = 0; i < len; i++) { if ((Palette->ColorData[gp[x + i]]->Protect == 0) && (mp[x + i] == 0) && (PenManagerForm->Selector->Number[gp[x + i]] != 255)) { bp[x + i] = c; lp[x + i] = 0; } } } else { for (int i = 0; i < len; i++) { if ((mp[x + i] == 0) && (PenManagerForm->Selector->Number[gp[x + i]] != 255)) { bp[x + i] = c; lp[x + i] = 0; } } } } else { if (bProtect) { for (int i = 0; i < len; i++) { if ((Palette->ColorData[gp[x + i]]->Protect == 0) && (PenManagerForm->Selector->Number[gp[x + i]] != 255)) { bp[x + i] = c; lp[x + i] = 0; } } } else { for (int i = 0; i < len; i++) { if (PenManagerForm->Selector->Number[gp[x + i]] != 255) { bp[x + i] = c; lp[x + i] = 0; } } } } iMainImage->LayerMask->PutScanLine(y); } else { if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y); if (bProtect) { for (int i = 0; i < len; i++) { if ((Palette->ColorData[bp[x + i]]->Protect == 0) && (mp[x + i] == 0) && (PenManagerForm->Selector->Number[bp[x + i]] != 255)) { bp[x + i] = c; } } } else { for (int i = 0; i < len; i++) { if ((mp[x + i] == 0) && (PenManagerForm->Selector->Number[bp[x + i]] != 255)) { bp[x + i] = c; } } } } else { if (bProtect) { for (int i = 0; i < len; i++) { if ((Palette->ColorData[bp[x + i]]->Protect == 0) && (PenManagerForm->Selector->Number[bp[x + i]] != 255)) { bp[x + i] = c; } } } else { for (int i = 0; i < len; i++) { if (PenManagerForm->Selector->Number[bp[x + i]] != 255) { bp[x + i] = c; } } } } } iMainImage->Bitmap->PutScanLine(y); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLine24(int x, int y, int len, COLORREF c) { Byte *bp, *mp, *lp; bp = iMainImage->Bitmap->GetScanLine(y); if (iMainImage->LayerMask) { lp = iMainImage->LayerMask->GetScanLine(y); if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y); for (int i = x; i < x + len; i++, bp += 3) { if ((mp[i >> 3] & (0x80 >> (i & 7))) == 0) { memset24(bp + 3 * x, c, 1); *(lp + (i >> 3)) &= ~(0x80 >> (i & 7)); } } } else { for (int i = x; i < x + len; i++, bp += 3) { memset24(bp+3*x, c, 1); *(lp + (i >> 3)) &= ~(0x80 >> (i & 7)); } } iMainImage->LayerMask->PutScanLine(y); } else { if (bMaskArea) { mp = iMainImage->Mask->GetScanLine(y); for (int i = x; i < x + len; i++, bp += 3) { if ((mp[i >> 3] & (0x80 >> (i & 7))) == 0) { memset24(bp + 3 * x, c, 1); } } } else { for (int i = x; i < x + len; i++, bp += 3) { memset24(bp+3*x, c, 1); } } } iMainImage->Bitmap->PutScanLine(y); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLineMask8(int x, int y, int len, COLORREF c) { Byte *bp; bp = iMainImage->Mask->GetScanLine(y); memset(bp + x, MaskPixel, len); iMainImage->Mask->PutScanLine(y); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLineMask24(int x, int y, int len, COLORREF c) { Byte *bp; bp = iMainImage->Mask->GetScanLine(y); for (int i = x; i < x + len; i++) { bp[i >> 3] |= MaskPixel >> (i & 7); } iMainImage->Mask->PutScanLine(y); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::SetHLineMaskDelete24(int x, int y, int len, COLORREF c) { Byte *bp; bp = iMainImage->Mask->GetScanLine(y); for (int i = x; i < x + len; i++) { bp[i >> 3] &= ~(0x80 >> (i & 7)); } iMainImage->Mask->PutScanLine(y); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::dotted_pen(int x, int y, int cx, int cy, COLORREF c) { int i, PenType, ls, rs, len; double r, dx; PenType = PenManagerForm->Pen->Shape; len = PenManagerForm->Pen->Thick; r = len / 2.0; ls = (int) r; rs = len - ls; if (PenType) { if (cy > y) y = y - ls; if (cx < x) x = x - ls; for (i = y; i < y + len; i++) set_hline(x, i, len, c); } else { for (i = -ls; i < rs; i++) { dx = sqrt(r * r - i * i); set_hline(x - dx, y + i, 2 * dx, c); } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::line_pen(int sx, int sy, int ex, int ey, COLORREF c, RECT *rect) { int PenType, dia, ls, rs, w, h, sw, y, x, r, yyy; double d, r1, r2, xx, yy; TLineData ld; PenType = PenManagerForm->Pen->Shape; dia = PenManagerForm->Pen->Thick; //lhskys draw ¿¡¼­ ÇÑÁ¡µÚ·Î ÇÒ¶§ Pen size°ªÀ» ÀÌ¿ë ±×¸®±â À§ÇØ... ls = dia>>1; rs = dia-ls; w = iMainImage->Bitmap->Width; h = iMainImage->Bitmap->Height; for (y=0; yh) ld.sy = h; if (ld.ey<0) ld.ey = 0; else if (ld.ey>h) ld.ey = h; r = PenType ? (ld.sx=0 && y=0 && y=0 && y=0 && y*(mex + y)) *(mex + y) = x; } } ld.sy -= ls; ld.ey += rs; if (!(iMainImage->Bitmap->StartScanLine())) goto fail; if (iMainImage->LayerMask) { if (!(iMainImage->LayerMask->StartScanLine())) goto fail; if (bProtect || PenManagerForm->acolor == 2) if (!(iMainImage->BackGround->StartScanLine())) goto fail; } if (iMainImage->Mask) { if (!(iMainImage->Mask->StartScanLine())) goto fail; } for (y=ld.sy; y<=ld.ey; y++) { if (*(mex + y)>=0 && *(msx + y)LayerMask) { iMainImage->LayerMask->StopScanLine(); if (bProtect || PenManagerForm->acolor == 2) iMainImage->BackGround->StopScanLine(); } if (iMainImage->Mask) iMainImage->Mask->StopScanLine(); iMainImage->Bitmap->StopScanLine(); if (rect) { rect->left = min(sx, ex) - ls; rect->top = min(sy, ey) - ls; rect->right = max(sx, ex) + rs; rect->bottom = max(sy, ey) + rs; } return; fail: if (iMainImage->Mask) iMainImage->Mask->StopScanLine(); if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); if (bProtect || PenManagerForm->acolor == 2) iMainImage->BackGround->StopScanLine(); iMainImage->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageChange() { FullViewForm->iMainImageChange(); MainMenuForm->iMainImageChange(this); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::WorkAreaChange() { MainForm->UpdateMenuItems(NULL); PenManagerForm->WorkAreaChange(); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::WorkAreaReset(bool bUndo) { MainImageForm->WorkArea->Reset(bUndo); MainForm->UpdateMenuItems(NULL); PenManagerForm->WorkAreaChange(); } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWholeColor(TChoiceColor *ChoiceColor) { int x, y; Byte *bp, *lp; if (!iMainImage->Bitmap->StartScanLine()) return false; if (iMainImage->LayerMask) { if (!iMainImage->LayerMask->StartScanLine()) return false; for (y=0; yBitmap->Height; y++) { bp = iMainImage->Bitmap->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x=0; xBitmap->Width; x++) { if (lp[x] == 0) ChoiceColor->Add(Palette, *(bp+x)); } } iMainImage->LayerMask->StopScanLine(); } else { for (y=0; yBitmap->Height; y++) { bp = iMainImage->Bitmap->GetScanLine(y); for (x=0; xBitmap->Width; x++) { ChoiceColor->Add(Palette, *(bp+x)); } } } iMainImage->Bitmap->StopScanLine(); return true; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWorkAreaColor(TChoiceColor *ChoiceColor) { Byte *mp, mm, *bp, *lp; int x, y; if (!WorkArea->Mask->StartScanLine()) goto fail; if (!iMainImage->Bitmap->StartScanLine()) goto fail; if (iMainImage->LayerMask) { if (!iMainImage->LayerMask->StartScanLine()) goto fail; if (iMainImage->Bitmap->BitsPerPixel==8) { for (y=WorkArea->Range.top; yRange.bottom; y++) { bp = iMainImage->Bitmap->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); for (x=WorkArea->Range.left; xRange.right; x++, mp++) { if (*mp && (lp[x] == 0)) { ChoiceColor->Add(Palette, *(bp+x)); } } } } else { for (y=WorkArea->Range.top; yRange.bottom; y++) { mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); mm = 0x80; bp = iMainImage->Bitmap->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x=WorkArea->Range.left; xRange.right; x++) { if (*mp&mm) { if ((*(lp + (x >> 3)) & (0x80 >> (x & 7))) == 0) ChoiceColor->Add(Palette, *(bp+x)); } if (mm==1) { mp++; mm = 0x80; } else mm >>= 1; } } } iMainImage->LayerMask->StopScanLine(); } else { if (iMainImage->Bitmap->BitsPerPixel==8) { for (y=WorkArea->Range.top; yRange.bottom; y++) { bp = iMainImage->Bitmap->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); for (x=WorkArea->Range.left; xRange.right; x++, mp++) { if (*mp) { ChoiceColor->Add(Palette, *(bp+x)); } } } } else { for (y=WorkArea->Range.top; yRange.bottom; y++) { mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); mm = 0x80; bp = iMainImage->Bitmap->GetScanLine(y); for (x=WorkArea->Range.left; xRange.right; x++) { if (*mp&mm) { ChoiceColor->Add(Palette, *(bp+x)); } if (mm==1) { mp++; mm = 0x80; } else mm >>= 1; } } } } iMainImage->Bitmap->StopScanLine(); WorkArea->Mask->StopScanLine(); return true; fail: if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); iMainImage->Bitmap->StopScanLine(); WorkArea->Mask->StopScanLine(); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWholeBackGroundColor(TChoiceColor *ChoiceColor) { int x, y; Byte *bp; TTexpiaBitmap *Bitmap = NULL; if ((Bitmap = iMainImage->Composition())) { if (!Bitmap->StartScanLine()) return false; for (y = 0; y < Bitmap->Height; y++) { bp = Bitmap->GetScanLine(y); for (x = 0; x < Bitmap->Width; x++) { ChoiceColor->Add(Palette, *(bp+x)); } } Bitmap->StopScanLine(); ::doDestroy(Bitmap); } return true; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::SearchWorkAreaBackGroundColor(TChoiceColor *ChoiceColor) { Byte *mp, mm, *bp; int x, y; TTexpiaBitmap *Bitmap = NULL; if ((Bitmap = iMainImage->Composition()) == NULL) goto fail; if (!WorkArea->Mask->StartScanLine()) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (Bitmap->BitsPerPixel==8) { for (y=WorkArea->Range.top; yRange.bottom; y++) { bp = Bitmap->GetScanLine(y); mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); for (x=WorkArea->Range.left; xRange.right; x++, mp++) { if (*mp) ChoiceColor->Add(Palette, *(bp+x)); } } } else { for (y=WorkArea->Range.top; yRange.bottom; y++) { mp = WorkArea->Mask->GetScanLine(y-WorkArea->Range.top); mm = 0x80; bp = Bitmap->GetScanLine(y); for (x=WorkArea->Range.left; xRange.right; x++) { if (*mp&mm) ChoiceColor->Add(Palette, *(bp+x)); if (mm==1) { mp++; mm = 0x80; } else mm >>= 1; } } } Bitmap->StopScanLine(); WorkArea->Mask->StopScanLine(); ::doDestroy(Bitmap); return true; fail: if (Bitmap) { Bitmap->StopScanLine(); ::doDestroy(Bitmap); } WorkArea->Mask->StopScanLine(); return false; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::UpdateImage() { TPoint Size; Size.x = Panel->Width*iMainImage->ZoomOut/iMainImage->ZoomIn; Size.y = Panel->Height*iMainImage->ZoomOut/iMainImage->ZoomIn; if (iMainImage->Bitmap->WidthMax = 0; else sbHorz->Max = iMainImage->Bitmap->Width-Size.x; sbHorz->SmallChange = Size.x/4; if (iMainImage->Bitmap->HeightMax = 0; else sbVert->Max = iMainImage->Bitmap->Height-Size.y; sbVert->SmallChange = Size.y/4; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::EditCut() { TCursor cursor; TPoint Size; TTexpiaBitmap *tb, *tlb; int x, y; Byte *mp, mm, *pp, *lm; bool undoSw = false; COLORREF c; RECT r; TPException ec = EC_NONE; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; c = PaletteForm->DIB256Palette->GetBGCOLORREF(iMainImage->Bitmap->BitsPerPixel); if (WorkArea->Mask) { if ((undoSw = UndoSave(UK_ALL, WorkArea->Range))==false) goto fail; if ((ec = SaveToClipboard())!=EC_NONE) goto fail; Size.x = WorkArea->Range.right-WorkArea->Range.left; Size.y = WorkArea->Range.bottom-WorkArea->Range.top; tb = iMainImage->Bitmap; tlb = iMainImage->LayerMask; if (!tb->StartScanLine()) goto fail; if (tlb) { if (!tlb->StartScanLine()) goto fail; if (!WorkArea->Mask->StartScanLine()) goto fail; if (iMainImage->Bitmap->BitsPerPixel==8) { for (y=0; yGetScanLine(WorkArea->Range.top+y)+WorkArea->Range.left; lm = tlb->GetScanLine(WorkArea->Range.top+y)+WorkArea->Range.left; mp = WorkArea->Mask->GetScanLine(y); for (x=0; xPutScanLine(WorkArea->Range.top+y); tb->PutScanLine(WorkArea->Range.top+y); } } else { for (y=0; yGetScanLine(WorkArea->Range.top+y)+3*WorkArea->Range.left; lm = tlb->GetScanLine(WorkArea->Range.top+y); mp = WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>= 1; } tb->PutScanLine(WorkArea->Range.top+y); tlb->PutScanLine(WorkArea->Range.top+y); } } tlb->StopScanLine(); } else { if (!WorkArea->Mask->StartScanLine()) goto fail; if (iMainImage->Bitmap->BitsPerPixel==8) { for (y=0; yGetScanLine(WorkArea->Range.top+y)+WorkArea->Range.left; mp = WorkArea->Mask->GetScanLine(y); for (x=0; xPutScanLine(WorkArea->Range.top+y); } } else { for (y=0; yGetScanLine(WorkArea->Range.top+y)+3*WorkArea->Range.left; mp = WorkArea->Mask->GetScanLine(y); mm = 0x80; for (x=0; x>= 1; } tb->PutScanLine(WorkArea->Range.top+y); } } } tb->StopScanLine(); WorkArea->Mask->StopScanLine(); } else { r = Rect(0, 0, iMainImage->Bitmap->Width, iMainImage->Bitmap->Height); if ((undoSw = UndoSave(UK_ALL, r)) == false) goto fail; if ((ec = SaveToClipboard())!=EC_NONE) goto fail; iMainImage->Bitmap->FillRect(r, c); if (iMainImage->LayerMask) { if (iMainImage->Bitmap->BitsPerPixel == 8) iMainImage->LayerMask->FillRect(r, PALETTEINDEX(255)); else iMainImage->LayerMask->FillRect(r, clWhite); } } iMainImage->Repaint(); Screen->Cursor = cursor; return; fail: if (WorkArea->Mask) { WorkArea->Mask->StopScanLine(); tb->StopScanLine(); tlb->StopScanLine(); } if (undoSw == true) Undo->RemoveLast(); Screen->Cursor = cursor; if (ec == EC_NONE) ec = EC_MEMORY_LACK; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::EditCopy() { TCursor cursor; TPException ec; cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if ((ec = SaveToClipboard())!=EC_NONE) EXCEPTION_MESSAGE_OK(ec); Screen->Cursor = cursor; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::EditPaste() { RGBQUAD rgb[256]; int x, y; BITMAPHANDLE bh; HGLOBAL hMem = NULL; TClipboardInfo *cbi = NULL; HANDLE hBuffer = NULL; Byte *pBuffer = NULL, c; short color[256]; int colors; TPException ec = EC_NONE; bool undoSw = false, bClipboard = false; TCursor cursor = Screen->Cursor; Screen->Cursor = crHourGlass; TRect r = Rect(0, 0, iMainImage->Bitmap->Width, iMainImage->Bitmap->Height); if ((undoSw = UndoSave(UK_ALL, r)) == false) { ec = EC_MEMORY_LACK; goto fail; } memset(&bh, 0, sizeof(BITMAPHANDLE)); iMainImage->SubEnabled = true; if (!OpenClipboard(MainForm->Handle)) { ec = EC_CLIPBOARD_NOT_OPEN; goto fail; } bClipboard = true; if (IsClipboardFormatAvailable(MainForm->ClipboardFormat)) { if ((hMem = GetClipboardData(MainForm->ClipboardFormat))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((cbi = (TClipboardInfo *)GlobalLock(hMem))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if (cbi->Width<=iMainImage->Bitmap->Width && cbi->Height<=iMainImage->Bitmap->Height) { if (iMainImage->Bitmap->BitsPerPixel==8) { if (cbi->BitsPerPixel!=8) { ec = EC_COLOR_OVERFLOW; goto fail; } if ((ec = ReadTexpiaFormat8To8(cbi))!=EC_NONE) goto fail; if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; goto fail; } } else { if (cbi->BitsPerPixel==8) { if ((ec = ReadTexpiaFormat8To24(cbi))!=EC_NONE) goto fail; } else { if ((ec = ReadTexpiaFormat24To24(cbi))!=EC_NONE) goto fail; } if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } } } else { ec = EC_BIG_SIZE; goto fail; } GlobalUnlock(hMem); } else { if (L_ClipboardReady()) { if (L_InitBitmap(&bh, 0, 0, iMainImage->Bitmap->BitsPerPixel)<1) { ec = EC_MEMORY_LACK; goto fail; } if (L_CopyFromClipboard(MainForm->Handle, &bh)<1) { ec = EC_CLIPBOARD_NOT_READ; goto fail; } if (bh.Width<=iMainImage->Bitmap->Width && bh.Height<=iMainImage->Bitmap->Height) { if (bh.ViewPerspective!=TOP_LEFT) if (L_ChangeBitmapViewPerspective(NULL, &bh, TOP_LEFT)<1) { ec = EC_MEMORY_LACK; goto fail; } if (bh.BitsPerPixel<=8) { if (bh.BitsPerPixel!=8) { if (L_ColorResBitmap(&bh, &bh, 8, CRF_OPTIMIZEDPALETTE, NULL, 0, NULL, NULL)<1) { ec = EC_CAN_NOT_CONVERT; goto fail; } } L_AccessBitmap(&bh); if ((hBuffer = GlobalAlloc(GMEM_MOVEABLE, bh.BytesPerLine))==NULL) { ec = EC_MEMORY_LACK; goto fail; } if ((pBuffer = (Byte *)GlobalLock(hBuffer))==NULL) { ec = EC_MEMORY_LACK; goto fail; } colors = 0; memset(color, 0, 256*sizeof(short)); L_GetBitmapColors(&bh, 0, 256, rgb); for (y=0; yBitmap->BitsPerPixel==8) { if (bh.BitsPerPixel!=8) { ec = EC_COLOR_OVERFLOW; goto fail; } if ((ec = ReadGeneralFormat8To8(&bh, colors, color))!=EC_NONE) goto fail; if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 8)) { ec = EC_MEMORY_LACK; goto fail; } } else { if (bh.BitsPerPixel==8) { if ((ec = ReadGeneralFormat8To24(&bh, colors, color))!=EC_NONE) goto fail; } else { if ((ec = ReadGeneralFormat24To24(&bh))!=EC_NONE) goto fail; } if (!iMainImage->SubBitmap->Create(TempBitmap->Width, TempBitmap->Height, 24)) { ec = EC_MEMORY_LACK; goto fail; } if (!iMainImage->SubMask->Create(TempBitmap->Width, TempBitmap->Height, 1)) { ec = EC_MEMORY_LACK; goto fail; } } } else { ec = EC_BIG_SIZE; goto fail; } L_FreeBitmap(&bh); } else {ec = EC_NO_CLIPBOARDDATA; goto fail;} } CloseClipboard(); if (iMainImage->SubBitmap->BitsPerPixel==8) { Palette->ToRGBQUAD(rgb, 256); iMainImage->SubBitmap->PutColors(0, 256, rgb); iMainImage->SubMask->PutColors(0, 256, rgb); } FullViewForm->stSuper->Enabled = false; iMainImage->InitBackGround(0x01); PenManagerForm->SetColor(Palette); Center.x = iMainImage->SubBitmap->Width/2; Center.y = iMainImage->SubBitmap->Height/2; MainMenuForm->Item = T_MERGE; MainMenuForm->SubItem = 0; ::RepaintColor(); Screen->Cursor = cursor; return; fail: if (undoSw) { if (bClipboard) { if (hBuffer) { if (pBuffer) GlobalUnlock(hBuffer); GlobalFree(hBuffer); } L_FreeBitmap(&bh); if (hMem) { if (cbi) GlobalUnlock(hMem); } ExitMerge(); CloseClipboard(); } Undo->RemoveLast(); } Screen->Cursor = cursor; EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------- TCaptureData *__fastcall TMainImageForm::MakeCapture() { TCaptureData *cd = NULL; if ((cd = new TCaptureData)==NULL) goto fail; cd->Range = WorkArea->Range; if ((cd->Bitmap = new TTexpiaBitmap)==NULL) goto fail; if (!cd->Bitmap->Create(cd->Range.Right-cd->Range.Left, cd->Range.Bottom-cd->Range.Top, iMainImage->Bitmap->BitsPerPixel)) goto fail; if (!cd->Bitmap->CopyFromRect(iMainImage->Bitmap, cd->Range.Left, cd->Range.Top, SRCCOPY)) goto fail; if ((cd->Mask = new TTexpiaBitmap)==NULL) goto fail; if (!cd->Mask->Create(cd->Range.Right-cd->Range.Left, cd->Range.Bottom-cd->Range.Top, WorkArea->Mask->BitsPerPixel)) goto fail; if (!cd->Mask->Copy(WorkArea->Mask, SRCCOPY)) goto fail; return cd; fail: if (cd) delete cd; return NULL; } //--------------------------------------------------------------------- bool __fastcall TMainImageForm::InitOverlap(void) { if (iMainImage->Bitmap->BitsPerPixel>8){ overlapdata = (Byte *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 252*252*3);//½ÇÁ¦ÀûÀ¸·Î ǮĮ¶ó¿¡¼­´Â ¾²ÀÌÁö ¾Ê´Âµí.. } else { overlapdata = (Byte *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 252*252); } return overlapdata!=NULL; } //--------------------------------------------------------------------- void __fastcall TMainImageForm::ExitOverlap(void) { // if (iMainImage->Bitmap->BitsPerPixel==8) { if (overlapdata) { HeapFree(GetProcessHeap(), 0, overlapdata); overlapdata = NULL; } // } } //--------------------------------------------------------------------- COLORREF __fastcall TMainImageForm::Overlap(COLORREF base, COLORREF cover) { int point, density = FullViewForm->OverlapDensity; Byte usecolor; RGBQUAD rgb[256], *rgbPoint, *rgbBase, *rgbCover; if (iMainImage->Bitmap->BitsPerPixel==8) { if (base && cover) { if (base==cover) return base; else { usecolor = PaletteForm->DIB256Palette->UseColor; if (usecolor>=251) return 0xFF; if (overlapdata[base*252+cover]) return overlapdata[base*252+cover]; point = usecolor+1; PaletteForm->DIB256Palette->UseColor = point; overlapdata[base*252+cover] = overlapdata[cover*252+base] = point; rgbPoint = &Palette->ColorData[point]->RGB; rgbBase = &Palette->ColorData[base]->RGB; rgbCover = &Palette->ColorData[cover]->RGB; rgbPoint->rgbRed = (rgbBase->rgbRed*(63-density)+rgbCover->rgbRed*density)/63; rgbPoint->rgbGreen = (rgbBase->rgbGreen*(63-density)+rgbCover->rgbGreen*density)/63; rgbPoint->rgbBlue = (rgbBase->rgbBlue*(63-density)+rgbCover->rgbBlue*density)/63; PaletteForm->DIB256Palette->SetPalette(Palette); Palette->ToRGBQUAD(rgb, 256); iMainImage->Bitmap->PutColors(0, 256, rgb); return point; } } else if (base) return base; else return cover; } else { if (base==cover) return base; else { rgb[0] = TColorToRGB((TColor)base); rgb[1] = TColorToRGB((TColor)cover); rgb[2].rgbRed = (rgb[0].rgbRed*(63-density)+rgb[1].rgbRed*density)/63; rgb[2].rgbGreen = (rgb[0].rgbGreen*(63-density)+rgb[1].rgbGreen*density)/63; rgb[2].rgbBlue = (rgb[0].rgbBlue*(63-density)+rgb[1].rgbBlue*density)/63; return RGBToTColor(rgb[2]); } } } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ComboHeaderNoMethod(TTexpiaBitmap *Pattern, TSize r, int len, int item) { int width, height; TSize s; RECT Src; RGBQUAD rgb[256]; TTexpiaBitmap *Bitmap = NULL; if (WorkArea->Mask) { Src = WorkArea->Range; } else { Src = Rect(0, 0, iMainImage->Bitmap->Width, iMainImage->Bitmap->Height); } s.cx = Src.right - Src.left; s.cy = Src.bottom - Src.top; width = s.cx*r.cx; height = s.cy*r.cy; if (iMainImage->Bitmap->BitsPerPixel==8) { Palette->ToRGBQUAD(rgb, 256); Pattern->Create(width, height, 8, rgb); } else { Pattern->Create(width, height, 24); } Pattern->FillRect(Rect(0, 0, width, height), clWhite); if (iMainImage->LayerList->Count > 1) { if ((Bitmap = iMainImage->Composition()) == NULL) goto fail; if (!Repeat_Method(Pattern, r, s, Src, len, item, Bitmap)) goto fail; delete Bitmap; Bitmap = NULL; } else { if (!Repeat_Method(Pattern, r, s, Src, len, item, iMainImage->Bitmap)) goto fail; } return true; fail: if (Bitmap) delete Bitmap; return false; } //---------------------------------------------------------------------------- by k3dogs(20001015) ±×¸®µå¸¦ Pattern¿¡ ±×¸°´Ù. void __fastcall TMainImageForm::PrintGrid(TTexpiaBitmap *Pattern, TSize r, TColor GridColor, TGrid Grid, int GridMark, TColor GridMarkColor) { int i; double gapx = 0, gapy = 0, width, height; TSize s; RECT Src; HDC dcDst = NULL; HPEN hPen = NULL; HPEN hOldPen = NULL; switch (Grid.Unit) { case 1: Grid.X *= CanvasInfor.DotsPerInch; Grid.Y *= CanvasInfor.DotsPerInch; break; case 2: Grid.X *= CanvasInfor.DotsPerInch/2.54; Grid.Y *= CanvasInfor.DotsPerInch/2.54; break; } if (Grid.X > 5 && Grid.Y > 5) { //±×¸®µå °£°Ý Á¦ÇÑ. if (WorkArea->Mask) { Src = WorkArea->Range; } else { Src = Rect(0, 0, iMainImage->Bitmap->Width, iMainImage->Bitmap->Height); } s.cx = Src.right - Src.left; s.cy = Src.bottom - Src.top; width = s.cx*r.cx; height = s.cy*r.cy; dcDst = Pattern->CreateDC(); hPen = CreatePen(psSolid, 1, GridColor); hOldPen = SelectObject(dcDst, hPen); for (i=0; i <= Floor(iMainImage->Bitmap->Width/Grid.X); i++) { if ((GridMark > 0) && (i % GridMark ==0)) { hPen = CreatePen(psSolid, 1, GridMarkColor); hOldPen = SelectObject(dcDst, hPen); } if (WorkArea->Mask) { if ((WorkArea->Range.left <= gapx) && (gapx <= WorkArea->Range.right)) { MoveToEx(dcDst, gapx-WorkArea->Range.left, 0, NULL); LineTo(dcDst, gapx-WorkArea->Range.left, height); } } else { if (/*(WorkArea->Range.left <= gapx) &&*/ (gapx <= iMainImage->Bitmap->Width)) { MoveToEx(dcDst, gapx, 0, NULL); LineTo(dcDst, gapx, height); } } if ((GridMark > 0) && (i % GridMark ==0)) { hPen = CreatePen(psSolid, 1, GridColor); hOldPen = SelectObject(dcDst, hPen); } gapx += Grid.X; } for (i=0; i <= Floor(iMainImage->Bitmap->Height/Grid.Y); i++) { if ((GridMark > 0) && (i % GridMark ==0)) { hPen = CreatePen(psSolid, 1, GridMarkColor); hOldPen = SelectObject(dcDst, hPen); } if (WorkArea->Mask) { if ((WorkArea->Range.top <= gapy) && (gapy <= WorkArea->Range.bottom)) { MoveToEx(dcDst, 0, gapy-WorkArea->Range.top, NULL); LineTo(dcDst, width, gapy-WorkArea->Range.top); } } else { if (/*(WorkArea->Range.top <= gapy) &&*/ (gapy <= iMainImage->Bitmap->Height)) { MoveToEx(dcDst, 0, gapy, NULL); LineTo(dcDst, width, gapy); } } if ((GridMark > 0) && (i % GridMark ==0)) { hPen = CreatePen(psSolid, 1, GridColor); hOldPen = SelectObject(dcDst, hPen); } gapy += Grid.Y; } SelectObject(dcDst, hOldPen); hOldPen = NULL; DeleteObject(hPen); hPen = NULL; Pattern->DeleteDC(dcDst); } } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ComboHeaderYesMethod(TTexpiaBitmap *Pattern) { bool result; if (iMainImage->LayerList->Count > 1) { result = HeaderYesMethod_layer(Pattern); } else { result = HeaderYesMethod_none(Pattern); } return result; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderYesMethod_none(TTexpiaBitmap *Pattern) { TRect Src, Dst, PDst; TTexpiaBitmap *UsedColBit = NULL; int w, h, temp, ht, width, height, cnt; bool over; HDC dcSrc = NULL, dcDst = NULL, dcUse = NULL; if ((UsedColBit = new TTexpiaBitmap)==NULL) goto fail; if (!ComboHeaderUsedColorMethod(UsedColBit, true)) goto fail; if (WorkArea->Mask) { Src = WorkArea->Range; width = Src.Right-Src.Left; height = Src.Bottom-Src.Top; } else { width = iMainImage->Bitmap->Width; height = iMainImage->Bitmap->Height; } w = UsedColBit->Width*CanvasInfor.DotsPerInch/160; h = UsedColBit->Height*CanvasInfor.DotsPerInch/160; // {µÎ°³ÀÇ BitmapÀ» ÇÕÄ£ PatternÀÇ »õ·Î¿î ³ôÀÌ¿Í ³ÐÀÌ} ht = GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); temp = height; //================================================ // if (w>width) width = w; // height = temp+h; // if (height>ht) height = ht+h; if (w>width) width = w; cnt = temp/ht; if ((temp-ht*cnt+h) > ht) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ cnt++; over = true; height = cnt*ht + h; } else { over = false; height = temp + h; } //================================================ Pattern->Create(width, height, 24); // { White·Î PatternÀüü¸¦ ä¿ì±â } Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if ((dcSrc = iMainImage->Bitmap->CreateDC())==NULL) goto fail; if ((dcDst = Pattern->CreateDC())==NULL) goto fail; if (WorkArea->Mask) { Dst = Rect(0, 0, Src.Right-Src.Left, temp); BitBlt(dcDst, 0, 0, Dst.Right, Dst.Bottom, dcSrc, Src.Left, Src.Top, SRCCOPY); if (!Irregularrect(dcDst, Src, Dst)) goto fail; } else { BitBlt(dcDst, 0, 0, iMainImage->Bitmap->Width, iMainImage->Bitmap->Height, dcSrc, 0, 0, SRCCOPY); } iMainImage->Bitmap->DeleteDC(dcSrc); dcSrc = NULL; if ((dcUse = UsedColBit->CreateDC()) == NULL) goto fail; //============================================ // PDst = Rect(0, temp , w, temp+h); // if (Pattern->Height>ht) PDst = Rect(0, ht, w, ht+h); if (over) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ PDst = Rect(0, cnt*ht, w, cnt*ht+h); } else { PDst = Rect(0, temp , w, temp+h); } //============================================ Src = Rect(0, 0, UsedColBit->Width, UsedColBit->Height); StretchBlt(dcDst, PDst.Left, PDst.Top, PDst.Right - PDst.Left, PDst.Bottom - PDst.Top, dcUse, 0, 0, UsedColBit->Width, UsedColBit->Height, SRCCOPY); UsedColBit->DeleteDC(dcUse); dcUse = NULL; Pattern->DeleteDC(dcDst); dcDst = NULL; delete UsedColBit; return true; fail: if (UsedColBit) { if (dcSrc) iMainImage->Bitmap->DeleteDC(dcSrc); if (dcDst) Pattern->DeleteDC(dcDst); if (dcUse) UsedColBit->DeleteDC(dcUse); delete UsedColBit; } return false; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderYesMethod_layer(TTexpiaBitmap *Pattern) { TRect Src, Dst, PDst; TTexpiaBitmap *UsedColBit = NULL, *Bitmap = NULL; int w, h, temp, ht, width, height, cnt; bool over; HDC dcSrc = NULL, dcDst = NULL, dcUse = NULL; if ((UsedColBit = new TTexpiaBitmap)==NULL) goto fail; if (!ComboHeaderUsedColorMethod(UsedColBit, true)) goto fail; if (WorkArea->Mask) { Src = WorkArea->Range; width = Src.Right-Src.Left; height = Src.Bottom-Src.Top; } else { width = iMainImage->Bitmap->Width; height = iMainImage->Bitmap->Height; } w = UsedColBit->Width*CanvasInfor.DotsPerInch/160; h = UsedColBit->Height*CanvasInfor.DotsPerInch/160; // {µÎ°³ÀÇ BitmapÀ» ÇÕÄ£ PatternÀÇ »õ·Î¿î ³ôÀÌ¿Í ³ÐÀÌ} ht = GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); temp = height; //================================================ // if (w>width) width = w; // height = temp+h; // if (height>ht) height = ht+h; if (w>width) width = w; cnt = temp/ht; if ((temp-ht*cnt+h) > ht) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ cnt++; over = true; height = cnt*ht + h; } else { over = false; height = temp + h; } //================================================ Pattern->Create(width, height, 24); // { White·Î PatternÀüü¸¦ ä¿ì±â } Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if ((Bitmap = iMainImage->Composition()) == NULL) goto fail; if ((dcSrc = Bitmap->CreateDC())==NULL) goto fail; if ((dcDst = Pattern->CreateDC())==NULL) goto fail; if (WorkArea->Mask) { Dst = Rect(0, 0, Src.Right-Src.Left, temp); BitBlt(dcDst, 0, 0, Dst.Right, Dst.Bottom, dcSrc, Src.Left, Src.Top, SRCCOPY); if (!Irregularrect(dcDst, Src, Dst)) goto fail; } else { BitBlt(dcDst, 0, 0, iMainImage->Bitmap->Width, iMainImage->Bitmap->Height, dcSrc, 0, 0, SRCCOPY); } Bitmap->DeleteDC(dcSrc); dcSrc = NULL; delete Bitmap; Bitmap = NULL; if ((dcUse = UsedColBit->CreateDC()) == NULL) goto fail; //============================================ // PDst = Rect(0, temp , w, temp+h); // if (Pattern->Height>ht) PDst = Rect(0, ht, w, ht+h); if (over) { // colorchipÀÌ À߸®´Â °ÍÀ» ¸·±â À§ÇØ PDst = Rect(0, cnt*ht, w, cnt*ht+h); } else { PDst = Rect(0, temp , w, temp+h); } //============================================ Src = Rect(0, 0, UsedColBit->Width, UsedColBit->Height); StretchBlt(dcDst, PDst.Left, PDst.Top, PDst.Right - PDst.Left, PDst.Bottom - PDst.Top, dcUse, 0, 0, UsedColBit->Width, UsedColBit->Height, SRCCOPY); UsedColBit->DeleteDC(dcUse); dcUse = NULL; Pattern->DeleteDC(dcDst); dcDst = NULL; delete UsedColBit; return true; fail: if (UsedColBit) { if (dcDst) Pattern->DeleteDC(dcDst); if (dcUse) UsedColBit->DeleteDC(dcUse); delete UsedColBit; } if (Bitmap) { if (dcSrc) Bitmap->DeleteDC(dcSrc); delete Bitmap; Bitmap = NULL; } return false; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ComboHeaderUsedColorMethod(TTexpiaBitmap *Pattern, bool Yes) { TChoiceColor *ChoiceColor = NULL; int i, j, k, l, row, width, height; short m, n, tab, bot, sbot, tb, t; AnsiString NameStr, Rgbvalue; RGBQUAD rgb[256]; TRect BitRect, StrRect, Re; TCanvas *ca = NULL; if ((ChoiceColor = new TChoiceColor)==NULL) goto fail; if (iMainImage->LayerList->Count > 1) { if (WorkArea->Mask) SearchWorkAreaBackGroundColor(ChoiceColor); else SearchWholeBackGroundColor(ChoiceColor); } else { if (WorkArea->Mask) SearchWorkAreaColor(ChoiceColor); else SearchWholeColor(ChoiceColor); } width = GetDeviceCaps(Printer()->Handle, HORZRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSX); height = GetDeviceCaps(Printer()->Handle, VERTRES)*160/ GetDeviceCaps(Printer()->Handle, LOGPIXELSY); if (Yes) { // ComboBoxYesMethod¿¡¼­ »ç¿ë ÇÒ °ª m =100; n =70; bot = 80; sbot = 100; tb = 82; t = 90; } else { // UsedColorMethod¿¡¼­ »ç¿ë ÇÒ °ª m = 120; n = 130; bot = 130; sbot = 160; tb = 135; t = 110; } l = (width-34) / m ; // Pattern Height Á¤Çϱâ row = 1+ChoiceColor->Count / l; height = row*n+60; Pattern->Create(width, height, 24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); for (i=0, k = 0; iCount; i++, k++) { if (i%l == 0) { j = i / l; k = 0; } BitRect = Rect(44+k*m, 30+j*n, 34+m+k*m, bot+j*n); PrintColorChip24(Pattern, BitRect, ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue); } ca = Pattern->CreateCanvas(); ca->Font->Size = 10; for (i=0, k = 0; iCount; i++, k++) { if (i%l == 0) { j = i / l; k = 0; } StrRect = Rect(44+k*m, bot+j*n, 34+m+k*m, sbot+j*n); ca->Brush->Color = clWhite; switch (ChoiceColor->ColorMap[i]->Kind) { case 0: if (ChoiceColor->ColorMap[i]->Page==0) NameStr = Format("%d - %d - %d", OPENARRAY(TVarRec, (255-ChoiceColor->ColorMap[i]->RGB.rgbRed, 255-ChoiceColor->ColorMap[i]->RGB.rgbGreen, 255-ChoiceColor->ColorMap[i]->RGB.rgbBlue))); else NameStr = PrinterColor->PN2Code(ChoiceColor->ColorMap[i]->Page, ChoiceColor->ColorMap[i]->Number); break; case 3: NameStr = StandardColor->PN2Code(ChoiceColor->ColorMap[i]->Page, ChoiceColor->ColorMap[i]->Number); break; case 4: NameStr = TextileColor->PN2Code(ChoiceColor->ColorMap[i]->Page, ChoiceColor->ColorMap[i]->Number); break; case 0x10: case 0x13: case 0x14: NameStr = ChoiceColor->ColorMap[i]->ColorName; Rgbvalue = Format("%d - %d - %d", OPENARRAY(TVarRec, (ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue))); break; } tab = (t- ca->TextWidth(NameStr)) / 2; // Adjust Center if (tab<0) tab = 0; ca->TextRect(StrRect, 44+tab+m*k, tb+j*n, NameStr); } delete ChoiceColor; Pattern->DeleteCanvas(ca); return true; fail: if (ChoiceColor) delete ChoiceColor; return false; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::ComboHeaderMosaicMethod(TTexpiaBitmap *Pattern, int mx, int my) { bool result; if (iMainImage->LayerList->Count > 1) { result = HeaderMosaicMethod_layer(Pattern, mx, my); } else { result = HeaderMosaicMethod_none(Pattern, mx, my); } return result; } //---------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderMosaicMethod_none(TTexpiaBitmap *Pattern, int mx, int my) { Byte max, maxp, *sl, *Msl; short color[256]; RGBQUAD rgb[256]; int i, j, k, m, w, h, wh, sum, red, green, blue; TRect Dst, Wrc, Re; COLORREF c; if (!iMainImage->Bitmap->StartScanLine()) goto fail; if (iMainImage->Bitmap->BitsPerPixel==8) { Palette->ToRGBQUAD(rgb, 256); if (WorkArea->Mask) { // Case of Rect_None Mosaic Wrc = WorkArea->Range; w = (Wrc.Right-Wrc.Left)/mx; h = (Wrc.Bottom-Wrc.Top)/my; wh = w*h/2; Pattern->Create(mx*w + 1, my*h + 1, 8, rgb); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (!WorkArea->Mask->StartScanLine()) goto fail; for (m=0; m=0 && j<(Wrc.Bottom-Wrc.Top)) { sl = iMainImage->Bitmap->GetScanLine(j+Wrc.Top)+Wrc.Left; Msl = WorkArea->Mask->GetScanLine(j); } else SHOWDEBUG; #else sl = iMainImage->Bitmap->GetScanLine(j+Wrc.Top)+Wrc.Left; Msl = WorkArea->Mask->GetScanLine(j); #endif for (i=k*w; i<(k+1)*w; i++) { #ifdef TPDEBUG if (i>=0 && i<(Wrc.Right-Wrc.Left)) { if (*(Msl+i)) { c = *(sl+i); color[c]++; if (color[c]>max) { max = color[c]; maxp = c; } sum++; } } else SHOWDEBUG; #else if (*(Msl+i)) { c = *(sl+i); color[c]++; if (color[c]>max) { max = color[c]; maxp = c; } sum++; } #endif } } if (sum>=(wh)) { // Because of Irregular rect.... MosaicDraw8(Pattern, k, m, w, h, maxp); } } } WorkArea->Mask->StopScanLine(); } else { w = iMainImage->Bitmap->Width/mx; h = iMainImage->Bitmap->Height/my; Pattern->Create(mx*w + 1, my*h + 1, 8, rgb); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); for (m=0; m=0 && j<(iMainImage->Bitmap->Height)) { sl = iMainImage->Bitmap->GetScanLine(j); } else SHOWDEBUG; #else sl = iMainImage->Bitmap->GetScanLine(j); #endif for (i=k*w; i<(k+1)*w; i++) { #ifdef TPDEBUG if (i>=0 && i<(iMainImage->Bitmap->Width)) { c = *(sl+i); color[c] = color[c]+1; if (color[c]>max) { max = color[c]; maxp = c; } } else SHOWDEBUG; #else c = *(sl+i); color[c] = color[c]+1; if (color[c]>max) { max = color[c]; maxp = c; } #endif } } MosaicDraw8(Pattern, k, m, w, h, maxp); } } } } else { if (WorkArea->Mask) { // Case of Rect_None Mosaic Wrc = WorkArea->Range; w = (Wrc.Right-Wrc.Left)/mx; h = (Wrc.Bottom-Wrc.Top)/my; wh = w*h/2; Pattern->Create(mx*w + 1, my*h + 1, 24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (!WorkArea->Mask->StartScanLine()) goto fail; for (m=0; m=0 && j<(Wrc.Right-Wrc.Left)) { sl = iMainImage->Bitmap->GetScanLine(j+Wrc.Top)+3*(Wrc.Left+k*w); Msl = WorkArea->Mask->GetScanLine(j); } else SHOWDEBUG; #else sl = iMainImage->Bitmap->GetScanLine(j+Wrc.Top)+3*(Wrc.Left+k*w); Msl = WorkArea->Mask->GetScanLine(j); #endif for (i=k*w; i<(k+1)*w; i++, sl+=3) { #ifdef TPDEBUG if (i>=0 && i<(Wrc.Bottom-Wrc.Top)) { if (*(Msl+(i>>3))&(0x80>>(i&7))) { GetPixel24(sl, c); rgb[0] = TColorToRGB(c); red += rgb[0].rgbRed; green += rgb[0].rgbGreen; blue += rgb[0].rgbBlue; sum++; } } else SHOWDEBUG; #else if (*(Msl+(i>>3))&(0x80>>(i&7))) { GetPixel24(sl, c); rgb[0] = TColorToRGB((TColor)c); red += rgb[0].rgbRed; green += rgb[0].rgbGreen; blue += rgb[0].rgbBlue; sum++; } #endif } } if (sum>(wh)) { // Because of Irregular rect.... rgb[0].rgbRed = red/sum; rgb[0].rgbGreen = green/sum; rgb[0].rgbBlue = blue/sum; MosaicDraw24(Pattern, k, m, w, h, rgb[0]); } } } WorkArea->Mask->StopScanLine(); } else { w = iMainImage->Bitmap->Width/mx; h = iMainImage->Bitmap->Height/my; wh = w*h; Pattern->Create(mx*w + 1, my*h + 1, 24); for (m=0; m=0 && jBitmap->Height) { sl = iMainImage->Bitmap->GetScanLine(j)+3*k*w; } else SHOWDEBUG; #else sl = iMainImage->Bitmap->GetScanLine(j)+3*k*w; #endif for (i=0; i=0 && iBitmap->Width) { GetPixel24(sl, c); rgb[0] = TColorToRGB(c); red += rgb[0].rgbBlue; green += rgb[0].rgbGreen; blue += rgb[0].rgbRed; } else SHOWDEBUG; #else GetPixel24(sl, c); rgb[0] = TColorToRGB((TColor)c); red += rgb[0].rgbBlue; green += rgb[0].rgbGreen; blue += rgb[0].rgbRed; #endif } } rgb[0].rgbRed = Byte(blue/wh); rgb[0].rgbGreen = Byte(green/wh); rgb[0].rgbBlue = Byte(red/wh); MosaicDraw24(Pattern, k, m, w, h, rgb[0]); } } } } iMainImage->Bitmap->StopScanLine(); return true; fail: if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); iMainImage->Bitmap->StopScanLine(); return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::HeaderMosaicMethod_layer(TTexpiaBitmap *Pattern, int mx, int my) { Byte max, maxp, *sl, *Msl; short color[256]; RGBQUAD rgb[256]; int i, j, k, m, w, h, wh, sum, red, green, blue; TRect Dst, Wrc, Re; COLORREF c; TTexpiaBitmap *Bitmap = NULL; if ((Bitmap = iMainImage->Composition()) == NULL) goto fail; if (!Bitmap->StartScanLine()) goto fail; if (iMainImage->Bitmap->BitsPerPixel==8) { Palette->ToRGBQUAD(rgb, 256); if (WorkArea->Mask) { // Case of Rect_None Mosaic Wrc = WorkArea->Range; w = (Wrc.Right-Wrc.Left)/mx; h = (Wrc.Bottom-Wrc.Top)/my; wh = w*h/2; Pattern->Create(mx*w + 1, my*h + 1, 8, rgb); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (!WorkArea->Mask->StartScanLine()) goto fail; for (m=0; m=0 && j<(Wrc.Bottom-Wrc.Top)) { sl = Bitmap->GetScanLine(j+Wrc.Top)+Wrc.Left; Msl = WorkArea->Mask->GetScanLine(j); } else SHOWDEBUG; #else sl = Bitmap->GetScanLine(j+Wrc.Top)+Wrc.Left; Msl = WorkArea->Mask->GetScanLine(j); #endif for (i=k*w; i<(k+1)*w; i++) { #ifdef TPDEBUG if (i>=0 && i<(Wrc.Right-Wrc.Left)) { if (*(Msl+i)) { c = *(sl+i); color[c]++; if (color[c]>max) { max = color[c]; maxp = c; } sum++; } } else SHOWDEBUG; #else if (*(Msl+i)) { c = *(sl+i); color[c]++; if (color[c]>max) { max = color[c]; maxp = c; } sum++; } #endif } } if (sum>=(wh)) { // Because of Irregular rect.... MosaicDraw8(Pattern, k, m, w, h, maxp); } } } WorkArea->Mask->StopScanLine(); } else { w = iMainImage->Bitmap->Width/mx; h = iMainImage->Bitmap->Height/my; Pattern->Create(mx*w + 1, my*h + 1, 8, rgb); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); for (m=0; m=0 && j<(iMainImage->Bitmap->Height)) { sl = Bitmap->GetScanLine(j); } else SHOWDEBUG; #else sl = Bitmap->GetScanLine(j); #endif for (i=k*w; i<(k+1)*w; i++) { #ifdef TPDEBUG if (i>=0 && i<(iMainImage->Bitmap->Width)) { c = *(sl+i); color[c] = color[c]+1; if (color[c]>max) { max = color[c]; maxp = c; } } else SHOWDEBUG; #else c = *(sl+i); color[c] = color[c]+1; if (color[c]>max) { max = color[c]; maxp = c; } #endif } } MosaicDraw8(Pattern, k, m, w, h, maxp); } } } } else { if (WorkArea->Mask) { // Case of Rect_None Mosaic Wrc = WorkArea->Range; w = (Wrc.Right-Wrc.Left)/mx; h = (Wrc.Bottom-Wrc.Top)/my; wh = w*h/2; Pattern->Create(mx*w + 1, my*h + 1, 24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); if (!WorkArea->Mask->StartScanLine()) goto fail; for (m=0; m=0 && j<(Wrc.Right-Wrc.Left)) { sl = Bitmap->GetScanLine(j+Wrc.Top)+3*(Wrc.Left+k*w); Msl = WorkArea->Mask->GetScanLine(j); } else SHOWDEBUG; #else sl = Bitmap->GetScanLine(j+Wrc.Top)+3*(Wrc.Left+k*w); Msl = WorkArea->Mask->GetScanLine(j); #endif for (i=k*w; i<(k+1)*w; i++, sl+=3) { #ifdef TPDEBUG if (i>=0 && i<(Wrc.Bottom-Wrc.Top)) { if (*(Msl+(i>>3))&(0x80>>(i&7))) { GetPixel24(sl, c); rgb[0] = TColorToRGB(c); red += rgb[0].rgbRed; green += rgb[0].rgbGreen; blue += rgb[0].rgbBlue; sum++; } } else SHOWDEBUG; #else if (*(Msl+(i>>3))&(0x80>>(i&7))) { GetPixel24(sl, c); rgb[0] = TColorToRGB((TColor)c); red += rgb[0].rgbRed; green += rgb[0].rgbGreen; blue += rgb[0].rgbBlue; sum++; } #endif } } if (sum>(wh)) { // Because of Irregular rect.... rgb[0].rgbRed = red/sum; rgb[0].rgbGreen = green/sum; rgb[0].rgbBlue = blue/sum; MosaicDraw24(Pattern, k, m, w, h, rgb[0]); } } } WorkArea->Mask->StopScanLine(); } else { w = iMainImage->Bitmap->Width/mx; h = iMainImage->Bitmap->Height/my; wh = w*h; Pattern->Create(mx*w + 1, my*h + 1, 24); for (m=0; m=0 && jBitmap->Height) { sl = Bitmap->GetScanLine(j)+3*k*w; } else SHOWDEBUG; #else sl = Bitmap->GetScanLine(j)+3*k*w; #endif for (i=0; i=0 && iBitmap->Width) { GetPixel24(sl, c); rgb[0] = TColorToRGB(c); red += rgb[0].rgbBlue; green += rgb[0].rgbGreen; blue += rgb[0].rgbRed; } else SHOWDEBUG; #else GetPixel24(sl, c); rgb[0] = TColorToRGB((TColor)c); red += rgb[0].rgbBlue; green += rgb[0].rgbGreen; blue += rgb[0].rgbRed; #endif } } rgb[0].rgbRed = Byte(blue/wh); rgb[0].rgbGreen = Byte(green/wh); rgb[0].rgbBlue = Byte(red/wh); MosaicDraw24(Pattern, k, m, w, h, rgb[0]); } } } } Bitmap->StopScanLine(); ::doDestroy(Bitmap); return true; fail: if (Bitmap) { if (WorkArea->Mask) WorkArea->Mask->StopScanLine(); Bitmap->StopScanLine(); ::doDestroy(Bitmap); } return false; } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::UndoSave(int k, RECT r, bool bSave) { Modify = true; if (FullViewForm->Super == sOverlap) FullViewForm->ExitOverlapChange(); return Undo->Save(k, r, bSave); } //--------------------------------------------------------------------------- bool __fastcall TMainImageForm::UndoSave(int k, bool bSave) { Modify = true; if (FullViewForm->Super == sOverlap) FullViewForm->ExitOverlapChange(); return Undo->Save(k, bSave); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PenChange(void) { PenManagerForm->lColor->Enabled = iMainImage->Bitmap->BitsPerPixel==8; PenManagerForm->eGrade->Enabled = iMainImage->Bitmap->BitsPerPixel==8; if (MainMenuForm->Item == T_NONE) { if (PenManagerForm->Type == PT_MASK) { if (iMainImage->Bitmap->BitsPerPixel == 8) { OnSetHLine = SetHLineMask8; if (PenManagerForm->chDelete->Checked) { MaskPixel = 0x00; } else { MaskPixel = 0x0F; } } else { if (PenManagerForm->chDelete->Checked) { OnSetHLine = SetHLineMaskDelete24; MaskPixel = 0x00; } else { OnSetHLine = SetHLineMask24; MaskPixel = 0x80; } } } else { if (iMainImage->Bitmap->BitsPerPixel==8) { if (PenManagerForm->Type == PT_WATER) { PenManagerForm->Type == PT_NORMAL; PenManagerForm->sbNormal->Down = true; PenManagerForm->PenSelectClick(PenManagerForm->sbNormal); PenManagerForm->sbWater->Enabled = false; } else { PenManagerForm->sbWater->Enabled = false; } if (PenManagerForm->acolor == 2) { OnSetHLine = SetHLine8ColorYes; } else { OnSetHLine = SetHLine8ColorNo; } } else { PenManagerForm->sbWater->Enabled = true; OnSetHLine = SetHLine24; } } } else if (MainMenuForm->Item == T_DRAW || MainMenuForm->Item == T_3D) { if (PenManagerForm->Type == PT_MASK) { if (iMainImage->Bitmap->BitsPerPixel == 8) { OnSetHLine = SetHLineMask8; if (PenManagerForm->chDelete->Checked) { MaskPixel = 0x00; } else { MaskPixel = 0x0F; } } else { if (PenManagerForm->chDelete->Checked) { OnSetHLine = SetHLineMaskDelete24; MaskPixel = 0x00; } else { OnSetHLine = SetHLineMask24; MaskPixel = 0x80; } } } else { if (iMainImage->Bitmap->BitsPerPixel==8) { OnSetHLine = SetHLine8ColorNo; } else { OnSetHLine = SetHLine24; } } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Timer50ms() { // } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Timer200ms() { if (CurrentUnit==uDot) { MainForm->StatusBar->Panels->Items[StatusBarAxis]->Text = Format("%d : %d", OPENARRAY(TVarRec, ((int)CursorPosition.x, (int)CursorPosition.y))); } else if (CurrentUnit==uInch) { MainForm->StatusBar->Panels->Items[StatusBarAxis]->Text = Format("%f : %f", OPENARRAY(TVarRec, ((double)CursorPosition.x/CanvasInfor.DotsPerInch, (double)CursorPosition.y/CanvasInfor.DotsPerInch))); } else if (CurrentUnit==uCm) { MainForm->StatusBar->Panels->Items[StatusBarAxis]->Text = Format("%f : %f", OPENARRAY(TVarRec, (2.54*CursorPosition.x/CanvasInfor.DotsPerInch, 2.54*CursorPosition.y/CanvasInfor.DotsPerInch))); } if (sbRuler->Down) Ruler->PositionBar(CursorPosition); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Timer1000ms() { // static int i=0; /*if (!BtnClick)*/ iMainImage->OutlineBitmapRgn(WorkArea->bComplex); // if(i==0&&Active&&iMainImage->CrossLine)iMainImage->Repaint(); // if(i==2)i=0; // i++; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::TimerAutoSave() { AnsiString msg, fn, ext; char *s; TGraphicFileFormat gff; #ifdef ACADEMY gff = gffTEX; ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; #else if (iMainImage->Bitmap->BitsPerPixel==8) { gff = gffTEX; ext = ".tex"; MainForm->SaveDialog->Filter = "Texpro Textile 256 Colors File (*.tex)|*.tex"; } else { #ifndef N_3D if(MainForm->T3D_Item){ if (MainMenuForm->Item == T_3D) { gff = gffT3D; ext = ".t3d"; MainForm->SaveDialog->Filter = "Texpro Textile 3D File (*.t3d)|*.t3d"; } else { gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; } } else { gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; } #else gff = gffTFC; ext = ".tfc"; MainForm->SaveDialog->Filter = "Texpro Textile Full Colors File (*.tfc)|*.tfc"; #endif } #endif if (initsave) { TIniFile *IniFile = new TIniFile(DirectoryItem + "\\Main.ini"); if (IniFile) { MainForm->SaveDialog->InitialDir = IniFile->ReadString("FileManager", "DirectoryName", "C:\\"); delete IniFile; } if (MainForm->SaveDialog->Execute() == mrOk) { s = AnsiStrScan(MainForm->SaveDialog->FileName.c_str(), '.'); if (s==NULL) fn = MainForm->SaveDialog->FileName+ext; else fn = MainForm->SaveDialog->FileName; DirName = ExtractFileDir(fn); FileName = ExtractFileName(fn); AutoSaveForm = new TAutoSaveForm(NULL); AutoSaveForm->Visible = true; AutoSaveForm->Update(); AutoSaveToFile(DirName, FileName, gff, MainForm->CompressMethod); delete AutoSaveForm; initsave = false; } } else { AutoSaveForm = new TAutoSaveForm(NULL); AutoSaveForm->Visible = true; AutoSaveForm->Update(); AutoSaveToFile(DirName, FileName, gff, MainForm->CompressMethod); delete AutoSaveForm; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ApplyEnvironment() { TIniFile *IniFile = new TIniFile(DirectoryItem+"\\Environment.ini"); if (IniFile) { WorkArea->undoMax = IniFile->ReadInteger("Window", "MaxUndo", 5); delete IniFile; } } //--------------------------------------------------------------------- void __fastcall TMainImageForm::ReadyToArrowKeyDown(bool IsDown) { sbHorz->Enabled = IsDown; sbVert->Enabled = IsDown; FullViewForm->tbOverlap->Enabled = IsDown; FullViewForm->TrackBar->Enabled = IsDown; } //--------------------------------------------------------------------- void __fastcall TMainImageForm::OverlapChange() { if (iMainImage->LayerMask) OverlapChange_layer(); else OverlapChange_none(); } //--------------------------------------------------------------------- void __fastcall TMainImageForm::OverlapChange_none() { Byte *ssl, *dsl, *usl, *mml, usecolor; int x, y, moveleft; COLORREF bgc, sc, dc, color; RGBQUAD rgb[256]; TTexpiaBitmap *SBitmap = NULL, *UBitmap = NULL; RECT rc, urc; TUndoData *ud; SBitmap = FullViewForm->OverlapBitmap; rc = FullViewForm->OverlapRect; if (FullViewForm->OverlapBack) { urc = rc; UBitmap = FullViewForm->OverlapBack; } else { if (Undo->Last == NULL) return; ud = Undo->Last; urc = ud->Range; UBitmap = ud->Bitmap; } if (SBitmap && UBitmap) { moveleft = rc.left - urc.left; PaletteForm->DIB256Palette->UseColor = FullViewForm->preusecolor; if (bMaskArea) { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) goto fail; if (!iMainImage->Bitmap->StartScanLine()) goto fail; if (!iMainImage->Mask->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->Bitmap->BitsPerPixel==8) { if (SBitmap->BitsPerPixel!=8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { if (Palette->ColorData[*usl]->Protect==0 && (*mml == 0)) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++) { if (*mml == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->Bitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel==8) { SBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); for (x=rc.left; x> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); for (x=rc.left; x> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->Bitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->Bitmap->StopScanLine(); iMainImage->Mask->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); } else { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) goto fail; if (!iMainImage->Bitmap->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->Bitmap->BitsPerPixel==8) { if (SBitmap->BitsPerPixel!=8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { if (Palette->ColorData[*usl]->Protect==0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } iMainImage->Bitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel==8) { SBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + 3*rc.left; for (x=rc.left; xBitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + 3*rc.left; for (x=rc.left; xBitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->Bitmap->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); } } ::RepaintColor(); return; fail: ExitOverlap(); iMainImage->Bitmap->StopScanLine(); if (bMaskArea) iMainImage->Mask->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::OverlapChange_layer() { Byte *ssl, *dsl, *usl, *mml, *lp, usecolor; int x, y, moveleft; COLORREF bgc, sc, dc, color; RGBQUAD rgb[256]; TTexpiaBitmap *SBitmap = NULL, *UBitmap = NULL; RECT rc, urc; TUndoData *ud; SBitmap = FullViewForm->OverlapBitmap; rc = FullViewForm->OverlapRect; if (FullViewForm->OverlapBack) { urc = rc; UBitmap = FullViewForm->OverlapBack; } else { if (Undo->Last == NULL) return; ud = Undo->Last; urc = ud->Range; UBitmap = ud->Bitmap; } if (SBitmap && UBitmap) { moveleft = rc.left - urc.left; PaletteForm->DIB256Palette->UseColor = FullViewForm->preusecolor; if (bMaskArea) { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) goto fail; if (!iMainImage->Bitmap->StartScanLine()) goto fail; if (!iMainImage->Mask->StartScanLine()) goto fail; if (!iMainImage->LayerMask->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->Bitmap->BitsPerPixel==8) { if (SBitmap->BitsPerPixel!=8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; lp = iMainImage->Mask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++, lp++) { if (*lp) continue; if (Palette->ColorData[*usl]->Protect==0 && (*mml == 0)) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + rc.left; mml = iMainImage->Mask->GetScanLine(y) + rc.left; lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, mml++, usl++, lp++) { if (*lp) continue; if (*mml == 0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->Bitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel==8) { SBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; x> 3] & (0x80 >> (x & 7))) != 0) continue; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + 3*rc.left; mml = iMainImage->Mask->GetScanLine(y); lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; x> 3] & (0x80 >> (x & 7))) != 0) continue; if ((mml[x >> 3] & (0x80 >> (x & 7))) == 0) { GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } } iMainImage->Bitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->Bitmap->StopScanLine(); iMainImage->LayerMask->StopScanLine(); iMainImage->Mask->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); } else { if (!SBitmap->StartScanLine()) goto fail; if (!UBitmap->StartScanLine()) goto fail; if (!iMainImage->Bitmap->StartScanLine()) goto fail; if (!iMainImage->LayerMask->StartScanLine()) goto fail; if (!InitOverlap()) goto fail; if (iMainImage->Bitmap->BitsPerPixel==8) { if (SBitmap->BitsPerPixel!=8) goto fail; if (bProtect) { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + rc.left; lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++, lp++) { if (*lp) continue; if (Palette->ColorData[*usl]->Protect==0) { if (*usl > 1) { if ((color = Overlap(*usl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } } iMainImage->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + rc.left; lp = iMainImage->LayerMask->GetScanLine(y) + rc.left; for (x = rc.left; x < rc.right; x++, ssl++, dsl++, usl++, lp++) { if (*lp) continue; if (*usl > 1) { if ((color = Overlap(*usl, *ssl))==0xFF) goto fail; *dsl = color; } else { *dsl = *ssl; } } iMainImage->Bitmap->PutScanLine(y); } } } else { bgc = PaletteForm->DIB256Palette->GetBGCOLORREF(24); if (SBitmap->BitsPerPixel==8) { SBitmap->GetColors(0, 256, rgb); for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + 3*rc.left; lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; x> 3] & (0x80 >> (x & 7))) != 0) continue; sc = RGBToTColor(rgb[*ssl]); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->Bitmap->PutScanLine(y); } } else { for (y = rc.top; y < rc.bottom; y++) { ssl = SBitmap->GetScanLine(y - rc.top); usl = UBitmap->GetScanLine(y - urc.top) + 3*moveleft; dsl = iMainImage->Bitmap->GetScanLine(y) + 3*rc.left; lp = iMainImage->LayerMask->GetScanLine(y); for (x=rc.left; x> 3] & (0x80 >> (x & 7))) != 0) continue; GetPixel24(ssl, sc); GetPixel24(usl, dc); if (dc != bgc) { color = Overlap(dc, sc); SetPixel24(dsl, color); } else { SetPixel24(dsl, sc); } } iMainImage->Bitmap->PutScanLine(y); } } } ExitOverlap(); iMainImage->Bitmap->StopScanLine(); iMainImage->LayerMask->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); } } ::RepaintColor(); return; fail: ExitOverlap(); iMainImage->Bitmap->StopScanLine(); iMainImage->LayerMask->StopScanLine(); if (bMaskArea) iMainImage->Mask->StopScanLine(); UBitmap->StopScanLine(); SBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ChangeLayer() { MainMenuForm->ExitForm(); if (bProtect) { iMainImage->ExitBackGround(0x10); iMainImage->InitBackGround(0x10); } if (PenManagerForm->acolor == 2) { iMainImage->ExitBackGround(0x20); iMainImage->InitBackGround(0x20); } if (PenManagerForm->Type == PT_WATER) { iMainImage->ExitBackGround(0x04); iMainImage->InitBackGround(0x04); } } //=========================================================================== // By kjs for Auto Repeat //=========================================================================== //--------------------------------------------------------------------------- // Private ======================== void __fastcall TMainImageForm::NormalDrawing(bool MaskBmp) { int w, h, hw, hh; int x, y; TPoint dp, sp; TUndoData *ud; w = arwindow.size.x; h = arwindow.size.y; if ((ud = Undo->Last) == NULL) return; if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(2)) goto fail; if (!ud->Mask->StartScanLineN(2)) goto fail; } else { if (!iMainImage->Bitmap->StartScanLineN(2)) goto fail; if (!ud->Bitmap->StartScanLineN(2)) goto fail; if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(2)) goto fail; } dp = Point(arwindow.s.x, arwindow.s.y); // Left - Top sp = Point(arwindow.s.x, arwindow.e.y); AR_NHADrawing(MaskBmp, w, h, dp, sp); dp = Point(arwindow.s.x - w/2, arwindow.s.y); // Right - Top sp = Point(arwindow.s.x - w/2, arwindow.e.y); AR_NHBDrawing(MaskBmp, w, h, dp, sp); dp = Point(arwindow.s.x, arwindow.e.y - h/2); // Left - Bottom sp = Point(arwindow.s.x, arwindow.s.y - h/2); AR_NHADrawing(MaskBmp, w, h, dp, sp); dp = Point(arwindow.s.x - w/2, arwindow.e.y - h/2); // Right - Bottom sp = Point(arwindow.s.x - w/2, arwindow.s.y - h/2); AR_NHBDrawing(MaskBmp, w, h, dp, sp); if (MaskBmp) { ud->Mask->StopScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); ud->Bitmap->StopScanLine(); iMainImage->Bitmap->StopScanLine(); } return; fail: if (!MaskBmp) iMainImage->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::HDHORDrawing(bool MaskBmp) { int w, h; TPoint dp, sp; TUndoData *ud; w = arwindow.size.x; h = arwindow.size.y; if ((ud = Undo->Last) == NULL) return; if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(2)) goto fail; if (!ud->Mask->StartScanLineN(2)) goto fail; } else { if (!iMainImage->Bitmap->StartScanLineN(2)) goto fail; if (!ud->Bitmap->StartScanLineN(2)) goto fail; if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(2)) goto fail; } dp = Point(arwindow.s.x, arwindow.s.y); // Left - Top sp = Point(arwindow.s.x - w/2, arwindow.e.y); AR_NHADrawing(MaskBmp, w, h, dp, sp); dp = Point(arwindow.s.x - w/2, arwindow.s.y); // Right - Top sp = Point(arwindow.s.x, arwindow.e.y); AR_NHBDrawing(MaskBmp, w, h, dp, sp); dp = Point(arwindow.s.x, arwindow.e.y - h/2); // Left - Bottom sp = Point(arwindow.s.x - w/2, arwindow.s.y - h/2); AR_NHADrawing(MaskBmp, w, h, dp, sp); dp = Point(arwindow.s.x - w/2, arwindow.e.y - h/2); // Right - Bottom sp = Point(arwindow.s.x, arwindow.s.y - h/2); AR_NHBDrawing(MaskBmp, w, h, dp, sp); if (MaskBmp) { ud->Mask->StopScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); ud->Bitmap->StopScanLine(); iMainImage->Bitmap->StopScanLine(); } return; fail: if (!MaskBmp) iMainImage->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::HDVERDrawing(bool MaskBmp) { int w, h, hh, hw; TPoint dsp, spp1, spp2, spp3; Byte *dst, *sr1, *sr2, *sr3; TUndoData *ud; hw = arwindow.size.x/2; hh = arwindow.size.y/2; if ((ud = Undo->Last) == NULL) return; if (MaskBmp) { if (!iMainImage->Mask->StartScanLineN(4)) goto fail; if (!ud->Mask->StartScanLineN(4)) goto fail; } else { if (!iMainImage->Bitmap->StartScanLineN(4)) goto fail; if (!ud->Bitmap->StartScanLineN(4)) goto fail; if (iMainImage->LayerMask) if (!iMainImage->LayerMask->StartScanLineN(4)) goto fail; } dsp = Point(arwindow.s.x, arwindow.s.y); // Left - Top spp1 = Point(arwindow.e.x, arwindow.s.y - hh); spp2 = Point(arwindow.e.x, arwindow.e.y - hh); spp3 = Point(arwindow.s.x, arwindow.e.y); AR_VDrawing(MaskBmp, hw, hh, dsp, spp1, spp2, spp3); dsp = Point(arwindow.e.x - hw, arwindow.s.y); // Right - Top spp1 = Point(arwindow.s.x - hw, arwindow.s.y - hh); spp2 = Point(arwindow.s.x - hw, arwindow.e.y - hh); spp3 = Point(arwindow.e.x - hw, arwindow.e.y); AR_VDrawing(MaskBmp, hw, hh, dsp, spp1, spp2, spp3); dsp = Point(arwindow.s.x, arwindow.e.y - hh); // Left - Bottom spp1 = Point(arwindow.s.x, arwindow.s.y - hh); spp2 = Point(arwindow.e.x, arwindow.s.y); spp3 = Point(arwindow.e.x, arwindow.e.y); AR_VDrawing(MaskBmp, hw, hh, dsp, spp1, spp2, spp3); dsp = Point(arwindow.e.x - hw, arwindow.e.y - hh); // Right - Bottom spp1 = Point(arwindow.e.x - hw, arwindow.s.y - hh); spp2 = Point(arwindow.s.x - hw, arwindow.s.y); spp3 = Point(arwindow.s.x - hw, arwindow.e.y); AR_VDrawing(MaskBmp,hw, hh, dsp, spp1, spp2, spp3); if (MaskBmp) { ud->Mask->StopScanLine(); iMainImage->Mask->StopScanLine(); } else { if (iMainImage->LayerMask) iMainImage->LayerMask->StopScanLine(); ud->Bitmap->StopScanLine(); iMainImage->Bitmap->StopScanLine(); } return; fail: if (!MaskBmp) iMainImage->Bitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- int __fastcall TMainImageForm::Comp_Value(COLORREF A, COLORREF B, COLORREF C, COLORREF D, COLORREF UA, COLORREF UB, COLORREF UC, COLORREF UD) { if ((B==C) && (C==D) && (D!=A)) { //order A, B, C, D return 1; } else if ((C==D) && (D==A) && (A!=B)) { return 2; } else if ((D==A) && (A==B) && (B!=C)) { return 3; } else if ((A==B) && (B==C) && (C!=D)) { return 4; } else { if (A==B) { if (C==D) { if (A==UA) return 3; else return 1; } else { return 3; } } else if (A==C) { if (B==D) { if (A==UA) return 2; else return 1; } else { return 2; } } else if (A==D) { if (B==C) { if (A==UA) return 2; else return 1; } else { return 2; } } else if (B==C) { if (A!=D) return 1; } else if (B==D) { if (A!=C) return 1; } else if (C==D) { if (A!=B) return 1; } } return -1; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_NHADrawing(bool Maskbmp, int w, int h, TPoint dp, TPoint spp) { int x, y, hw, hh, ux, uy; int mx, tx, umx, utx, point = 0; Byte *mp, *mp1, *tp, *tp1, *lmp, *ltp; Byte *ump, *ump1, *utp, *utp1; COLORREF mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3; TUndoData *ud; ud = Undo->Last; hw = w/2; hh = h/2; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; ux = ud->Range.left; uy = ud->Range.top; if (Maskbmp) { if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; ump = ud->Mask->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); ump = ud->Mask->GetScanLine(dp.y - uy + y); utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1); mx = dp.x; tx = spp.x; umx = dp.x-ux, utx = spp.x-ux; for (x=0; x>3))&(0x80>>(mx&7))) > 0) ? 1 : 0; //1 cv1 = ((*(mp+((mx+w)>>3))&(0x80>>((mx+w)&7))) > 0) ? 1 : 0; //2 cv2 = ((*(tp+(tx>>3))&(0x80>>(tx&7))) > 0 ) ? 1 : 0; //3 cv3 = ((*(tp+((tx+w)>>3))&(0x80>>((tx+w)&7))) > 0) ? 1 : 0; //4 umv = ((*(ump+(umx>>3))&(0x80>>(umx&7))) > 0) ? 1 : 0; ucv1 = ((*(ump+((umx+w)>>3))&(0x80>>((umx+w)&7))) > 0) ? 1 : 0; ucv2 = ((*(utp+(utx>>3))&(0x80>>(utx&7))) > 0 ) ? 1 : 0; ucv3 = ((*(utp+((utx+w)>>3))&(0x80>>((utx+w)&7))) > 0) ? 1 : 0; if (!((mv==cv1) && (cv1==cv2) && (cv2==cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { if (mv) { *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); } else { *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); } } else if (point == 2) { if (cv1) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } else if (point == 3) { if (cv2) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } else if (point == 4) { if (cv3) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+(tx>>3)) |= 0x80 >> (tx&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> ((mx)&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); } } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; yBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 2) { SetPixel24(mp, cv1); SetPixel24(tp, cv1); SetPixel24(tp1, cv1); if (*(lmp + ((dp.x+x+w)>>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp1, cv2); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp, cv3); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } } } iMainImage->Bitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; yBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_NHBDrawing(bool MaskBmp, int w, int h, TPoint dp, TPoint spp) { int x, y, hw, hh, ux, uy; int mx, tx, umx, utx, point = 0; Byte *mp, *mp1, *tp, *tp1, *lmp, *ltp; Byte *ump, *ump1, *utp, *utp1; COLORREF mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3; TUndoData *ud; ud = Undo->Last; hw = w/2; hh = h/2; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; ux = ud->Range.left; uy = ud->Range.top; if (MaskBmp) { if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; ump = ud->Mask->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); ump = ud->Mask->GetScanLine(dp.y - uy + y); utp = ud->Mask->GetScanLineN(spp.y - uy + y, 1); mx = dp.x; tx = spp.x; umx = dp.x-ux; utx = spp.x-ux; for (x=0; x>3))&(0x80>>((mx+w)&7))) > 0) ? 1 : 0; //1 cv1 = ((*(mp+(mx>>3))&(0x80>>(mx&7))) > 0) ? 1 : 0; //2 cv2 = ((*(tp+((tx+w)>>3))&(0x80>>((tx+w)&7))) > 0) ? 1 : 0; //3 cv3 = ((*(tp+(tx>>3))&(0x80>>(tx&7))) > 0 ) ? 1 : 0; //4 umv = ((*(ump+((umx+w)>>3))&(0x80>>((umx+w)&7))) > 0) ? 1 : 0; ucv1 = ((*(ump+(umx>>3))&(0x80>>(umx&7))) > 0) ? 1 : 0; ucv2 = ((*(utp+((utx+w)>>3))&(0x80>>((utx+w)&7))) > 0) ? 1 : 0; ucv3 = ((*(utp+(utx>>3))&(0x80>>(utx&7))) > 0 ) ? 1 : 0; if (!((mv == cv1) && (cv1==cv2) && (cv2==cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, ucv1, ucv2, ucv3); if (point == 1) { if (mv) { *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(mp+(mx>>3)) |= 0x80 >> (mx&7); } else { *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); } } else if (point == 2) { if (cv1) { *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); } else { *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); } } else if (point == 3) { if (cv2) { *(tp+(tx>>3)) |= 0x80 >> (tx&7); *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); } else { *(tp+(tx>>3)) &= ~(0x80 >> (tx&7)); *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); } } else if (point == 4) { if (cv3) { *(mp+(mx>>3)) |= 0x80 >> (mx&7); *(mp+((mx+w)>>3)) |= 0x80 >> ((mx+w)&7); *(tp+((tx+w)>>3)) |= 0x80 >> ((tx+w)&7); } else { *(mp+(mx>>3)) &= ~(0x80 >> (mx&7)); *(mp+((mx+w)>>3)) &= ~(0x80 >> ((mx+w)&7)); *(tp+((tx+w)>>3)) &= ~(0x80 >> ((tx+w)&7)); } } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1)+ spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + dp.x - ux; utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + spp.x - ux; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3) ) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 2) { SetPixel24(mp1, cv1); SetPixel24(tp1, cv1); SetPixel24(tp, cv1); if (*(lmp + ((dp.x+x)>>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if (point == 3) { SetPixel24(mp, cv2); SetPixel24(mp1, cv2); SetPixel24(tp, cv2); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } else if (point == 4) { SetPixel24(mp, cv3); SetPixel24(mp1, cv3); SetPixel24(tp1, cv3); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } } } iMainImage->Bitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1)+ 3*spp.x; ump = ud->Bitmap->GetScanLine(dp.y - uy + y) + 3*(dp.x-ux); utp = ud->Bitmap->GetScanLineN(spp.y - uy + y, 1) + 3*(spp.x-ux); for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_VDrawing(bool MaskBmp, int hw, int hh, TPoint dsp, TPoint spp1, TPoint spp2, TPoint spp3) { int x, y, dx, s1x, s2x, s3x; int udx, us1x, us2x, us3x, ux, uy, point=0; Byte *dst, *sr1, *sr2, *sr3, *lmp, *lp1, *lp2, *lp3; Byte *mdst, *msr1, *msr2, *msr3, *uds, *ur1, *ur2, *ur3; COLORREF mv, cv1, cv2, cv3, umv, uv1, uv2, uv3; TUndoData *ud; ud = Undo->Last; // ux = arwindow.s.x - hw; // uy = arwindow.s.y - hh; ux = ud->Range.left; uy = ud->Range.top; if (MaskBmp) { if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; yMask->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3) + spp3.x; uds = ud->Mask->GetScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = ud->Mask->GetScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = ud->Mask->GetScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = ud->Mask->GetScanLineN(spp3.y - uy + y, 3) + spp3.x - ux; for (x=0; xMask->PutScanLine(dsp.y + y); iMainImage->Mask->PutScanLineN(spp1.y + y, 1); iMainImage->Mask->PutScanLineN(spp2.y + y, 2); iMainImage->Mask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yMask->GetScanLine(dsp.y + y); sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1); sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2); sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3); uds = ud->Mask->GetScanLine(dsp.y - uy + y); ur1 = ud->Mask->GetScanLineN(spp1.y - uy + y, 1); ur2 = ud->Mask->GetScanLineN(spp2.y - uy + y, 2); ur3 = ud->Mask->GetScanLineN(spp3.y - uy + y, 3); dx = dsp.x; s1x = spp1.x; s2x = spp2.x; s3x = spp3.x; udx = dsp.x-ux; us1x = spp1.x-ux; us2x = spp2.x-ux; us3x = spp3.x-ux; for (x=0; x>3)) & (0x80>>(dx&7))) > 0) ? 1 : 0; cv1 = ((*(sr1+(s1x>>3)) & (0x80>>(s1x&7))) > 0) ? 1 : 0; cv2 = ((*(sr2+(s2x>>3)) & (0x80>>(s2x&7))) > 0) ? 1 : 0; cv3 = ((*(sr3+(s3x>>3)) & (0x80>>(s3x&7))) > 0) ? 1 : 0; umv = ((*(uds+(udx>>3)) & (0x80>>(udx&7))) > 0) ? 1 : 0; uv1 = ((*(ur1+(us1x>>3)) & (0x80>>(us1x&7))) > 0) ? 1 : 0; uv2 = ((*(ur2+(us2x>>3)) & (0x80>>(us2x&7))) > 0) ? 1 : 0; uv3 = ((*(ur3+(us3x>>3)) & (0x80>>(us3x&7))) > 0) ? 1 : 0; if (!((mv==cv1) && (cv1==cv2) && (cv2==cv3))) { point = Comp_Value(mv, cv1, cv2, cv3, umv, uv1, uv2, uv3); if (point == 1) { if (mv) { *(sr1+(s1x>>3)) |= 0x80 >> (s1x&7); *(sr2+(s2x>>3)) |= 0x80 >> (s2x&7); *(sr3+(s3x>>3)) |= 0x80 >> (s3x&7); } else { *(sr1+(s1x>>3)) &= ~(0x80 >> (s1x&7)); *(sr2+(s2x>>3)) &= ~(0x80 >> (s2x&7)); *(sr3+(s3x>>3)) &= ~(0x80 >> (s3x&7)); } } else if (point == 2) { if (cv1) { *(dst+(dx>>3)) |= 0x80 >> (dx&7); *(sr2+(s2x>>3)) |= 0x80 >> (s2x&7); *(sr3+(s3x>>3)) |= 0x80 >> (s3x&7); } else { *(dst+(dx>>3)) &= ~(0x80 >> (dx&7)); *(sr2+(s2x>>3)) &= ~(0x80 >> (s2x&7)); *(sr3+(s3x>>3)) &= ~(0x80 >> (s3x&7)); } } else if (point == 3) { if (cv2) { *(dst+(dx>>3)) |= 0x80 >> (dx&7); *(sr1+(s1x>>3)) |= 0x80 >> (s1x&7); *(sr3+(s3x>>3)) |= 0x80 >> (s3x&7); } else { *(dst+(dx>>3)) &= ~(0x80 >> (dx&7)); *(sr1+(s1x>>3)) &= ~(0x80 >> (s1x&7)); *(sr3+(s3x>>3)) &= ~(0x80 >> (s3x&7)); } } else if (point == 4) { if (cv3) { *(dst+(dx>>3)) |= 0x80 >> (dx&7); *(sr1+(s1x>>3)) |= 0x80 >> (s1x&7); *(sr2+(s2x>>3)) |= 0x80 >> (s2x&7); } else { *(dst+(dx>>3)) &= ~(0x80 >> (dx&7)); *(sr1+(s1x>>3)) &= ~(0x80 >> (s1x&7)); *(sr2+(s2x>>3)) &= ~(0x80 >> (s2x&7)); } } } } iMainImage->Mask->PutScanLine(dsp.y + y); iMainImage->Mask->PutScanLineN(spp1.y + y, 1); iMainImage->Mask->PutScanLineN(spp2.y + y, 2); iMainImage->Mask->PutScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; yBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; uds = ud->Bitmap->GetScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = ud->Bitmap->GetScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = ud->Bitmap->GetScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = ud->Bitmap->GetScanLineN(spp3.y - uy + y, 3) + spp3.x - ux; lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y) + dsp.x; lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1) + spp1.x; lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2) + spp2.x; lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xBitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutScanLine(dsp.y + y); iMainImage->LayerMask->PutScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; uds = ud->Bitmap->GetScanLine(dsp.y - uy + y) + dsp.x - ux; ur1 = ud->Bitmap->GetScanLineN(spp1.y - uy + y, 1) + spp1.x - ux; ur2 = ud->Bitmap->GetScanLineN(spp2.y - uy + y, 2) + spp2.x - ux; ur3 = ud->Bitmap->GetScanLineN(spp3.y - uy + y, 3) + spp3.x - ux; for (x=0; xBitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->LayerMask) { for (y=0; yBitmap->GetScanLine(dsp.y + y) + 3*dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + 3*spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + 3*spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + 3*spp3.x; uds = ud->Bitmap->GetScanLine(dsp.y - uy + y) + 3*(dsp.x - ux); ur1 = ud->Bitmap->GetScanLineN(spp1.y - uy + y, 1) + 3*(spp1.x - ux); ur2 = ud->Bitmap->GetScanLineN(spp2.y - uy + y, 2) + 3*(spp2.x - ux); ur3 = ud->Bitmap->GetScanLineN(spp3.y - uy + y, 3) + 3*(spp3.x - ux); lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y); lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1); lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2); lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3); for (x=0; x>3)) & (0x80 >> ((dsp.x+x)&7))) { *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else if (point == 2) { SetPixel24(dst, cv1); SetPixel24(sr2, cv1); SetPixel24(sr3, cv1); if (*(lp1 + ((spp1.x+x)>>3)) & (0x80 >> ((spp1.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else if (point == 3) { SetPixel24(dst, cv2); SetPixel24(sr1, cv2); SetPixel24(sr3, cv2); if (*(lp2 + ((spp2.x+x)>>3)) & (0x80 >> ((spp2.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else if (point == 4) { SetPixel24(dst, cv3); SetPixel24(sr1, cv3); SetPixel24(sr2, cv3); if (*(lp3 + ((spp3.x+x)>>3)) & (0x80 >> ((spp3.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); } } } } iMainImage->Bitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutScanLine(dsp.y + y); iMainImage->LayerMask->PutScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yBitmap->GetScanLine(dsp.y + y) + 3*dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + 3*spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + 3*spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + 3*spp3.x; uds = ud->Bitmap->GetScanLine(dsp.y - uy + y) + 3*(dsp.x - ux); ur1 = ud->Bitmap->GetScanLineN(spp1.y - uy + y, 1) + 3*(spp1.x - ux); ur2 = ud->Bitmap->GetScanLineN(spp2.y - uy + y, 2) + 3*(spp2.x - ux); ur3 = ud->Bitmap->GetScanLineN(spp3.y - uy + y, 3) + 3*(spp3.x - ux); for (x=0; xBitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); } } } } } //--------------------------------------------------------------------------- //Public ======================== void __fastcall TMainImageForm::AutoRepUpdateMenu(bool bExitForm) { if ( bExitForm) { MainMenuForm->ARExitForm(); } else { MainMenuForm->AutoRepUpdateItem(); } } /* void __fastcall TMainImageForm::AutoRepUpdateMenu(bool bAutoRep, bool bExitForm) { if ( bExitForm) { MainMenuForm->ARExitForm(bExitForm); //get out in autorepeat } else { if (bAutoRep) MainMenuForm->AutoRepUpdateItem(); // autorepeat is true, but get out repeat else MainMenuForm->ARExitForm(bExitForm); //be repeat form } } */ //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbAutoRepViewClick(TObject *Sender) { #ifndef ACADEMY if (AutoRepeat) { if (sbAutoRepView->Down) { AutoRepViewForm = new TAutoRepViewForm(NULL); AutoRepViewForm->Parent = MainForm; AutoRepViewForm->Visible = true; } else { ARViewExitForm(); } } #endif } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::ARViewExitForm() { #ifndef ACADEMY if (AutoRepViewForm) { AutoRepViewForm->WriteIniFile(); ::doDestroy(AutoRepViewForm); //Error } sbAutoRepView->Down = false; #endif } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::RedrawingRepeat(bool MaskBmp, bool repaint, bool Draw) { POINT sp, ep; HRGN rgn = NULL; if (Draw) { //========================================= Delete WorkArea for BitBlt if (WorkArea->Mask) { //¾î´À ¼±Åà ¿µ¿ªÀÌ ÀÖÀ¸¸é ±× ºÎºÐ¸¸ BitBlt°¡ µÈ´Ù. WorkArea->ResetRegion(iMainImage, &rgn); } //========================================== if (ARTItem == AREPEAT_NORMAL) { //Normal NormalDrawing(MaskBmp); } else if (ARTItem == AREPEAT_HDVER) { //Half Drop Ver. HDVERDrawing(MaskBmp); } else if (ARTItem == AREPEAT_HDHOR) { //Half Drop Hor. HDHORDrawing(MaskBmp); } if (rgn) { WorkArea->SetRegion(rgn); DeleteObject(rgn); } } if (repaint) iMainImage->Repaint(); #ifndef ACADEMY if (AutoRepViewForm) AutoRepViewForm->ReDrawImage(); #endif } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::DrawARepeatArea(TObject *Sender, HDC hDC, int X, int Y) { TPItemImage *Image = (TPItemImage *)Sender; int sx, sy, ex, ey; HBRUSH hOldBrush; COLORREF clOldBk; HPEN hPen, hOldPen; sx = Image->BitmapToCanvasX(arwindow.s.x) - X; sy = Image->BitmapToCanvasY(arwindow.s.y) - Y; ex = Image->BitmapToCanvasX(arwindow.e.x) - X; ey = Image->BitmapToCanvasY(arwindow.e.y) - Y; hOldBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH)); clOldBk = SetBkColor(hDC, clWhite); hPen = CreatePen(PS_DASHDOT, 1, clBlack); hOldPen = SelectObject(hDC, hPen); Rectangle(hDC, sx, sy, ex, ey); SelectObject(hDC, hOldPen); DeleteObject(hPen); SetBkColor(hDC, clOldBk); SelectObject(hDC, hOldBrush); } //--------------------------------------------------------------------------- RECT __fastcall TMainImageForm::AutoRep_UndoRect(RECT rt) { RECT art, rect; art = Rect(arwindow.s.x - arwindow.size.x/2, arwindow.s.y - arwindow.size.y/2, arwindow.e.x + arwindow.size.x/2, arwindow.e.y + arwindow.size.y/2); UnionRect(&rect, &rt, &art); return rect; } //--------------------------------------------------------------------- void __fastcall TMainImageForm::RegionMouseDown(int X, int Y) { TransformRegionKind = RegionMethod(X, Y); if (TransformRegionKind) { bRegionDown = true; region = WorkArea->Range; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::RegionMouseMove(int X, int Y) { TPItemImage *Image = MainImageForm->iMainImage; Image->SetCrossPos(Point(X, Y)); int hw, hh; TSize size; if (bRegionDown) { if (bRegionDraw) DrawRectangleLocate(region); if (TransformRegionKind == 5) { size.cx = WorkArea->Range.right - WorkArea->Range.left; size.cy = WorkArea->Range.bottom - WorkArea->Range.top; hw = size.cx / 2.0; hh = size.cy / 2.0; region.left = X - hw; if (region.left < 0) region.left = 0; if (region.left + size.cx > iMainImage->Bitmap->Width) region.left = iMainImage->Bitmap->Width - size.cx; region.right = region.left + size.cx; region.top = Y - hh; if (region.top < 0) region.top = 0; if (region.top + size.cy > iMainImage->Bitmap->Height) region.top = iMainImage->Bitmap->Height - size.cy; region.bottom = region.top + size.cy; } else { switch (TransformRegionKind) { case 1: region.left = X; region.top = Y; break; case 2: region.right = X + 1; region.top = Y; break; case 3: region.left = X; region.bottom = Y + 1; break; case 4: region.right = X + 1; region.bottom = Y + 1; } } DrawRectangleLocate(region); bRegionDraw = true; } int kind = RegionMethod(X, Y); if (kind == 5) iMainImage->Cursor = crHandPoint; else if (kind && kind < 5) iMainImage->Cursor = crCross; else iMainImage->Cursor = crDefault; } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::RegionMouseUp(int X, int Y) { if (bRegionDown) { if (bRegionDraw) DrawRectangleLocate(region); WorkArea->Transform(region); bRegionDown = false; bRegionDraw = false; DrawRectangleLocate(region,0); ::RepaintImage(); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::RegionChange() { bRegionDown = false; bRegionDraw = false; DrawRectangleLocate(region,0); TransformRegionKind = 0; iMainImage->Repaint(); } //--------------------------------------------------------------------------- int __fastcall TMainImageForm::RegionMethod(int X, int Y) { RECT r = WorkArea->Range; if (bRegionDown == false) { if (X > r.left - 5 && X < r.left + 5) { if (Y > r.top - 5 && Y < r.top + 5) return 1; else if (Y > r.bottom - 5 && Y < r.bottom + 5) return 3; } else if (X > r.right - 5 && X < r.right + 5) { if (Y > r.top - 5 && Y < r.top + 5) return 2; else if (Y > r.bottom - 5 && Y < r.bottom + 5) return 4; } else if (PtInRect(&r, Point(X, Y))) return 5; } return 0; } //--------------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////// // Gauze 8 ////////////////////////////////////////////////////////////////////////////// void __fastcall TMainImageForm::Merge_Mask_Protect_TempMask_Gauze8(TTexpiaBitmap *Bitmap , int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (Palette->ColorData[*PP]->Protect == 0 && *MM == 0) { if (*TM == 0) { if (*PP > 1) { if ((x+y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Protect_Gauze8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (Palette->ColorData[*PP]->Protect == 0 && *MM == 0) { if (*PP > 1) { if ((x+y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Gauze8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (*MM == 0) { if (*TM == 0) { if (*PP > 1) { if ((x+y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Gauze8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++, MM++) { if (*MM == 0) { if (*PP > 1) { if ((x+y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_TempMask_Gauze8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++) { if (Palette->ColorData[*PP]->Protect == 0) { if (*TM == 0) { if (*PP > 1) { if ((x+y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_Gauze8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++) { if (Palette->ColorData[*PP]->Protect == 0) { if (*PP > 1) { if ((x+y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Gauze8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++) { if (*TM == 0) { if (*PP > 1) { if ((x+y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Gauze8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++) { if (*PP > 1) { if ((x+y) & 1) { *DP = *PP; *MP = 0xFF; } else { *DP = *TB; *MP = 0; } } else { *DP = *TB; *MP = 0; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- // Gauze 24 void __fastcall TMainImageForm::Merge_Mask_Temp8_TempMask_Gauze24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, *MM, mm; int x, y, w, h; COLORREF tc, cc, bgc; RGBQUAD rgb[256]; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if (((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) && Palette->ColorData[*PP]->Protect == 0) { if (*TM == 0) { GetPixel24(PP, cc); tc = RGBToTColor(rgb[*TB]); if (cc != bgc) { if ((x+y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { SetPixel24(DP, tc); } } else { SetPixel24(DP, tc); } } else { CopyPixel24(DP, PP); *MP |= mm; } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TM++; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Temp8_Gauze24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *MM, mm; int x, y, w, h; COLORREF tc, cc, bgc; RGBQUAD rgb[256]; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { GetPixel24(PP, cc); tc = RGBToTColor(rgb[*TB]); if (cc != bgc) { if ((x+y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { SetPixel24(DP, tc); } } else { SetPixel24(DP, tc); } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_TempMask_Gauze24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, mm; int x, y, w, h; COLORREF tc, cc, bgc; RGBQUAD rgb[256]; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; x = 0; mm = 0x80; *MP = 0; while (1) { if (*TM == 0) { GetPixel24(PP, cc); tc = RGBToTColor(rgb[*TB]); if (cc != bgc) { if ((x+y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { SetPixel24(DP, tc); } } else { SetPixel24(DP, tc); } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TM++; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_Gauze24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, mm; int x, y, w, h; COLORREF tc, cc, bgc; RGBQUAD rgb[256]; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; x = 0; mm = 0x80; *MP = 0; while (1) { GetPixel24(PP, cc); tc = RGBToTColor(rgb[*TB]); if (cc != bgc) { if ((x+y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { SetPixel24(DP, tc); } } else { SetPixel24(DP, tc); } x++; if (x >= w) break; PP+=3; DP+=3; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Gauze24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *TM, *MM, mm; int x, y, w, h; COLORREF cc, bgc; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { if ((*TM & mm) == 0) { GetPixel24(PP, cc); if (cc != bgc) { if ((x+y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, PP); *MP |= mm; } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TB+=3; if (mm == 1) { TM++; MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Gauze24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *MM, mm; int x, y, w, h; COLORREF cc, bgc; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { GetPixel24(PP, cc); if (cc != bgc) { if ((x+y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TB+=3; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Gauze24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *TM, mm; int x, y, w, h; COLORREF cc, bgc; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; x = 0; mm = 0x80; *MP = 0; while (1) { if ((*TM & mm) == 0) { GetPixel24(PP, cc); if (cc != bgc) { if ((x+y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TB+=3; if (mm == 1) { TM++; MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Gauze24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, mm; int x, y, w, h; COLORREF cc, bgc; bgc = Palette->ColorData[1]->Color; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; x = 0; mm = 0x80; *MP = 0; while (1) { GetPixel24(PP, cc); if (cc != bgc) { if ((x+y) & 1) { CopyPixel24(DP, PP); *MP |= mm; } else { CopyPixel24(DP, TB); } } else { CopyPixel24(DP, TB); } x++; if (x >= w) break; PP+=3; DP+=3; TB+=3; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } } //--------------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////// // Default 8 ///////////////////////////////////////////////////////////////////////////// void __fastcall TMainImageForm::Merge_Mask_Protect_TempMask_Default8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (Palette->ColorData[*PP]->Protect == 0 && *MM == 0) { if (*TM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Protect_Default8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (Palette->ColorData[*PP]->Protect == 0 && *MM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Default8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++, MM++) { if (*MM == 0) { if (*TM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Default8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *MM; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; MM = iMainImage->Mask->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++, MM++) { if (*MM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_TempMask_Default8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++) { if (Palette->ColorData[*PP]->Protect == 0) { if (*TM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Protect_Default8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, MP++) { if (Palette->ColorData[*PP]->Protect == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Default8(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + px; for (x = 0; x < w; x++, PP++, DP++, TB++, TM++, MP++) { if (*TM == 0) { *DP = *TB; *MP = 0; } else { *DP = *PP; *MP = 0xFF; } } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Default8(int px, int py) { Byte *TB, *DP, *MP; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); for (x = 0; x < w; x++, DP++, TB++, MP++) { *DP = *TB; *MP = 0; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- // Default 24 void __fastcall TMainImageForm::Merge_Mask_Temp8_TempMask_Default24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *MM, *PP, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if (((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) && Palette->ColorData[*PP]->Protect == 0) { if (*TM == 0) { tc = RGBToTColor(rgb[*TB]); SetPixel24(DP, tc); } else { CopyPixel24(DP, PP); *MP |= mm; } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TM++; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Temp8_Default24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *MM, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { tc = RGBToTColor(rgb[*TB]); SetPixel24(DP, tc); } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_TempMask_Default24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *TM, *DP, *MP, *PP, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; x = 0; mm = 0x80; *MP = 0; while (1) { if (*TM == 0) { tc = RGBToTColor(rgb[*TB]); SetPixel24(DP, tc); } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TM++; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Temp8_Default24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; TempBitmap->GetColors(0, 256, rgb); for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; x = 0; mm = 0x80; *MP = 0; while (1) { tc = RGBToTColor(rgb[*TB]); SetPixel24(DP, tc); x++; if (x >= w) break; PP+=3; DP+=3; TB++; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubMask->PutScanLine(y); iMainImage->SubBitmap->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_TempMask_Default24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *TM, *MM, mm; int x, y, w, h; COLORREF tc; RGBQUAD rgb[256]; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7)))==0) { if ((*TM & mm) == 0) { CopyPixel24(DP, TB); } else { CopyPixel24(DP, PP); *MP |= mm; } } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TB+=3; if (mm == 1) { TM++; MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Mask_Default24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *MM, mm; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; MM = iMainImage->Mask->GetScanLine(y + py); x = 0; mm = 0x80; *MP = 0; while (1) { if ((MM[(x + px) >> 3] & (0x80 >> ((x + px) & 7))) == 0) { CopyPixel24(DP, TB); } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TB+=3; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_TempMask_Default24(TTexpiaBitmap *Bitmap, int px, int py) { Byte *TB, *DP, *MP, *PP, *TM, mm; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); TM = TempMask->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); PP = Bitmap->GetScanLine(y + py) + 3*px; x = 0; mm = 0x80; *MP = 0; while (1) { if ((*TM & mm) == 0) { CopyPixel24(DP, TB); } else { CopyPixel24(DP, PP); *MP |= mm; } x++; if (x >= w) break; PP+=3; DP+=3; TB+=3; if (mm == 1) { TM++; MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::Merge_Default24(int px, int py) { Byte *TB, *DP, *MP, mm; int x, y, w, h; w = iMainImage->SubBitmap->Width; h = iMainImage->SubBitmap->Height; for (y = 0; y < h; y++) { TB = TempBitmap->GetScanLine(y); DP = iMainImage->SubBitmap->GetScanLine(y); MP = iMainImage->SubMask->GetScanLine(y); x = 0; mm = 0x80; *MP = 0; while (1) { CopyPixel24(DP, TB); x++; if (x >= w) break; DP+=3; TB+=3; if (mm == 1) { MP++; *MP = 0; mm = 0x80; } else mm >>= 1; } iMainImage->SubBitmap->PutScanLine(y); iMainImage->SubMask->PutScanLine(y); } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::IsMerge(POINT p) { TTexpiaBitmap *Bitmap; switch (iMainImage->IsBackGround()) { case 0: Bitmap = iMainImage->Bitmap; break; case 1: Bitmap = iMainImage->BackGround; break; default : goto fail; } if (TempBitmap->StartScanLine() == false) goto fail; if (Bitmap->StartScanLine() == false) goto fail; if (iMainImage->SubBitmap->StartScanLine() == false) goto fail; if (iMainImage->SubMask->StartScanLine() == false) goto fail; if (FullViewForm->Super == sGauze) { if (TempMask) { if (TempMask->StartScanLine() == false) goto fail; if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) Merge_Mask_Protect_TempMask_Gauze8(Bitmap, p.x, p.y); else Merge_Mask_TempMask_Gauze8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Mask_Temp8_TempMask_Gauze24(Bitmap, p.x, p.y); else Merge_Mask_TempMask_Gauze24(Bitmap, p.x, p.y); } iMainImage->Mask->StopScanLine(); } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) Merge_Protect_TempMask_Gauze8(Bitmap, p.x, p.y); else Merge_TempMask_Gauze8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Temp8_TempMask_Gauze24(Bitmap, p.x, p.y); else Merge_TempMask_Gauze24(Bitmap, p.x, p.y); } } TempMask->StopScanLine(); } else { if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) Merge_Mask_Protect_Gauze8(Bitmap, p.x, p.y); else Merge_Mask_Gauze8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Mask_Temp8_Gauze24(Bitmap, p.x, p.y); else Merge_Mask_Gauze24(Bitmap, p.x, p.y); } iMainImage->Mask->StopScanLine(); } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) Merge_Protect_Gauze8(Bitmap, p.x, p.y); else Merge_Gauze8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Temp8_TempMask_Gauze24(Bitmap, p.x, p.y); else Merge_Gauze24(Bitmap, p.x, p.y); } } } } else { if (TempMask) { if (TempMask->StartScanLine() == false) goto fail; if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) Merge_Mask_Protect_TempMask_Default8(Bitmap, p.x, p.y); else Merge_Mask_TempMask_Default8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Mask_Temp8_TempMask_Default24(Bitmap, p.x, p.y); else Merge_Mask_TempMask_Default24(Bitmap, p.x, p.y); } iMainImage->Mask->StopScanLine(); } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) Merge_Protect_TempMask_Default8(Bitmap, p.x, p.y); else Merge_TempMask_Default8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Temp8_TempMask_Default24(Bitmap, p.x, p.y); else Merge_TempMask_Default24(Bitmap, p.x, p.y); } } TempMask->StopScanLine(); } else { if (bMaskArea) { if (iMainImage->Mask->StartScanLine() == false) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) Merge_Mask_Protect_Default8(Bitmap, p.x, p.y); else Merge_Mask_Default8(Bitmap, p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Mask_Temp8_Default24(Bitmap, p.x, p.y); else Merge_Mask_Default24(Bitmap, p.x, p.y); } iMainImage->Mask->StopScanLine(); } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (bProtect) Merge_Protect_Default8(Bitmap, p.x, p.y); else Merge_Default8(p.x, p.y); } else { if (TempBitmap->BitsPerPixel == 8) Merge_Temp8_Default24(Bitmap, p.x, p.y); //k3dogs <- Merge_Temp8_TempMask_Default24(Bitmap, p.x, p.y) else Merge_Default24(p.x, p.y); } } } } iMainImage->SubMask->StopScanLine(); iMainImage->SubBitmap->StopScanLine(); Bitmap->StopScanLine(); TempBitmap->StopScanLine(); return; fail: iMainImage->Mask->StopScanLine(); iMainImage->SubMask->StopScanLine(); iMainImage->SubBitmap->StopScanLine(); Bitmap->StopScanLine(); TempBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- // External Function //--------------------------------------------------------------------- void __fastcall RepaintImage() { if (MainImageForm) { MainImageForm->iMainImage->Repaint(); FullViewForm->InitForm(MainImageForm->iMainImage); #ifndef ACADEMY LayerForm->InitForm(); #endif } } //--------------------------------------------------------------------- void __fastcall RepaintColor() { RGBQUAD rgb[256]; if (MainImageForm) { if (MainImageForm->iMainImage->Bitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); MainImageForm->iMainImage->ChangeRGBColors(rgb); } MainImageForm->iMainImage->Repaint(); FullViewForm->InitForm(MainImageForm->iMainImage); PaletteForm->InitForm(MainImageForm->Palette); #ifndef ACADEMY LayerForm->InitForm(); #endif PenManagerForm->SetColor(MainImageForm->Palette); ColorLibraryForm->View(); #ifndef ACADEMY if (MainImageForm->AutoRepeat) { if (AutoRepViewForm) AutoRepViewForm->ReDrawImage(); } #endif } } //--------------------------------------------------------------------------- /* void __fastcall TMainImageForm::AR_NHADrawing(bool Maskbmp, int w, int h, TPoint dp, TPoint spp) { int x, y, hw, hh; int mx, tx; Byte *mp, *tp, *pp, *cp1, *cp2, *cp3, *lmp, *ltp, *mmp, *tmmp; COLORREF mv, cv1, cv2, cv3; hw = w/2; hh = h/2; if (Maskbmp) { if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); mx = dp.x; tx = spp.x; for (x=0; x>3]&(0x80>>((mx+w)&7))) > 0) == ((tp[tx>>3]&(0x80>>(tx&7))) > 0)) && (((tp[tx>>3]&(0x80>>(tx&7))) > 0 ) == ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0)) && (((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0) != ((mp[mx>>3]&(0x80>>(mx&7))) > 0))) { if (mp[mx>>3] & (0x80 >> (mx&7))) { mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); tp[tx>>3] |= 0x80 >> (tx&7); } else { mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); tp[tx>>3] &= ~(0x80 >> (tx&7)); } } else if ((((tp[tx>>3]&(0x80>>(tx&7))) > 0) == ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0)) && (((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0) == ((mp[mx>>3]&(0x80>>(mx&7))) > 0)) && (((mp[mx>>3] & (0x80>>(mx&7))) > 0) != ((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) > 0))) { if (mp[(mx+w)>>3] & (0x80 >> ((mx+w)&7))) { mp[mx>>3] |= 0x80 >> (mx&7); tp[tx>>3] |= 0x80 >> (tx&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); } else { mp[mx>>3] &= ~(0x80 >> (mx&7)); tp[tx>>3] &= ~(0x80 >> (tx&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); } } else if ((((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0) == ((mp[mx>>3]&(0x80>>(mx&7))) > 0)) && (((mp[mx>>3] & (0x80>>(mx&7))) > 0) == ((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) > 0)) && (((mp[(mx>+w)>3]&(0x80>>((mx+w)&7))) > 0) != ((tp[tx>>3]&(0x80>>(tx&7))) > 0))) { if (tp[tx>>3] & (0x80 >> (tx&7))) { mp[mx>>3] |= 0x80 >> (mx&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); } else { mp[mx>>3] &= ~(0x80 >> (mx&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); } } else if ((((mp[mx>>3] & (0x80>>(mx&7))) > 0) == ((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) > 0)) && (((mp[(mx>+w)>3]&(0x80>>((mx+w)&7))) > 0) == ((tp[tx>>3]&(0x80>>(tx&7))) > 0)) && (((tp[tx>>3]&(0x80>>(tx&7))) > 0)!= ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0))) { if (tp[(tx+w)>>3] & (0x80 >> ((tx+w)&7))) { mp[mx>>3] |= 0x80 >> (mx&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); tp[tx>>3] |= 0x80 >> (tx&7); } else { mp[(mx)>>3] &= ~(0x80 >> ((mx)&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); tp[tx>>3] &= ~(0x80 >> (tx&7)); } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; yBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if ((cv2 == cv3) && (cv3 == mv) && (mv != cv1)) { SetPixel24(pp, cv1); SetPixel24(cp2, cv1); SetPixel24(cp3, cv1); if (*(lmp + ((dp.x+x+w)>>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if ((cv3 == mv) && (mv == cv1) && (cv1 != cv2)) { SetPixel24(pp, cv2); SetPixel24(cp1, cv2); SetPixel24(cp3, cv2); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if ((mv == cv1) && (cv1 == cv2) && (cv2 != cv3)) { SetPixel24(pp, cv3); SetPixel24(cp1, cv3); SetPixel24(cp2, cv3); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } } iMainImage->Bitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; yBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_NHBDrawing(bool MaskBmp, int w, int h, TPoint dp, TPoint spp) { int x, y, hw, hh; int mx, tx; Byte *mp, *tp, *pp, *cp1, *cp2, *cp3, *lmp, *ltp, *mmp, *tmmp; COLORREF mv, cv1, cv2, cv3;; hw = w/2; hh = h/2; if (MaskBmp) { if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); mx = dp.x; tx = spp.x; for (x=0; x>3]&(0x80>>(mx&7))) > 0) == ((tp[tx>>3]&(0x80>>(tx&7))) > 0)) && (((tp[tx>>3]&(0x80>>(tx&7))) > 0) == ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0)) && (((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0) != ((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) > 0))) { if (mp[(mx+w)>>3] & (0x80 >> ((mx+w)&7))) { tp[tx>>3] |= 0x80 >> (tx&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); mp[mx>>3] |= 0x80 >> (mx&7); } else { tp[tx>>3] &= ~(0x80 >> (tx&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); mp[mx>>3] &= ~(0x80 >> (mx&7)); } } else if ((((tp[tx>>3]&(0x80>>(tx&7))) > 0) == ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0)) && (((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0) == ((mp[mx>>3]&(0x80>>(mx&7))) > 0)) && (((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) > 0) != ((mp[mx>>3]&(0x80>>(mx&7))) > 0))) { if (mp[mx>>3] & (0x80 >> (mx&7))) { tp[tx>>3] |= 0x80 >> (tx&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); } else { tp[tx>>3] &= ~(0x80 >> (tx&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); } } else if ((((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0) == ((mp[mx>>3]&(0x80>>(mx&7))) > 0)) && (((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) > 0) == ((mp[mx>>3]&(0x80>>(mx&7))) > 0)) && (((mp[mx>>3]&(0x80>>(mx&7))) > 0) != ((tp[tx>>3]&(0x80>>(tx&7))) > 0))) { if (tp[tx>>3] & (0x80 >> (tx&7))) { mp[mx>>3] |= 0x80 >> (mx&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); } else { mp[mx>>3] &= ~(0x80 >> (mx&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); } } else if ((((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) > 0) == ((mp[mx>>3]&(0x80>>(mx&7))) > 0)) && (((mp[mx>>3]&(0x80>>(mx&7))) > 0) == ((tp[tx>>3]&(0x80>>(tx&7))) > 0)) && (((tp[tx>>3]&(0x80>>(tx&7))) > 0) != ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) > 0))) { if (tp[(tx+w)>>3] & (0x80 >> ((tx+w)&7))) { tp[tx>>3] |= 0x80 >> (tx&7); mp[mx>>3] |= 0x80 >> (mx&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); } else { tp[tx>>3] &= ~(0x80 >> (tx&7)); mp[mx>>3] &= ~(0x80 >> (mx&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3) ) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if ((cv2 == cv3) && (cv3 == mv) && (mv != cv1)) { SetPixel24(pp, cv1); SetPixel24(cp2, cv1); SetPixel24(cp3, cv1); if (*(lmp + ((dp.x+x)>>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if ((cv3 == mv) && (mv == cv1) && (cv1 != cv2)) { SetPixel24(pp, cv2); SetPixel24(cp1, cv2); SetPixel24(cp3, cv2); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else if ((mv == cv1) && (cv1 == cv2) && (cv2 != cv3)) { SetPixel24(pp, cv3); SetPixel24(cp1, cv3); SetPixel24(cp2, cv3); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } } iMainImage->Bitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_VDrawing(bool MaskBmp, int hw, int hh, TPoint dsp, TPoint spp1, TPoint spp2, TPoint spp3) { int x, y; int dx, s1x, s2x, s3x; Byte *dst, *sr1, *sr2, *sr3, *pp, *cp1, *cp2, *cp3, *lmp, *lp1, *lp2, *lp3; Byte *mdst, *msr1, *msr2, *msr3; COLORREF mv, cv1, cv2, cv3; if (MaskBmp) { if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; yMask->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xMask->PutScanLine(dsp.y + y); iMainImage->Mask->PutScanLineN(spp1.y + y, 1); iMainImage->Mask->PutScanLineN(spp2.y + y, 2); iMainImage->Mask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yMask->GetScanLine(dsp.y + y); sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1); sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2); sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3); dx = dsp.x; s1x = spp1.x; s2x = spp2.x; s3x = spp3.x; for (x=0; x>3] & (0x80>>(s1x&7))) > 0) == ((sr2[s2x>>3] & (0x80>>(s2x&7))) > 0)) && (((sr2[s2x>>3] & (0x80>>(s2x&7))) > 0) == ((sr3[s3x>>3] & (0x80>>(s3x&7))) > 0)) && (((sr3[s3x>>3] & (0x80>>(s3x&7))) > 0) != ((dst[dx>>3] & (0x80>>(dx&7))) > 0))) { if (dst[dx>>3] & (0x80 >> (dx&7))) { sr1[s1x>>3] |= 0x80 >> (s1x&7); sr2[s2x>>3] |= 0x80 >> (s2x&7); sr3[s3x>>3] |= 0x80 >> (s3x&7); } else { sr1[s1x>>3] &= ~(0x80 >> (s1x&7)); sr2[s2x>>3] &= ~(0x80 >> (s2x&7)); sr3[s3x>>3] &= ~(0x80 >> (s3x&7)); } } else if ((((sr2[s2x>>3] & (0x80>>(s2x&7))) > 0) == ((sr3[s3x>>3] & (0x80>>(s3x&7))) > 0)) && (((sr3[s3x>>3] & (0x80>>(s3x&7))) > 0) == ((dst[dx>>3] & (0x80>>(dx&7))) > 0)) && (((dst[dx>>3] & (0x80>>(dx&7))) > 0) != ((sr1[s1x>>3] & (0x80>>(s1x&7))) > 0))) { if (sr1[s1x>>3] & (0x80 >> (s1x&7))) { dst[dx>>3] |= 0x80 >> (dx&7); sr2[s2x>>3] |= 0x80 >> (s2x&7); sr3[s3x>>3] |= 0x80 >> (s3x&7); } else { dst[dx>>3] &= ~(0x80 >> (dx&7)); sr2[s2x>>3] &= ~(0x80 >> (s2x&7)); sr3[s3x>>3] &= ~(0x80 >> (s3x&7)); } } else if ((((sr3[s3x>>3] & (0x80>>(s3x&7))) > 0) == ((dst[dx>>3] & (0x80>>(dx&7))) > 0)) && (((dst[dx>>3] & (0x80>>(dx&7))) > 0) == ((sr1[s1x>>3] & (0x80>>(s1x&7))) > 0)) && (((sr1[s1x>>3] & (0x80>>(s1x&7))) > 0) != ((sr2[s2x>>3] & (0x80>>(s2x&7))) > 0))) { if (sr2[s2x>>3] & (0x80 >> (s2x&7))) { dst[dx>>3] |= 0x80 >> (dx&7); sr1[s1x>>3] |= 0x80 >> (s1x&7); sr3[s3x>>3] |= 0x80 >> (s3x&7); } else { dst[dx>>3] &= ~(0x80 >> (dx&7)); sr1[s1x>>3] &= ~(0x80 >> (s1x&7)); sr3[s3x>>3] &= ~(0x80 >> (s3x&7)); } } else if ((((dst[dx>>3] & (0x80>>(dx&7))) > 0) == ((sr1[s1x>>3] & (0x80>>(s1x&7))) > 0)) && (((sr1[s1x>>3] & (0x80>>(s1x&7))) > 0) == ((sr2[s2x>>3] & (0x80>>(s2x&7))) > 0)) && (((sr2[s2x>>3] & (0x80>>(s2x&7))) > 0) != ((sr3[s3x>>3] & (0x80>>(s3x&7))) > 0))) { if (sr3[s3x>>3] & (0x80 >> (s3x&7))) { dst[dx>>3] |= 0x80 >> (dx&7); sr1[s1x>>3] |= 0x80 >> (s1x&7); sr2[s2x>>3] |= 0x80 >> (s2x&7); } else { dst[dx>>3] &= ~(0x80 >> (dx&7)); sr1[s1x>>3] &= ~(0x80 >> (s1x&7)); sr2[s2x>>3] &= ~(0x80 >> (s2x&7)); } } } iMainImage->Mask->PutScanLine(dsp.y + y); iMainImage->Mask->PutScanLineN(spp1.y + y, 1); iMainImage->Mask->PutScanLineN(spp2.y + y, 2); iMainImage->Mask->PutScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; yBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y) + dsp.x; lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1) + spp1.x; lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2) + spp2.x; lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xBitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutScanLine(dsp.y + y); iMainImage->LayerMask->PutScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xBitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->LayerMask) { for (y=0; yBitmap->GetScanLine(dsp.y + y) + 3*dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + 3*spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + 3*spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + 3*spp3.x; lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y); lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1); lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2); lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3); for (x=0; x>3)) & (0x80 >> ((dsp.x+x)&7))) { *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else if ((cv2 == cv3) && (cv3 == mv) && (mv != cv1)) { SetPixel24(pp, cv1); SetPixel24(cp2, cv1); SetPixel24(cp3, cv1); if (*(lp1 + ((spp1.x+x)>>3)) & (0x80 >> ((spp1.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else if ((cv3 == mv) && (mv == cv1) && (cv1 != cv2)) { SetPixel24(pp, cv2); SetPixel24(cp1, cv2); SetPixel24(cp3, cv2); if (*(lp2 + ((spp2.x+x)>>3)) & (0x80 >> ((spp2.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else if ((mv == cv1) && (cv1 == cv2) && (cv2 != cv3)) { SetPixel24(pp, cv3); SetPixel24(cp1, cv3); SetPixel24(cp2, cv3); if (*(lp3 + ((spp3.x+x)>>3)) & (0x80 >> ((spp3.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); } } } iMainImage->Bitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutScanLine(dsp.y + y); iMainImage->LayerMask->PutScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yBitmap->GetScanLine(dsp.y + y) + 3*dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + 3*spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + 3*spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + 3*spp3.x; for (x=0; xBitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); } } } } } //--------------------------------------------------------------------------- */ //--------------------------------------------------------------------------- /* void __fastcall TMainImageForm::AR_NHADrawing(bool Maskbmp, int w, int h, TPoint dp, TPoint spp) { int x, y, hw, hh; int mx, tx; Byte *mp, *tp, *pp, *cp1, *cp2, *cp3, *lmp, *ltp, *mmp, *tmmp; COLORREF mv, cv1, cv2, cv3; hw = w/2; hh = h/2; if (Maskbmp) { if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); mx = dp.x; tx = spp.x; for (x=0; x>3] & (0x80>>((mx+w)&7))) && 1) == ((tp[tx>>3] & (0x80>>(tx&7))) && 1)) { if (((mp[(mx+w)>>3] & (0x80>>((mx+w)&7))) && 1) == ((tp[(tx+w)>>3] & (0x80>>((tx+w)&7))) && 1)) { if (mp[mx>>3] & (0x80 >> (mx&7))) { mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); tp[tx>>3] |= 0x80 >> (tx&7); } else { mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); tp[tx>>3] &= ~(0x80 >> (tx&7)); } } else { if (tp[(tx+w)>>3] & (0x80 >> ((tx+w)&7))) { mp[mx>>3] |= 0x80 >> (mx&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); tp[tx>>3] |= 0x80 >> (tx&7); } else { mp[(mx)>>3] &= ~(0x80 >> ((mx)&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); tp[tx>>3] &= ~(0x80 >> (tx&7)); } } } else { if (((mp[(mx+w)>>3] & (0x80>>((mx+w)&7))) && 1) != ((tp[(tx+w)>>3] & (0x80>>((tx+w)&7))) && 1)) { if (mp[(mx+w)>>3] & (0x80 >> ((mx+w)&7))) { mp[mx>>3] |= 0x80 >> (mx&7); tp[tx>>3] |= 0x80 >> (tx&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); } else { mp[mx>>3] &= ~(0x80 >> (mx&7)); tp[tx>>3] &= ~(0x80 >> (tx&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); } } else { if (tp[tx>>3] & (0x80 >> (tx&7))) { mp[mx>>3] |= 0x80 >> (mx&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); } else { mp[mx>>3] &= ~(0x80 >> (mx&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); } } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } } else { if (iMainImage->LayerMask) { for (y=0; yBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else { SetPixel24(pp, cv3); SetPixel24(cp1, cv3); SetPixel24(cp2, cv3); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } } else { if (cv1 != cv3) { SetPixel24(pp, cv1); SetPixel24(cp2, cv1); SetPixel24(cp3, cv1); if (*(lmp + ((dp.x+x+w)>>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else { SetPixel24(pp, cv2); SetPixel24(cp1, cv2); SetPixel24(cp3, cv2); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } } } iMainImage->Bitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; yBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_NHBDrawing(bool MaskBmp, int w, int h, TPoint dp, TPoint spp) { int x, y, hw, hh; int mx, tx; Byte *mp, *tp, *pp, *cp1, *cp2, *cp3, *lmp, *ltp, *mmp, *tmmp; COLORREF mv, cv1, cv2, cv3;; hw = w/2; hh = h/2; if (MaskBmp) { if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xMask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); mx = dp.x; tx = spp.x; for (x=0; x>3] & (0x80>>(mx&7))) && 1) == ((tp[tx>>3] & (0x80>>(tx&7))) && 1)) { if (((mp[mx>>3] & (0x80>>(mx&7))) && 1) == ((tp[(tx+w)>>3] & (0x80>>((tx+w)&7))) && 1)) { if (mp[(mx+w)>>3] & (0x80 >> ((mx+w)&7))) { tp[tx>>3] |= 0x80 >> (tx&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); mp[mx>>3] |= 0x80 >> (mx&7); } else { tp[tx>>3] &= ~(0x80 >> (tx&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); mp[mx>>3] &= ~(0x80 >> (mx&7)); } } else { if (tp[(tx+w)>>3] & (0x80 >> ((tx+w)&7))) { tp[tx>>3] |= 0x80 >> (tx&7); mp[mx>>3] |= 0x80 >> (mx&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); } else { tp[tx>>3] &= ~(0x80 >> (tx&7)); mp[mx>>3] &= ~(0x80 >> (mx&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); } } } else { if (((mp[mx>>3] & (0x80>>(mx&7))) && 1) != ((tp[(tx+w)>>3] & (0x80>>((tx+w)&7))) && 1)) { if (mp[mx>>3] & (0x80 >> (mx&7))) { tp[tx>>3] |= 0x80 >> (tx&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); } else { tp[tx>>3] &= ~(0x80 >> (tx&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); } } else { if (tp[tx>>3] & (0x80 >> (tx&7))) { mp[mx>>3] |= 0x80 >> (mx&7); mp[(mx+w)>>3] |= 0x80 >> ((mx+w)&7); tp[(tx+w)>>3] |= 0x80 >> ((tx+w)&7); } else { mp[mx>>3] &= ~(0x80 >> (mx&7)); mp[(mx+w)>>3] &= ~(0x80 >> ((mx+w)&7)); tp[(tx+w)>>3] &= ~(0x80 >> ((tx+w)&7)); } } } } iMainImage->Mask->PutScanLine(dp.y + y); iMainImage->Mask->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y) + dp.x; ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } else { if (iMainImage->LayerMask) { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; lmp = iMainImage->LayerMask->GetScanLine(dp.y + y); ltp = iMainImage->LayerMask->GetScanLineN(spp.y + y, 1); for (x=0; x>3)) & (0x80 >> ((dp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(ltp + ((spp.x+x)>>3) ) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else { SetPixel24(pp, cv3); SetPixel24(cp1, cv3); SetPixel24(cp2, cv3); if (*(ltp + ((spp.x+x+w)>>3)) & (0x80 >> ((spp.x+x+w)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); } } } else { if (cv1 != cv3) { SetPixel24(pp, cv1); SetPixel24(cp2, cv1); SetPixel24(cp3, cv1); if (*(lmp + ((dp.x+x)>>3)) & (0x80 >> ((dp.x+x)&7))) { *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) |= (0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x)>>3)) &= ~(0x80 >> ((spp.x+x)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } else { SetPixel24(pp, cv2); SetPixel24(cp1, cv2); SetPixel24(cp3, cv2); if (*(ltp + ((spp.x+x)>>3)) & (0x80 >> ((spp.x+x)&7))) { *(lmp + ((dp.x+x)>>3)) |= (0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) |= (0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) |= (0x80 >> ((spp.x+x+w)&7)); } else { *(lmp + ((dp.x+x)>>3)) &= ~(0x80 >> ((dp.x+x)&7)); *(lmp + ((dp.x+x+w)>>3)) &= ~(0x80 >> ((dp.x+x+w)&7)); *(ltp + ((spp.x+x+w)>>3)) &= ~(0x80 >> ((spp.x+x+w)&7)); } } } } iMainImage->Bitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); iMainImage->LayerMask->PutScanLine(dp.y + y); iMainImage->LayerMask->PutScanLineN(spp.y + y, 1); } } else { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; for (x=0; xBitmap->PutScanLine(dp.y + y); iMainImage->Bitmap->PutScanLineN(spp.y + y, 1); } } } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_VDrawing(bool MaskBmp, int hw, int hh, TPoint dsp, TPoint spp1, TPoint spp2, TPoint spp3) { int x, y; int dx, s1x, s2x, s3x; Byte *dst, *sr1, *sr2, *sr3, *pp, *cp1, *cp2, *cp3, *lmp, *lp1, *lp2, *lp3; Byte *mdst, *msr1, *msr2, *msr3; COLORREF mv, cv1, cv2, cv3; if (MaskBmp) { if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; yMask->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xMask->PutScanLine(dsp.y + y); iMainImage->Mask->PutScanLineN(spp1.y + y, 1); iMainImage->Mask->PutScanLineN(spp2.y + y, 2); iMainImage->Mask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yMask->GetScanLine(dsp.y + y); sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1); sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2); sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3); dx = dsp.x; s1x = spp1.x; s2x = spp2.x; s3x = spp3.x; for (x=0; x>3] & (0x80>>(s1x&7))) && 1) == ((sr2[s2x>>3] & (0x80>>(s2x&7))) && 1)) { if (((sr1[s1x>>3] & (0x80>>(s1x&7))) && 1) == ((sr3[s3x>>3] & (0x80>>(s3x&7))) && 1)) { if (dst[dx>>3] & (0x80 >> (dx&7))) { sr1[s1x>>3] |= 0x80 >> (s1x&7); sr2[s2x>>3] |= 0x80 >> (s2x&7); sr3[s3x>>3] |= 0x80 >> (s3x&7); } else { sr1[s1x>>3] &= ~(0x80 >> (s1x&7)); sr2[s2x>>3] &= ~(0x80 >> (s2x&7)); sr3[s3x>>3] &= ~(0x80 >> (s3x&7)); } } else { if (sr3[s3x>>3] & (0x80 >> (s3x&7))) { dst[dx>>3] |= 0x80 >> (dx&7); sr1[s1x>>3] |= 0x80 >> (s1x&7); sr2[s2x>>3] |= 0x80 >> (s2x&7); } else { dst[dx>>3] &= ~(0x80 >> (dx&7)); sr1[s1x>>3] &= ~(0x80 >> (s1x&7)); sr2[s2x>>3] &= ~(0x80 >> (s2x&7)); } } } else { if (((sr1[s1x>>3] & (0x80>>(s1x&7))) && 1) != ((sr3[s3x>>3] & (0x80>>(s3x&7))) && 1)) { if (sr1[s1x>>3] & (0x80 >> (s1x&7))) { dst[dx>>3] |= 0x80 >> (dx&7); sr2[s2x>>3] |= 0x80 >> (s2x&7); sr3[s3x>>3] |= 0x80 >> (s3x&7); } else { dst[dx>>3] &= ~(0x80 >> (dx&7)); sr2[s2x>>3] &= ~(0x80 >> (s2x&7)); sr3[s3x>>3] &= ~(0x80 >> (s3x&7)); } } else { if (sr2[s2x>>3] & (0x80 >> (s2x&7))) { dst[dx>>3] |= 0x80 >> (dx&7); sr1[s1x>>3] |= 0x80 >> (s1x&7); sr3[s3x>>3] |= 0x80 >> (s3x&7); } else { dst[dx>>3] &= ~(0x80 >> (dx&7)); sr1[s1x>>3] &= ~(0x80 >> (s1x&7)); sr3[s3x>>3] &= ~(0x80 >> (s3x&7)); } } } } iMainImage->Mask->PutScanLine(dsp.y + y); iMainImage->Mask->PutScanLineN(spp1.y + y, 1); iMainImage->Mask->PutScanLineN(spp2.y + y, 2); iMainImage->Mask->PutScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->Bitmap->BitsPerPixel == 8) { if (iMainImage->LayerMask) { for (y=0; yBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y) + dsp.x; lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1) + spp1.x; lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2) + spp2.x; lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xBitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutScanLine(dsp.y + y); iMainImage->LayerMask->PutScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xBitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); } } } else { if (iMainImage->LayerMask) { for (y=0; yBitmap->GetScanLine(dsp.y + y) + 3*dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + 3*spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + 3*spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + 3*spp3.x; lmp = iMainImage->LayerMask->GetScanLine(dsp.y + y); lp1 = iMainImage->LayerMask->GetScanLineN(spp1.y + y, 1); lp2 = iMainImage->LayerMask->GetScanLineN(spp2.y + y, 2); lp3 = iMainImage->LayerMask->GetScanLineN(spp3.y + y, 3); for (x=0; x>3)) & (0x80 >> ((dsp.x+x)&7))) { *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else { SetPixel24(pp, cv3); SetPixel24(cp1, cv3); SetPixel24(cp2, cv3); if (*(lp3 + ((spp3.x+x)>>3)) & (0x80 >> ((spp3.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); } } } else { if (cv1 != cv3) { SetPixel24(pp, cv1); SetPixel24(cp2, cv1); SetPixel24(cp3, cv1); if (*(lp1 + ((spp1.x+x)>>3)) & (0x80 >> ((spp1.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) |= (0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp2 + ((spp2.x+x)>>3)) &= ~(0x80 >> ((spp2.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } else{ SetPixel24(pp, cv2); SetPixel24(cp1, cv2); SetPixel24(cp3, cv2); if (*(lp2 + ((spp2.x+x)>>3)) & (0x80 >> ((spp2.x+x)&7))) { *(lmp + ((dsp.x+x)>>3)) |= (0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) |= (0x80 >> ((spp1.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) |= (0x80 >> ((spp3.x+x)&7)); } else { *(lmp + ((dsp.x+x)>>3)) &= ~(0x80 >> ((dsp.x+x)&7)); *(lp1 + ((spp1.x+x)>>3)) &= ~(0x80 >> ((spp1.x+x)&7)); *(lp3 + ((spp3.x+x)>>3)) &= ~(0x80 >> ((spp3.x+x)&7)); } } } } iMainImage->Bitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); iMainImage->LayerMask->PutScanLine(dsp.y + y); iMainImage->LayerMask->PutScanLineN(spp1.y + y, 1); iMainImage->LayerMask->PutScanLineN(spp2.y + y, 2); iMainImage->LayerMask->PutScanLineN(spp3.y + y, 3); } } else { for (y=0; yBitmap->GetScanLine(dsp.y + y) + 3*dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + 3*spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + 3*spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + 3*spp3.x; for (x=0; xBitmap->PutScanLine(dsp.y + y); iMainImage->Bitmap->PutScanLineN(spp1.y + y, 1); iMainImage->Bitmap->PutScanLineN(spp2.y + y, 2); iMainImage->Bitmap->PutScanLineN(spp3.y + y, 3); } } } } } //--------------------------------------------------------------------------- */ /* void __fastcall TMainImageForm::AR_NHADrawing(bool Maskbmp, int w, int h, TPoint dp, TPoint spp) { int x, y, hw, hh; int mx, tx; HDC MhDC = NULL, LhDC = NULL; Byte *mp, *tp, *pp, *cp1, *cp2, *cp3, *lmp, *ltp, *mmp, *tmmp; COLORREF mv, cv1, cv2, cv3; hw = w/2; hh = h/2; if (Maskbmp) { if ((LhDC = iMainImage->Mask->CreateDC()) == NULL) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; x mp[x] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); mx = dp.x; tx = spp.x; for (x=0; x>3]&(0x80>>((mx+w)&7))) == (tp[tx>>3]&(0x80>>(tx&7)))) && ((tp[tx>>3]&(0x80>>(tx&7))) == (tp[(tx+w)>>3]&(0x80>>((tx+w)&7)))) && ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) != (mp[mx>>3]&(0x80>>(mx&7))))) { BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); goto stop; } else if (((tp[tx>>3]&(0x80>>(tx&7))) == (tp[(tx+w)>>3]&(0x80>>((tx+w)&7)))) && ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) == (mp[mx>>3]&(0x80>>(mx&7)))) && ((mp[mx>>3] & (0x80>>(mx&7))) != (mp[(mx+w)>>3]&(0x80>>((mx+w)&7))))) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); goto stop; } else if (((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) == (mp[mx>>3]&(0x80>>(mx&7)))) && ((mp[mx>>3] & (0x80>>(mx&7))) == (mp[(mx+w)>>3]&(0x80>>((mx+w)&7)))) && ((mp[(mx>+w)>3]&(0x80>>((mx+w)&7))) != (tp[tx>>3]&(0x80>>(tx&7))))) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); goto stop; } else if (((mp[mx>>3] & (0x80>>(mx&7))) == (mp[(mx+w)>>3]&(0x80>>((mx+w)&7)))) && ((mp[(mx>+w)>3]&(0x80>>((mx+w)&7))) == (tp[tx>>3]&(0x80>>(tx&7)))) && ((tp[tx>>3]&(0x80>>(tx&7))) != (tp[(tx+w)>>3]&(0x80>>((tx+w)&7))))) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); goto stop; } } } } stop: iMainImage->Mask->DeleteDC(LhDC); } else { if ((MhDC = iMainImage->Bitmap->CreateDC()) == NULL) goto fail; if (iMainImage->LayerMask) if ((LhDC = iMainImage->LayerMask->CreateDC()) == NULL) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xLayerMask) { BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); } goto next; } else if ((tp[x]==tp[x+w]) && (tp[x+w]==mp[x]) && (mp[x]!=mp[x+w])) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(MhDC, spp.x, spp.y, hw, hh, MhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(MhDC, spp.x+w, spp.y, hw, hh, MhDC, dp.x+w, dp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); } goto next; } else if ((tp[x+w]==mp[x]) && (mp[x]==mp[x+w]) && (mp[x+w]!=tp[x])) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); BitBlt(MhDC, spp.x+w, spp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); } goto next; } else if ((mp[x]==mp[x+w]) && (mp[x+w]==tp[x]) && (tp[x]!=tp[x+w])) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(MhDC, spp.x, spp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); } goto next; } } } } else { for (y=0; yBitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; for (x=0; xLayerMask) { BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); } goto next; } else if ((cv2 == cv3) && (cv3 == mv) && (mv != cv1)) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(MhDC, spp.x, spp.y, hw, hh, MhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(MhDC, spp.x+w, spp.y, hw, hh, MhDC, dp.x+w, dp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); } goto next; } else if ((cv3 == mv) && (mv == cv1) && (cv1 != cv2)) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); BitBlt(MhDC, spp.x+w, spp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); } goto next; } else if ((mv == cv1) && (cv1 == cv2) && (cv2 != cv3)) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(MhDC, spp.x, spp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); } goto next; } } } } next: if (iMainImage->LayerMask) iMainImage->LayerMask->DeleteDC(LhDC); iMainImage->Bitmap->DeleteDC(MhDC); } return; fail: if (MhDC) iMainImage->Bitmap->DeleteDC(MhDC); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_NHBDrawing(bool MaskBmp, int w, int h, TPoint dp, TPoint spp) { int x, y, hw, hh; int mx, tx; HDC MhDC = NULL, LhDC = NULL; Byte *mp, *tp, *pp, *cp1, *cp2, *cp3, *lmp, *ltp, *mmp, *tmmp; COLORREF mv, cv1, cv2, cv3;; hw = w/2; hh = h/2; if (MaskBmp) { if ((LhDC = iMainImage->Mask->CreateDC()) == NULL) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; x mp[x+w] mp = iMainImage->Mask->GetScanLine(dp.y + y); tp = iMainImage->Mask->GetScanLineN(spp.y + y, 1); mx = dp.x; tx = spp.x; for (x=0; x>3]&(0x80>>(mx&7))) == (tp[tx>>3]&(0x80>>(tx&7)))) && ((tp[tx>>3]&(0x80>>(tx&7))) == (tp[(tx+w)>>3]&(0x80>>((tx+w)&7)))) && ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) != (mp[(mx+w)>>3]&(0x80>>((mx+w)&7))))) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); goto stop; } else if (((tp[tx>>3]&(0x80>>(tx&7))) == (tp[(tx+w)>>3]&(0x80>>((tx+w)&7)))) && ((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) == (mp[mx>>3]&(0x80>>(mx&7)))) && ((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) != (mp[mx>>3]&(0x80>>(mx&7))))) { BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); goto stop; } else if (((tp[(tx+w)>>3]&(0x80>>((tx+w)&7))) == (mp[mx>>3]&(0x80>>(mx&7)))) && ((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) == (mp[mx>>3]&(0x80>>(mx&7)))) && ((mp[mx>>3]&(0x80>>(mx&7))) != (tp[tx>>3]&(0x80>>(tx&7))))) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); goto stop; } else if (((mp[(mx+w)>>3]&(0x80>>((mx+w)&7))) == (mp[mx>>3]&(0x80>>(mx&7)))) && ((mp[mx>>3]&(0x80>>(mx&7))) == (tp[tx>>3]&(0x80>>(tx&7)))) && ((tp[tx>>3]&(0x80>>(tx&7))) != (tp[(tx+w)>>3]&(0x80>>((tx+w)&7))))) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); goto stop; } } } } stop: iMainImage->Mask->DeleteDC(LhDC); } else { if ((MhDC = iMainImage->Bitmap->CreateDC()) == NULL) goto fail; if (iMainImage->LayerMask) if ((LhDC = iMainImage->LayerMask->CreateDC()) == NULL) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + spp.x; for (x=0; xLayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); } goto next; } else if ((tp[x] == tp[x+w]) && (tp[x+w] == mp[x+w]) && (mp[x+w] != mp[x])) { BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, dp.x, dp.y, SRCCOPY); BitBlt(MhDC, spp.x, spp.y, hw, hh, MhDC, dp.x, dp.y, SRCCOPY); BitBlt(MhDC, spp.x+w, spp.y, hw, hh, MhDC, dp.x, dp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); } goto next; } else if ((tp[x+w] == mp[x+w]) && (mp[x+w] == mp[x]) && (mp[x] != tp[x])) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); BitBlt(MhDC, spp.x+w, spp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); } goto next; } else if ((mp[x+w] == mp[x]) && (mp[x] == tp[x]) && (tp[x] != tp[x+w])) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(MhDC, spp.x, spp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); } goto next; } } } } else { for (y=0; y mp[x+w] mp = iMainImage->Bitmap->GetScanLine(dp.y + y) + 3*dp.x; tp = iMainImage->Bitmap->GetScanLineN(spp.y + y, 1) + 3*spp.x; for (x=0; xLayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x+w, dp.y, SRCCOPY); } goto next; } else if ((cv2 == cv3) && (cv3 == mv) &&(mv != cv1)) { BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, dp.x, dp.y, SRCCOPY); BitBlt(MhDC, spp.x, spp.y, hw, hh, MhDC, dp.x, dp.y, SRCCOPY); BitBlt(MhDC, spp.x+w, spp.y, hw, hh, MhDC, dp.x, dp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, dp.x, dp.y, SRCCOPY); } goto next; } else if ((cv3 == mv) && (mv == cv1) && (cv1 != cv2)) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); BitBlt(MhDC, spp.x+w, spp.y, hw, hh, MhDC, spp.x, spp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); BitBlt(LhDC, spp.x+w, spp.y, hw, hh, LhDC, spp.x, spp.y, SRCCOPY); } goto next; } else if ((mv == cv1) && (cv1 == cv2) &&(cv2 != cv3)) { BitBlt(MhDC, dp.x, dp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(MhDC, dp.x+w, dp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(MhDC, spp.x, spp.y, hw, hh, MhDC, spp.x+w, spp.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dp.x, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, dp.x+w, dp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); BitBlt(LhDC, spp.x, spp.y, hw, hh, LhDC, spp.x+w, spp.y, SRCCOPY); } goto next; } } } } next: if (iMainImage->LayerMask) iMainImage->LayerMask->DeleteDC(LhDC); iMainImage->Bitmap->DeleteDC(MhDC); } return; fail: if (MhDC) iMainImage->Bitmap->DeleteDC(MhDC); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::AR_VDrawing(bool MaskBmp, int hw, int hh, TPoint dsp, TPoint spp1, TPoint spp2, TPoint spp3) { int x, y; int dx, s1x, s2x, s3x; HDC MhDC = NULL, LhDC = NULL; Byte *dst, *sr1, *sr2, *sr3, *pp, *cp1, *cp2, *cp3, *lmp, *lp1, *lp2, *lp3; Byte *mdst, *msr1, *msr2, *msr3; COLORREF mv, cv1, cv2, cv3; if (MaskBmp) { if ((LhDC = iMainImage->Mask->CreateDC()) == NULL) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; yMask->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xMask->GetScanLine(dsp.y + y); sr1 = iMainImage->Mask->GetScanLineN(spp1.y + y, 1); sr2 = iMainImage->Mask->GetScanLineN(spp2.y + y, 2); sr3 = iMainImage->Mask->GetScanLineN(spp3.y + y, 3); dx = dsp.x; s1x = spp1.x; s2x = spp2.x; s3x = spp3.x; for (x=0; x>3] & (0x80>>(s1x&7))) == (sr2[s2x>>3] & (0x80>>(s2x&7)))) && ((sr2[s2x>>3] & (0x80>>(s2x&7))) == (sr3[s3x>>3] & (0x80>>(s3x&7)))) && ((sr3[s3x>>3] & (0x80>>(s3x&7))) != (dst[dx>>3] & (0x80>>(dx&7))))) { BitBlt(LhDC, spp1.x, spp1.y, hw, hh, LhDC, dsp.x, dsp.y, SRCCOPY); BitBlt(LhDC, spp2.x, spp2.y, hw, hh, LhDC, dsp.x, dsp.y, SRCCOPY); BitBlt(LhDC, spp3.x, spp3.y, hw, hh, LhDC, dsp.x, dsp.y, SRCCOPY); goto stop; } else if (((sr2[s2x>>3] & (0x80>>(s2x&7))) == (sr3[s3x>>3] & (0x80>>(s3x&7)))) && ((sr3[s3x>>3] & (0x80>>(s3x&7))) == (dst[dx>>3] & (0x80>>(dx&7)))) && ((dst[dx>>3] & (0x80>>(dx&7))) != (sr1[s1x>>3] & (0x80>>(s1x&7))))) { BitBlt(LhDC, dsp.x, dsp.y, hw, hh, LhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(LhDC, spp2.x, spp2.y, hw, hh, LhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(LhDC, spp3.x, spp3.y, hw, hh, LhDC, spp1.x, spp1.y, SRCCOPY); goto stop; } else if (((sr3[s3x>>3] & (0x80>>(s3x&7))) == (dst[dx>>3] & (0x80>>(dx&7)))) && ((dst[dx>>3] & (0x80>>(dx&7))) == (sr1[s1x>>3] & (0x80>>(s1x&7)))) && ((sr1[s1x>>3] & (0x80>>(s1x&7))) != (sr2[s2x>>3] & (0x80>>(s2x&7))))) { BitBlt(LhDC, dsp.x, dsp.y, hw, hh, LhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(LhDC, spp1.x, spp1.y, hw, hh, LhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(LhDC, spp3.x, spp3.y, hw, hh, LhDC, spp2.x, spp2.y, SRCCOPY); goto stop; } else if (((dst[dx>>3] & (0x80>>(dx&7))) == (sr1[s1x>>3] & (0x80>>(s1x&7)))) && ((sr1[s1x>>3] & (0x80>>(s1x&7))) == (sr2[s2x>>3] & (0x80>>(s2x&7)))) && ((sr2[s2x>>3] & (0x80>>(s2x&7))) != (sr3[s3x>>3] & (0x80>>(s3x&7))))) { BitBlt(LhDC, spp1.x, spp1.y, hw, hh, LhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(LhDC, spp2.x, spp2.y, hw, hh, LhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(LhDC, dsp.x, dsp.y, hw, hh, LhDC, spp3.x, spp3.y, SRCCOPY); goto stop; } } } } stop: iMainImage->Mask->DeleteDC(LhDC); } else { if ((MhDC = iMainImage->Bitmap->CreateDC()) == NULL) goto fail; if (iMainImage->LayerMask) if ((LhDC = iMainImage->LayerMask->CreateDC()) == NULL) goto fail; if (iMainImage->Bitmap->BitsPerPixel == 8) { for (y=0; yBitmap->GetScanLine(dsp.y + y) + dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + spp3.x; for (x=0; xLayerMask) { BitBlt(LhDC, spp1.x, spp1.y, hw, hh, LhDC, dsp.x, dsp.y, SRCCOPY); BitBlt(LhDC, spp2.x, spp2.y, hw, hh, LhDC, dsp.x, dsp.y, SRCCOPY); BitBlt(LhDC, spp3.x, spp3.y, hw, hh, LhDC, dsp.x, dsp.y, SRCCOPY); } goto next; } else if ((sr2[x] == sr3[x]) && (sr3[x] == dst[x]) && (dst[x] != sr1[x])) { BitBlt(MhDC, dsp.x, dsp.y, hw, hh, MhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(MhDC, spp2.x, spp2.y, hw, hh, MhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(MhDC, spp3.x, spp3.y, hw, hh, MhDC, spp1.x, spp1.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dsp.x, dsp.y, hw, hh, LhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(LhDC, spp2.x, spp2.y, hw, hh, LhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(LhDC, spp3.x, spp3.y, hw, hh, LhDC, spp1.x, spp1.y, SRCCOPY); } goto next; } else if ((sr3[x] == dst[x]) && (dst[x] == sr1[x]) && (sr1[x] != sr2[x])) { BitBlt(MhDC, dsp.x, dsp.y, hw, hh, MhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(MhDC, spp1.x, spp1.y, hw, hh, MhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(MhDC, spp3.x, spp3.y, hw, hh, MhDC, spp2.x, spp2.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dsp.x, dsp.y, hw, hh, LhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(LhDC, spp1.x, spp1.y, hw, hh, LhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(LhDC, spp3.x, spp3.y, hw, hh, LhDC, spp2.x, spp2.y, SRCCOPY); } goto next; } else if ((dst[x] == sr1[x]) && (sr1[x] == sr2[x]) && (sr2[x] != sr3[x])) { BitBlt(MhDC, dsp.x, dsp.y, hw, hh, MhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(MhDC, spp1.x, spp1.y, hw, hh, MhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(MhDC, spp2.x, spp2.y, hw, hh, MhDC, spp3.x, spp3.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dsp.x, dsp.y, hw, hh, LhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(LhDC, spp1.x, spp1.y, hw, hh, LhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(LhDC, spp2.x, spp2.y, hw, hh, LhDC, spp3.x, spp3.y, SRCCOPY); } goto next; } } } } else { for (y=0; yBitmap->GetScanLine(dsp.y + y) + 3*dsp.x; sr1 = iMainImage->Bitmap->GetScanLineN(spp1.y + y, 1) + 3*spp1.x; sr2 = iMainImage->Bitmap->GetScanLineN(spp2.y + y, 2) + 3*spp2.x; sr3 = iMainImage->Bitmap->GetScanLineN(spp3.y + y, 3) + 3*spp3.x; for (x=0; xLayerMask) { BitBlt(LhDC, spp1.x, spp1.y, hw, hh, LhDC, dsp.x, dsp.y, SRCCOPY); BitBlt(LhDC, spp2.x, spp2.y, hw, hh, LhDC, dsp.x, dsp.y, SRCCOPY); BitBlt(LhDC, spp3.x, spp3.y, hw, hh, LhDC, dsp.x, dsp.y, SRCCOPY); } goto next; } else if ((cv2 == cv3) && (cv3 == mv) && (mv != cv1)) { BitBlt(MhDC, dsp.x, dsp.y, hw, hh, MhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(MhDC, spp2.x, spp2.y, hw, hh, MhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(MhDC, spp3.x, spp3.y, hw, hh, MhDC, spp1.x, spp1.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dsp.x, dsp.y, hw, hh, LhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(LhDC, spp2.x, spp2.y, hw, hh, LhDC, spp1.x, spp1.y, SRCCOPY); BitBlt(LhDC, spp3.x, spp3.y, hw, hh, LhDC, spp1.x, spp1.y, SRCCOPY); } goto next; } else if ((cv3 == mv) && (mv == cv1) && (cv1 != cv2)) { BitBlt(MhDC, dsp.x, dsp.y, hw, hh, MhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(MhDC, spp1.x, spp1.y, hw, hh, MhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(MhDC, spp3.x, spp3.y, hw, hh, MhDC, spp2.x, spp2.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dsp.x, dsp.y, hw, hh, LhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(LhDC, spp1.x, spp1.y, hw, hh, LhDC, spp2.x, spp2.y, SRCCOPY); BitBlt(LhDC, spp3.x, spp3.y, hw, hh, LhDC, spp2.x, spp2.y, SRCCOPY); } goto next; } else if ((mv == cv1) && (cv1 == cv2) && (cv2 != cv3)) { BitBlt(MhDC, dsp.x, dsp.y, hw, hh, MhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(MhDC, spp1.x, spp1.y, hw, hh, MhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(MhDC, spp2.x, spp2.y, hw, hh, MhDC, spp3.x, spp3.y, SRCCOPY); if (iMainImage->LayerMask) { BitBlt(LhDC, dsp.x, dsp.y, hw, hh, LhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(LhDC, spp1.x, spp1.y, hw, hh, LhDC, spp3.x, spp3.y, SRCCOPY); BitBlt(LhDC, spp2.x, spp2.y, hw, hh, LhDC, spp3.x, spp3.y, SRCCOPY); } goto next; } } } } next: if (iMainImage->LayerMask) iMainImage->LayerMask->DeleteDC(LhDC); iMainImage->Bitmap->DeleteDC(MhDC); } return; fail: if (MhDC) iMainImage->Bitmap->DeleteDC(MhDC); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } */ //--------------------------------------------------------------------------- void __fastcall TMainImageForm::sbCrossLineClick(TObject *Sender) { if (sbCrossLine->Down) { MainImageForm->iMainImage->Cross = true; MainImageForm->iMainImage->CrossLine = true; } else { MainImageForm->iMainImage->Cross = false; MainImageForm->iMainImage->CrossLine = false; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageKeyDown(Char &Key) //added by qe È®´ëÃà¼Ò ´ÜÃàŰ { bool IsEditMode = false; if(TextForm) IsEditMode = TextForm->Edit->Enabled; if(!((PaletteForm->PanelLibrary->Visible) || IsEditMode )){ //TextForm °ú PalletteFormÀÌ ¾Æ´Ò¶§ ½ÇÇà int Ratio = 0; if((Key == 65) || (Key == 97)){ //'a' or 'A' Key = 0; switch (iMainImage->ZoomIn) { //ÇöÀçÀÇ È®´ë, Ãà¼ÒµÈ ºñÀ²Àº ¾Ë¾Æ³»¾î case 1: switch (iMainImage->ZoomOut) { // ºñÀ²¿¡ µû¶ó ratio¶ó´Â º¯¼ö¿¡ Àû´çÇÑ °ªÀ» case 1: Ratio = 2 ; break; // ÀԷ½Ã۰í, ±×°ÍÀº parameter·Î ÇÏ´Â ÇÔ¼ö(RatioZoom) case 2: Ratio = 1; break; // ¸¦ È£ÃâÇÑ´Ù. case 4: Ratio = 12; break; case 8: Ratio = 14; break; case 16: Ratio = 18; break; } break; case 2: Ratio = 4; break; case 4: Ratio = 8; break; case 8: Ratio = 16; break; } RatioZoom(Ratio); } if((Key == 83) || (Key == 115)){ // 's' or 'S' Key = 0; switch (iMainImage->ZoomIn) { case 1: switch (iMainImage->ZoomOut) { case 1: Ratio = 12 ; break; case 2: Ratio = 14; break; case 4: Ratio = 18; break; case 8: Ratio = 116; break; } break; case 2: Ratio = 1; break; case 4: Ratio = 2; break; case 8: Ratio = 4; break; case 16 : Ratio = 8; break; } RatioZoom(Ratio); } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::RatioZoom(int r) //by qe { GetCursorPos(&ptScreen); //¸¶¿ì½º Ä¿¼­ÀÇ À§Ä¡¸¦ ÀԷ¹޴´Ù. switch (r){ //È®´ëµÉ ºñÀ² case 116 : ZoomChange(1, 16, &ptScreen); break; case 18 : ZoomChange(1, 8, &ptScreen); break; case 14 : ZoomChange(1, 4, &ptScreen); break; case 12 : ZoomChange(1, 2, &ptScreen); break; case 1 : ZoomChange(1, 1, &ptScreen); break; case 2 : ZoomChange(2, 1, &ptScreen); break; case 4 : ZoomChange(4, 1, &ptScreen); break; case 8 : ZoomChange(8, 1, &ptScreen); break; case 16 : ZoomChange(16, 1, &ptScreen); break; default : return; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::iMainImageMouseEnter(TObject *Sender) { sbCrossLineClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintPenLocate(TObject *Sender, HDC formDC,int X, int Y) { HBRUSH hOldBrush; HPEN hOldPen, hPen; int nDrawMode; int ls, rs, left, top, right, bottom; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); hPen = CreatePen(PS_SOLID, 1, clWhite); hOldPen = SelectObject(formDC, hPen); nDrawMode = GetROP2(formDC); SetROP2(formDC, R2_NOT); ls = PenManagerForm->Pen->BasicThick>>1; rs = PenManagerForm->Pen->BasicThick-ls; double ratio=iMainImage->ZoomIn/iMainImage->ZoomOut; if (PenManagerForm->Pen->BasicThick*ratio>5) { left = X-ls*ratio; top = Y-ls*ratio; right = X+rs*ratio+1; bottom = Y+rs*ratio+1; if (PenManagerForm->Pen->Shape) Rectangle(formDC, left, top, right, bottom); else Ellipse(formDC, left, top, right, bottom); } MoveToEx(formDC, X, Y-15, NULL); LineTo(formDC, X, Y+15); MoveToEx(formDC, X-15, Y, NULL); LineTo(formDC, X+15, Y); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); DeleteObject(hPen); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintLineLocate(TObject *Sender, HDC formDC) { // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; int NOL=NumberOfLine; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; POINT pt; POINT First; POINT Second; LineListData *line; for(int i=0;iItems[i]; First=line->First; Second=line->Second; pt.x = iMainImage->BitmapToCanvasX(First.x); pt.y = iMainImage->BitmapToCanvasY(First.y); MoveToEx(formDC, pt.x, pt.y, NULL); pt.x = iMainImage->BitmapToCanvasX(Second.x); pt.y = iMainImage->BitmapToCanvasY(Second.y); LineTo(formDC, pt.x, pt.y); } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void TMainImageForm::DrawLineLocate(POINT First, POINT Second, int NOL) { NumberOfLine=NOL; static RECT oldlines=Rect(0,0,0,0); LineListData *line; if(NOL==0) { // LineList->Clear(); ////// while(LineList->Count > 0){ line = (LineListData *)LineList->Last(); delete line; LineList->Remove(line); } iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); } else { iMainImage->OnPaintLocate = PaintLineLocate;/////////////////by jeegeo static int cnt = 0; if(cnt==0) { //LineList->Clear(); ////// while(LineList->Count > 0){ line = (LineListData *)LineList->Last(); delete line; LineList->Remove(line); } } line = new LineListData; cnt++; line->First=First; line->Second=Second; LineList->Add(line); if(NOL==cnt) { cnt=0; line=(LineListData *)LineList->Items[0]; int minx,miny,maxx,maxy; minx = iMainImage->BitmapToCanvasX(min( line->First.x, line->Second.x )); maxx = iMainImage->BitmapToCanvasX(max( line->First.x, line->Second.x )); miny = iMainImage->BitmapToCanvasY(min( line->First.y, line->Second.y )); maxy = iMainImage->BitmapToCanvasY(max( line->First.y, line->Second.y )); for(int i=1;iItems[i]; minx = min(minx,iMainImage->BitmapToCanvasX(min(line->First.x,line->Second.x))); maxx = max(maxx,iMainImage->BitmapToCanvasX(max(line->First.x,line->Second.x))); miny = min(miny,iMainImage->BitmapToCanvasY(min(line->First.y,line->Second.y))); maxy = max(maxy,iMainImage->BitmapToCanvasY(max(line->First.y,line->Second.y))); } RECT rc = {minx-1,miny-1,maxx+1,maxy+1}; #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #endif oldlines=rc; } } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintFreeLineLocate(TObject *Sender, HDC formDC) { // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; // int NOL=NumberOfLine; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; POINT pt; POINT First; POINT Second; LineListData *line; if(LineList->Count>0){ line=(LineListData *)LineList->Items[0]; Second=line->Second; pt.x = iMainImage->BitmapToCanvasX(Second.x); pt.y = iMainImage->BitmapToCanvasY(Second.y); MoveToEx(formDC, pt.x, pt.y, NULL); } for(int i=1;iCount;i++){ line=(LineListData *)LineList->Items[i]; First=line->First; Second=line->Second; pt.x = iMainImage->BitmapToCanvasX(First.x); pt.y = iMainImage->BitmapToCanvasY(First.y); MoveToEx(formDC, pt.x, pt.y, NULL); pt.x = iMainImage->BitmapToCanvasX(Second.x); pt.y = iMainImage->BitmapToCanvasY(Second.y); LineTo(formDC, pt.x, pt.y); } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void TMainImageForm::DrawFreeLineLocate(POINT Second, int resetCount) { LineListData *line; static RECT oldlines=Rect(0,0,0,0); static POINT First = Second; if(resetCount==0) { First=Second; // LineList->Clear(); ////// while(LineList->Count > 0){ line = (LineListData *)LineList->Last(); delete line; LineList->Remove(line); } iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); } else { iMainImage->OnPaintLocate = PaintFreeLineLocate;/////////////////by jeegeo LineListData *line; if(resetCount==-1||resetCount==-2){ line=new LineListData; line->First=First; line->Second=Second; LineList->Add(line); First=Second; } else { while(LineList->Count>resetCount){ line = (LineListData *)LineList->Last(); delete line; LineList->Remove(line); } First= ((LineListData *)LineList->Last())->Second; } line=(LineListData *)LineList->Items[0]; int minx,miny,maxx,maxy; minx = iMainImage->BitmapToCanvasX(min( line->First.x, line->Second.x )); maxx = iMainImage->BitmapToCanvasX(max( line->First.x, line->Second.x )); miny = iMainImage->BitmapToCanvasY(min( line->First.y, line->Second.y )); maxy = iMainImage->BitmapToCanvasY(max( line->First.y, line->Second.y )); for(int i=1;iCount;i++){ line=(LineListData *)LineList->Items[i]; minx = min(minx,iMainImage->BitmapToCanvasX(min(line->First.x,line->Second.x))); maxx = max(maxx,iMainImage->BitmapToCanvasX(max(line->First.x,line->Second.x))); miny = min(miny,iMainImage->BitmapToCanvasY(min(line->First.y,line->Second.y))); maxy = max(maxy,iMainImage->BitmapToCanvasY(max(line->First.y,line->Second.y))); } RECT rc = {minx-1,miny-1,maxx+1,maxy+1}; if(resetCount!=-2){ #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldlines,false); InvalidateRect(iMainImage->Parent->Handle,&rc,false); #endif } oldlines=rc; } } //--------------------------------------------------------------------------- void TMainImageForm::DrawRectangleLocate(RECT rc,int NOR) { static RECT oldrc=Rect(0,0,0,0); if(NOR==0) { iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); } else { iMainImage->OnPaintLocate = PaintRectangleLocate;/////////////////by jeegeo FloatingRect.left = iMainImage->BitmapToCanvasX(min(rc.left,rc.right)); FloatingRect.right = iMainImage->BitmapToCanvasX(max(rc.left,rc.right)); FloatingRect.top = iMainImage->BitmapToCanvasY(min(rc.top,rc.bottom)); FloatingRect.bottom = iMainImage->BitmapToCanvasY(max(rc.top,rc.bottom)); #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #endif oldrc=FloatingRect; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintRectangleLocate(TObject *Sender, HDC formDC) { RECT rc = FloatingRect; // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; Rectangle(formDC, min(rc.left, rc.right)+1, min(rc.top, rc.bottom)+1, max(rc.left, rc.right), max(rc.top, rc.bottom)); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void TMainImageForm::DrawEllipseLocate(RECT rc,int NOE) { static RECT oldrc=Rect(0,0,0,0); if(NOE==0) { iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); } else { iMainImage->OnPaintLocate = PaintEllipseLocate;/////////////////by jeegeo FloatingRect.left = iMainImage->BitmapToCanvasX(min(rc.left,rc.right)); FloatingRect.right = iMainImage->BitmapToCanvasX(max(rc.left,rc.right)); FloatingRect.top = iMainImage->BitmapToCanvasY(min(rc.top,rc.bottom)); FloatingRect.bottom = iMainImage->BitmapToCanvasY(max(rc.top,rc.bottom)); #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #endif oldrc=FloatingRect; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintEllipseLocate(TObject *Sender, HDC formDC) { RECT rc = FloatingRect; // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; Ellipse(formDC, min(rc.left, rc.right)+1, min(rc.top, rc.bottom)+1, max(rc.left, rc.right), max(rc.top, rc.bottom)); SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void TMainImageForm::DrawArcLocate(POINT center2, double LRadius2, double SRadius2, double angleS2, double angleE2, bool isFan2, bool isClosed2, int NOA) { //////isFanÀÌ trueÀ̸é fanÀ̰í falseÀ̸é tubeÀÌ´Ù center=center2; //////tube¿¡¼­´Â SRadius°¡ Æ©ºê ¾çÂÊ ³¡ÀÇ ¼±ºÐÀÇ ±æÀÌÀÌ´Ù LRadius=LRadius2; //////angleS´Â ½ÃÀæ°¢µµÀ̰í SRadius=SRadius2; //////angleE´Â ³¡°¢µµÀÌ´Ù angleS=angleS2; angleE=angleE2; isFan=isFan2; isClosed=isClosed2; RECT rc = Rect(center.x-LRadius-SRadius,center.y-LRadius-SRadius, center.x+LRadius+SRadius,center.y+LRadius+SRadius); static RECT oldrc=Rect(0,0,0,0); if(NOA==0) { iMainImage->OnPaintLocate = NULL; InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); } else { iMainImage->OnPaintLocate = PaintArcLocate;/////////////////by jeegeo FloatingRect.left = iMainImage->BitmapToCanvasX(min(rc.left,rc.right)); FloatingRect.right = iMainImage->BitmapToCanvasX(max(rc.left,rc.right)); FloatingRect.top = iMainImage->BitmapToCanvasY(min(rc.top,rc.bottom)); FloatingRect.bottom = iMainImage->BitmapToCanvasY(max(rc.top,rc.bottom)); #if defined(TEXTILE) #if defined(CARPET) InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #else #endif #else InvalidateRect(iMainImage->Parent->Handle,&oldrc,false); InvalidateRect(iMainImage->Parent->Handle,&FloatingRect,false); #endif oldrc=FloatingRect; } } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintArcLocate(TObject *Sender, HDC formDC) /////by jeegeo { RECT rc,rr; POINT p,ps,pe; // HDC formDC; HBRUSH hOldBrush; HPEN hOldPen; int nDrawMode; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); // formDC = iMainImage->Canvas->Handle; if(isFan){ rc = Rect(center.x - LRadius,center.y - LRadius, center.x + LRadius,center.y + LRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC,rr.left,rr.top,rr.right,rr.bottom,ps.x,ps.y,pe.x,pe.y); rc = Rect(center.x - SRadius,center.y - SRadius, center.x + SRadius,center.y + SRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x+cos(angleS)*SRadius,center.y-sin(angleS)*SRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x+cos(angleE)*SRadius,center.y-sin(angleE)*SRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC,rr.left,rr.top,rr.right,rr.bottom,ps.x,ps.y,pe.x,pe.y); if(isClosed) { /////////Arc¸¦ ´Ý´Â ¼±ºÐÀ» ±×¸°´Ù p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC,p.x,p.y,NULL); p = Point(center.x+cos(angleS)*SRadius,center.y-sin(angleS)*SRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); LineTo(formDC,p.x,p.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC,p.x,p.y,NULL); p = Point(center.x+cos(angleE)*SRadius,center.y-sin(angleE)*SRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); LineTo(formDC,p.x,p.y); } } else { rc = Rect(center.x - LRadius,center.y - LRadius, center.x + LRadius,center.y + LRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC,rr.left,rr.top,rr.right,rr.bottom,ps.x,ps.y,pe.x,pe.y); double midAngle=(angleS+angleE)/2.0; float ratio=(float)iMainImage->ZoomIn/(float)iMainImage->ZoomOut; POINT plus = Point(-SRadius*cos(midAngle)*ratio,SRadius*sin(midAngle)*ratio); rc = Rect(center.x - LRadius,center.y - LRadius, center.x + LRadius,center.y + LRadius); rr.left = iMainImage->BitmapToCanvasX(rc.left); rr.top = iMainImage->BitmapToCanvasY(rc.top); rr.right = iMainImage->BitmapToCanvasX(rc.right); rr.bottom = iMainImage->BitmapToCanvasY(rc.bottom); p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); ps.x = iMainImage->BitmapToCanvasX(p.x); ps.y = iMainImage->BitmapToCanvasY(p.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); pe.x = iMainImage->BitmapToCanvasX(p.x); pe.y = iMainImage->BitmapToCanvasY(p.y); Arc(formDC,rr.left+plus.x,rr.top+plus.y,rr.right+plus.x,rr.bottom+plus.y, ps.x+plus.x,ps.y+plus.y,pe.x+plus.x,pe.y+plus.y); if(isClosed) { /////////Arc¸¦ ´Ý´Â ¼±ºÐÀ» ±×¸°´Ù p = Point(center.x+cos(angleS)*LRadius,center.y-sin(angleS)*LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC,p.x,p.y,NULL); LineTo(formDC,p.x+plus.x,p.y+plus.y); p = Point(center.x+cos(angleE)*LRadius,center.y-sin(angleE)*LRadius); p.x = iMainImage->BitmapToCanvasX(p.x); p.y = iMainImage->BitmapToCanvasY(p.y); MoveToEx(formDC,p.x,p.y,NULL); LineTo(formDC,p.x+plus.x,p.y+plus.y); } } SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintCrossLine(TObject *Sender, HDC formDC) { HPEN hOldPen; HBRUSH hOldBrush; int nDrawMode; POINT cp=iMainImage->GetCrossPos(); RGBQUAD rgb; hOldBrush = SelectObject(formDC, GetStockObject(NULL_BRUSH)); nDrawMode = GetROP2(formDC); hOldPen = SelectObject(formDC, GetStockObject(BLACK_PEN)); SetROP2(formDC, R2_NOT); #ifdef WEAVE MoveToEx(formDC, cp.x, iMainImage->Parent->Top-30, NULL); LineTo(formDC, cp.x, iMainImage->Parent->Top + iMainImage->Parent->Height); MoveToEx(formDC, iMainImage->Parent->Left-30, cp.y, NULL); LineTo(formDC, iMainImage->Parent->Left + iMainImage->Parent->Width, cp.y); #else MoveToEx(formDC, cp.x, iMainImage->Parent->Top, NULL); LineTo(formDC, cp.x, iMainImage->Parent->Top + iMainImage->Parent->Height); MoveToEx(formDC, iMainImage->Parent->Left, cp.y, NULL); LineTo(formDC, iMainImage->Parent->Left + iMainImage->Parent->Width, cp.y); #endif SetROP2(formDC, nDrawMode); SelectObject(formDC, hOldBrush); SelectObject(formDC, hOldPen); } //--------------------------------------------------------------------------- void __fastcall TMainImageForm::PaintDirectly(HDC dcDst, int px, int py, int vw, int vh) { bool is3DMove = false; if (Menu3DForm) if (Menu3DForm->item == 0) is3DMove = true; if(!isPaintDirectlyClean){ if(!isFirst){ if(iMainImage->OnPaintCursor) iMainImage->OnPaintCursor(iMainImage,dcDst,Pen.x,Pen.y); if(iMainImage->OnPaintCrossLine) iMainImage->OnPaintCrossLine(iMainImage,dcDst); } if (!is3DMove) //k3dogs 3D¿¡¼­ ±×¸®µå¸¦ ±×¸®°Å³ª À̵¿½Ã¿¡ ÀÜ»ó°ú ±ô¹ÚÀÓÀÌ ¹ß»ýÇØ¼­ check if (iMainImage->OnPaintZoom) iMainImage->OnPaintZoom(iMainImage, dcDst); if(iMainImage->OnPaintLocate) iMainImage->OnPaintLocate(iMainImage, dcDst); } } //--------------------------------------------------------------------------- int __fastcall TMainImageForm::GetLineListCount(void){ return LineList->Count; } //--------------------------------------------------------------------------- void TMainImageForm::ResetDraw(bool repaint) { LineListData *line; iMainImage->OnPaintLocate=NULL; // LineList->Clear(); ////// while(LineList->Count > 0){ line = (LineListData *)LineList->Last(); delete line; LineList->Remove(line); } FloatingRect=Rect(0,0,0,0); NumberOfLine=0; center=Point(0,0); SRadius=0;LRadius=0;angleS=0;angleE=0; isClosed=false;isFan=true; if(repaint)iMainImage->Repaint(); } //---------------------------------------------------------------------------