//--------------------------------------------------------------------------- #include #include #include #pragma hdrstop #include "Jacquard.h" #include "FileManager_F.h" #include "Grouping_F.h" #include "JacPrt.h" #include "Main.h" #include "MainImage.h" #include "Palette.h" #include "StatusProgress.h" #include "Texture_F.h" #include "Undo.h" //#include "PenManager.h" //2001.6.19 by lhskys autorepeat #ifndef ACADEMY #include "UserColor_F.h" #endif //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" //--------------------------------------------------------------------------- #define IDS_JACQUARDMENU StringTable[0] #define IDS_SELECTCOLOR StringTable[1] #define IDS_TEXTURE StringTable[2] #define IDS_INAREA StringTable[3] #define IDS_EFFECT StringTable[4] #define IDS_ROTATE StringTable[5] #define IDS_ALLDELETE StringTable[6] //--------------------------------------------------------------------------- TJacquardForm *JacquardForm; typedef struct tagTJtxtData { Byte g[4]; Byte mode; char name[22]; TTexBitData *bmp; } TJtxtData; typedef struct tagTjaqdFiledata { Byte base; Byte tcnt; } TJaqdFiledata; //--------------------------------------------------------------------------- __fastcall TJacquardForm::TJacquardForm(TComponent* Owner) : TForm(Owner) { hWnd = ((TWinControl *)Owner)->Handle; //====================================================================== StringTable.Create(DirectoryItem, Language, "Jacquard"); SetSmallFont(Font); SetSmallFont(NameText->Font); Caption = IDS_JACQUARDMENU; SelectColButton->Caption = IDS_SELECTCOLOR; TextureButton->Caption = IDS_TEXTURE; AreaButton->Caption = IDS_INAREA; FileButton->Caption = IDS_COMMON_FILE; EffectButton->Caption = IDS_EFFECT; PrintButton->Caption = IDS_COMMON_PRINT; sbRotate->Hint = IDS_ROTATE; // sbAllDelete->Hint = IDS_ALLDELETE; // sbDelete->Hint = IDS_COMMON_DELETE; sbAllDelete->Caption = IDS_ALLDELETE; sbDelete->Caption = IDS_COMMON_DELETE; //====================================================================== } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FormCreate(TObject *Sender) { store = NULL; Bitmap = NULL; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FormDestroy(TObject *Sender) { int count; AnsiString str; TIniFile* JacIni = new TIniFile(DirectoryItem+"\\Jacquard.ini"); count = JacIni->ReadInteger("Count", "cnt", 0); while (count>0) { str = Format("%d", OPENARRAY(TVarRec, (count-1))); JacIni->WriteInteger(str, "Use", 0); count = count-1; } delete JacIni; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::TextureButtonClick(TObject *Sender) { TextureForm->Visible = true; Effect = false; IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo DrawGImage(); } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::SelectColButtonClick(TObject *Sender) { TextureForm->Visible = false; Effect = false; IsDraw = true; DrawGImage(); Select = 0; } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::AreaButtonClick(TObject *Sender) { TextureForm->Visible = false; Effect = false; IsDraw = true; DrawGImage(); Select = 1; } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::EffectButtonClick(TObject *Sender) { int i, ct, uc; Byte r, g, b; double h, l, s; TextureForm->Visible = false; Effect = true; IsDraw = true; Select =2; minL = 0.5; maxL = 0.5; uc = MainImageForm->Palette->UseColor; for (i=2; i<=uc; i++) { r = MainImageForm->Palette->ColorData[i]->RGB.rgbRed; g = MainImageForm->Palette->ColorData[i]->RGB.rgbGreen; b = MainImageForm->Palette->ColorData[i]->RGB.rgbBlue; RGB2HLS(r, g, b, h, l, s); if (maxLl) minL = l; } alpha = maxL-minL; delta = alpha/2; ct = delta*180; length = delta*180; LigLine(Point(ct-length-18, 0), Point(ct+length-18, 19)); diff = -0.1; } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::PrintButtonClick(TObject *Sender) { TJacPrtForm *Form = NULL; TTexpiaBitmap *Pattern = NULL; int DPI; TRect Src, Dst; TSize r; TextureForm->Visible = false; if ((Form = new TJacPrtForm(this)) == NULL) goto fail; if (Form->ShowModal()==mrOk) { if ((Pattern = new TTexpiaBitmap) == NULL) goto fail; DPI = MainImageForm->CanvasInfor.DotsPerInch; switch (Form->MethodComboBox->ItemIndex) { case 0: //No r.cx = Form->RepeatXEdit->Value; r.cy = Form->RepeatYEdit->Value; if (!ComboNoMethod(Pattern, r)) goto fail; DPI = DPI * 100 / StrToInt(Form->EditZoom->Text); break; case 1: //Yes if (!ComboYesMethod(Pattern)) goto fail; break; } SendToPrinterTP(Pattern, DPI, "Jacquard - "+MainImageForm->FileName, Form->PageEdit->Value, Form->cbMethod->ItemIndex); // convert by celberus delete Pattern; } delete Form; SelectColButton->Down = true; IsDraw = true; return; fail: if (Pattern) delete Pattern; if (Form) delete Form; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); SelectColButton->Down = true; IsDraw = true; } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::FileButtonClick(TObject *Sender) { //TFileManagerForm *Form = NULL; TextureForm->Visible = false; Effect = false; if ((FileManagerForm = new TFileManagerForm(this)) == NULL) goto fail; FileManagerForm->Extension = 1; //Jacquard¸¦ fileManager¿¡°Ô ¾Ë¸². FileManagerForm->FilterComboBox->Filter = "Texpro Jacquard File (*.jqd)|*.jqd"; FileManagerForm->OnRead = JQDOnRead; FileManagerForm->OnFileName = JQDOnFileName; if (store->Count) { FileManagerForm->OnSave = JQDOnSave; } FileManagerForm->ShowModal(); delete FileManagerForm; SelectColButton->Down = true; IsDraw = true; return; fail : EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::sbAllDeleteClick(TObject *Sender) { IniTTextureData(); } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::sbDeleteClick(TObject *Sender) { int r; PTextureData jd; if (store->Count) { r = ImgScrollBar->Position; jd = (PTextureData) store->Items[r]; store->Remove(jd); delete jd; if (store->Count==0) IniTTextureData(); else { ImgScrollBar->Max = store->Count-1; ImgScrollBar->Position = store->Count-1; if (r==store->Count) ImgChange(r-1); else ImgChange(r); } } } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::sbRotateClick(TObject *Sender) { PTextureData jd; int i; if (store->Count>0) { i = ImgScrollBar->Position; jd = (PTextureData) store->Items[i]; jd->Rot = jd->Rot+1; if (jd->Rot==4) jd->Rot = 0; ImgChange(ImgScrollBar->Position); } } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::ImgScrollBarScroll(TObject *Sender, TScrollCode ScrollCode, int &ScrollPos) { ImgChange(ScrollPos); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::GImageMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (Effect) { ImgClick = true; DrawGImage(); LigLine(Point(X-length, 0), Point(X+length, 19)); } } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::GImageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y) { if (ImgClick) MoveRectangle(X); } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::GImageMouseUp(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y) { if (ImgClick) { MoveRectangle(X); ImgClick = false; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::InitFunc(int i) { if (i==0) { SelectColButton->Enabled = true; AreaButton->Enabled = true; EffectButton->Enabled = true; } else { SelectColButton->Enabled = false; AreaButton->Enabled = false; EffectButton->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::ReadJacIni() { int i, count, J_use; AnsiString str; PTextureData jd = NULL; TIniFile* JacIni = new TIniFile(DirectoryItem+"\\Jacquard.ini"); count = JacIni->ReadInteger("Count", "cnt", 0); i = count; if (count>0) { InitFunc(0); mm = true; } else { InitFunc(1); mm = false; } while (count>0) { if ((jd = new TTextureData) == NULL) goto fail; str = Format("%d", OPENARRAY(TVarRec, (i-count))); jd->Itm = JacIni->ReadInteger(str, "Itm", 0); jd->pts = JacIni->ReadInteger(str, "pts", 0); jd->name = JacIni->ReadString(str, "Name", ""); jd->disname = JacIni->ReadString(str, "disName", ""); jd->zoom = JacIni->ReadInteger(str, "zoom", 0); jd->num = JacIni->ReadInteger(str, "num", 0); jd->Ind = JacIni->ReadInteger(str, "Ind", 0); jd->Rot = JacIni->ReadInteger(str, "Rot", 0); J_use = JacIni->ReadInteger(str, "Use", 0); // if (J_use) jd->use = true; else jd->use = false; if (J_use) jd->use = true; else {jd->use = false; j_use = false;} //2001.7.26 lhskys Jacquard ¿¡¼­ ¹«Á¶°ÇÀúÀå ¹æÁö store->Add(jd); count = count-1; } delete JacIni; if (store->Count>0) { ImgScrollBar->Enabled = true; ImgScrollBar->Max = store->Count-1; ImgScrollBar->Position = store->Count-1; ImgChange(store->Count-1); } else ImgScrollBar->Enabled = false; return; fail : EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::WriteJacIni() { int count, i, J_use; AnsiString str; PTextureData jd; TIniFile* JacIni = new TIniFile(DirectoryItem+"\\Jacquard.ini"); count = JacIni->ReadInteger("Count", "cnt", 0); if (store->CountCount; iEraseSection(str); } } JacIni->WriteInteger("Count", "cnt", store->Count); count = store->Count; while (count>0) { jd = (PTextureData) store->Items[count-1]; str = Format("%d", OPENARRAY(TVarRec, (count-1))); JacIni->WriteInteger(str, "Itm", jd->Itm); JacIni->WriteInteger(str, "pts", jd->pts); JacIni->WriteString(str, "Name", jd->name); JacIni->WriteString(str, "disName", jd->disname); JacIni->WriteInteger(str, "zoom", jd->zoom); JacIni->WriteInteger(str, "num", jd->num); JacIni->WriteInteger(str, "Ind", jd->Ind); JacIni->WriteInteger(str, "Rot", jd->Rot); if (jd->use) J_use = 1; else J_use = 0; JacIni->WriteInteger(str, "Use", J_use); count = count-1; } delete JacIni; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::IniTTextureData() { PTextureData jd; while (store->Count) { jd = (PTextureData) store->Last(); store->Remove(jd); delete jd; } ImgScrollBar->Max = 0; ImgScrollBar->Enabled = false; find = false; Clear(); NameText->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FindData(PTextureData jd) { Byte i; PTextureData cp; if (store->Count==0) return; for (i=0; iCount; i++) { cp = (PTextureData) store->Items[i]; if (cp->Itm==jd->Itm) { if (cp->pts==jd->pts) { if (cp->name==jd->name) { if (cp->disname==jd->disname) { if (cp->zoom==jd->zoom) { find = true; Sysutils::Beep(); return; } else { cp->zoom = jd->zoom; return; } } } } } } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FoundDrawData(PTextureData jd, Byte &i, Byte &n) { TFound *fd; AnsiString str1, str2; int cnt, x; TTexBitData *bip; cnt = TextureForm->Texture->f[jd->pts]->Count; for (x=0; xTexture->f[jd->pts]->Items[x]; str1 = Format("%d x %d", OPENARRAY(TVarRec, (fd->size, fd->size))); if (str1==jd->name) { i = x; break; } } fd = (TFound *) TextureForm->Texture->f[jd->pts]->Items[i]; cnt = fd->data->Count; for (x=0; xdata->Items[x]; str2 = AnsiString(bip->Name); if (str2==jd->disname) n = x; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::DerivDrawData(PTextureData jd, Byte &i, Byte &n) { TDeriv *dt; AnsiString str1, str2; int cnt, x; TTexBitData *bip; cnt = TextureForm->Texture->d[jd->pts]->Count; for (x=0; xTexture->d[jd->pts]->Items[x]; str1 = AnsiString (dt->name); if (str1==jd->name) { i = x; break; } } dt = (TDeriv *) TextureForm->Texture->d[jd->pts]->Items[i]; cnt = dt->data->Count; for (x=0; xdata->Items[x]; str2 = AnsiString (bip->Name); if (str2==jd->disname) n = x; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SpecialDrawData(PTextureData jd, Byte &i, Byte &n) { TSpecial *sp; AnsiString str1, str2; int cnt, x; TTexBitData *bip; cnt = TextureForm->Texture->s->Count; for (x=0; xTexture->s->Items[x]; str1 = AnsiString (sp->name); if (str1==jd->name) { i = x; break; } } sp = (TSpecial *) TextureForm->Texture->s->Items[i]; cnt = sp->data->Count; for (x=0; xdata->Items[x]; str2 = AnsiString (bip->Name); if (str2==jd->disname) n = x; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::ImgChange(int Pos) { Byte i, n; PTextureData jd = (PTextureData) store->Items[Pos]; switch (jd->Itm) { case 0: FoundDrawData(jd, i, n); FoundDraw(jd->pts, i, n, jd->Rot); break; case 1: DerivDrawData(jd, i, n); DerivDraw(jd->pts, i, n, jd->Rot); break; case 2: SpecialDrawData(jd, i, n); SpecialDraw(i, n, jd->Rot); break; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FoundDraw(Byte p, Byte i, Byte n, Byte Rot) { TFound *fd = (TFound *) TextureForm->Texture->f[p]->Items[i]; NameText->Caption = Format("F: <<%d>> %d x %d", OPENARRAY(TVarRec, (n+1, fd->size, fd->size))); TTexBitData *bip = (TTexBitData *) fd->data->Items[n]; DrawBitmap(bip, Rot); Image->Canvas->Draw(0, 0, Bitmap); LineDraw(bip, Rot); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::DerivDraw(Byte p, Byte i, Byte n, Byte Rot) { TDeriv *dt = (TDeriv *) TextureForm->Texture->d[p]->Items[i]; NameText->Caption = Format("D: <<%d>> %s", OPENARRAY(TVarRec, (n+1, dt->name))); TTexBitData *bip = (TTexBitData *) dt->data->Items[n]; DrawBitmap(bip, Rot); Image->Canvas->Draw(0, 0, Bitmap); LineDraw(bip, Rot); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SpecialDraw(Byte i, Byte n, Byte Rot) { TSpecial *sp = (TSpecial *) TextureForm->Texture->s->Items[i]; NameText->Caption = Format("S: <<%d>> %s", OPENARRAY(TVarRec, (n+1, sp->name))); TTexBitData *bip = (TTexBitData *) sp->data->Items[n]; DrawBitmap(bip, Rot); Image->Canvas->Draw(0, 0, Bitmap); LineDraw(bip, Rot); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::DrawBitmap(TTexBitData *bip, Byte Rot) { short x, y, j, w, rw, zr, tot, spt, zh, zw; Byte z, r; Byte *sl, *stp, *temp, *pcx, *pcy; stp = (Byte *) bip->pBitmap; pcy = stp; temp = stp; zw = bip->Width*9; zh = bip->Height*9; w = Bitmap->Width/zw; rw = Bitmap->Width%zw; if (w==0) w = 1; for (y=Bitmap->Height-1; y>=0; y--) { if ((Rot==0)||(Rot==1)) sl = (Byte *) Bitmap->ScanLine[y]; else if ((Rot==2)||(Rot==3)) sl = (Byte *) Bitmap->ScanLine[Bitmap->Height-1-y]; spt = Bitmap->Height-1-y; if ((spt%9)<9) stp = temp; if ((spt%9)==0)stp = pcy; if ((spt%zh)==0) stp = (Byte *)bip->pBitmap; for (j=0; jWidth; r++) { zr = r*9; for (z=0; z<9; z++) { tot = x+zr+z; if (tot>=Bitmap->Width) break; if ((Rot==0)||(Rot==3)) *(sl+tot) = *pcx; else if ((Rot==1)||(Rot==2)) *(sl+(Bitmap->Width-1-tot)) = *pcx; } pcx++; pcy = pcx; } } if ((Bitmap->Width>zw)&&(rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z<9; z++) { tot = (Bitmap->Width-rw)+(r*9)+z; if (tot>=Bitmap->Width) break; if ((Rot==0)||(Rot==3)) *(sl+tot) = *pcx; else if ((Rot==1)||(Rot==2)) *(sl+(Bitmap->Width-1-tot)) = *pcx; } pcx++; } } } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::LineDraw(TTexBitData *bip, Byte Rot) { int w, h, i, j, vj; w = bip->Width*9; h = bip->Height*9; switch (Rot) { case 0: case 3: for (i=0; iWidth; i++) { if ((i%9)==0) { Image->Canvas->Pen->Color = clBlue; if ((i%w)==0) Image->Canvas->Pen->Color = clRed; Image->Canvas->MoveTo(i, 0); Image->Canvas->LineTo(i, Bitmap->Height); } } break; case 1: case 2: for (i=Bitmap->Width-1; i>=0; i--) { if (((Bitmap->Width-i-1)%9)==0) { Image->Canvas->Pen->Color = clBlue; if (((Bitmap->Width-1-i)%w)==0) Image->Canvas->Pen->Color = clRed; Image->Canvas->MoveTo(i, 0); Image->Canvas->LineTo(i, Bitmap->Height); } } break; } switch (Rot) { case 0: case 1: for (j=Bitmap->Height-1; j>=0; j--) { vj = Bitmap->Height-1-j; if ((vj%9)==0) { Image->Canvas->Pen->Color = clBlue; if ((vj%h)==0) Image->Canvas->Pen->Color = clRed; Image->Canvas->MoveTo(0, j+1); Image->Canvas->LineTo(Bitmap->Width, j+1); } } break; case 2: case 3: for (j=0; jHeight; j++) { if ((j%9)==0) { Image->Canvas->Pen->Color = clBlue; if ((j%h)==0) Image->Canvas->Pen->Color = clRed; Image->Canvas->MoveTo(0, j); Image->Canvas->LineTo(Bitmap->Width, j); } } break; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::Clear() { NameText->Caption = ""; Image->Canvas->Brush->Color = clWhite; Image->Canvas->FillRect(Rect(0, 0, Image->Width, Image->Height)); InitFunc(1); DrawGImage(); mm = false; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::DrawGImage() { PChar sl; int x, y, xx, i; GImage->Picture->Bitmap->PixelFormat = pf24bit; GImage->Picture->Bitmap->Width = 181; GImage->Picture->Bitmap->Height = 20; GImage->Canvas->Pen->Color = clAqua; for (y=0; y<20; y++) { sl = (char*) GImage->Picture->Bitmap->ScanLine[y]; for (x=0; x<=180; x++) { xx = x*3; i = 255*x/180; *(sl+xx) = i; *(sl+xx+1) = i; *(sl+xx+2) = i; } } GImage->Repaint(); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SetPaletteColor() { Byte i, uc, r, g, b; double h, l, s; uc = U_Col; if ((uc*2)<=251) { for (i=2; i<=uc; i++) { r = MainImageForm->Palette->ColorData[i]->RGB.rgbRed; g = MainImageForm->Palette->ColorData[i]->RGB.rgbGreen; b = MainImageForm->Palette->ColorData[i]->RGB.rgbBlue; RGB2HLS(r, g, b, h, l, s); l = l+diff; if (l<0.0) l = 0.0; if (l>1.0) l = 1.0; MainImageForm->Palette->HLS2RGB(i-1+uc, h, l, s); } } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::LigLine(TPoint sp, TPoint ep) { GImage->Canvas->MoveTo(sp.x, sp.y); GImage->Canvas->LineTo(sp.x, ep.y); GImage->Canvas->LineTo(ep.x, ep.y); GImage->Canvas->LineTo(ep.x, sp.y); GImage->Canvas->LineTo(sp.x, sp.y); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::MoveRectangle(int X) { double center; DrawGImage(); if (X>180) X = 180; if (X<0) X =0; LigLine(Point(X-length, 0), Point(X+length, 19)); center = (double) X/180; diff = center-delta; if (draw) SetPaletteColor(); ::RepaintColor(); } //--------------------------------------------------------------------------- bool __fastcall TJacquardForm::FillRead(Byte *p, int x) { return *(p+x)==FillColor; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FillSave(Byte *p, int x) { *(p+x) = 0xFF; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SelectColorFill() { TRect Rect; TCursor Cursor = Screen->Cursor; Screen->Cursor = crHourGlass; StatusProgress->Maximum = 4; MainImageForm->iMainImage->uBitmap->FloodFill(First, FillRead, FillSave, Rect); StatusProgress->Position = 2; MainFill(Rect, 0); StatusProgress->Position = 3; StatusProgress->Position = 4; ClientHeight = 223; // Because of an unknown error... Screen->Cursor = Cursor; StatusProgress->End(); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::AreaFill() { RECT r; TCursor Cursor = Screen->Cursor; Screen->Cursor = crHourGlass; if (MainImageForm->WorkArea->Mask) { r = MainImageForm->WorkArea->Range; MainFill(Rect(r.left, r.top, r.right, r.bottom), 1); } else { MainFill(Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height), 0); } ClientHeight = 223; // Because of an unknown error... Screen->Cursor = Cursor; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::EffectFill() { int uc; RECT r; TCursor Cursor = Screen->Cursor; Screen->Cursor = crHourGlass; uc = MainImageForm->Palette->UseColor; if ((uc*2) < 252) { SetPaletteColor(); if (MainImageForm->WorkArea->Mask) { r = MainImageForm->WorkArea->Range; MainFill(Rect(r.left, r.top, r.right, r.bottom), 3); } else { MainFill(Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height), 2); } ClientHeight = 223; // Because of an unknown error...; sep = true; } else { EXCEPTION_MESSAGE_OK(EC_COLOR_OVERFLOW); sep = false; } Screen->Cursor = Cursor; return; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::MainFill(TRect Rect, Byte code) { TFound *fd; TDeriv *dt; TSpecial *sp; PTextureData jd; TTexBitData *bip; int pos; Byte zo, Rot, i, n; pos = ImgScrollBar->Position; jd = (PTextureData)store->Items[pos]; switch (jd->Itm) { case 0: FoundDrawData(jd, i, n); fd = (TFound *) TextureForm->Texture->f[jd->pts]->Items[i]; bip = (TTexBitData *) fd->data->Items[n]; break; case 1: DerivDrawData(jd, i, n); dt = (TDeriv *)TextureForm->Texture->d[jd->pts]->Items[i]; bip = (TTexBitData *) dt->data->Items[n]; break; case 2: SpecialDrawData(jd, i, n); sp = (TSpecial *) TextureForm->Texture->s->Items[i]; bip = (TTexBitData *) sp->data->Items[n]; break; } zo = jd->zoom; Rot = jd->Rot; switch (code) { case 0: SubFill(bip, Rect, zo, Rot); break; //Use in case of Select_Color & WA_RECT .. case 1: SubIRREFill(bip, Rect, zo, Rot); break; case 2: SubNONEEffect (bip, Rect, zo, Rot); break; case 3: SubIRREEffect (bip, Rect, zo, Rot); break; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubFill(TTexBitData *bip, TRect Rect, Byte zo, Byte Rot) { int x, y, j, w, rw, zr, tot, spt, zh, zw; Byte z, r, id; Byte *sl, *ul; THistoryData *ud; //by linuxjun For Undo_Method Byte *stp, *temp, *pcx, *pcy, *lp; int Width, RL, TB, ec, www, hhh; /* if(MainImageForm->AutoRepeat){ //2001.6.22 by lhskys autorepeat Rect.Left = MainImageForm->arwindow.s.x; Rect.Top = MainImageForm->arwindow.s.y; Rect.Right = MainImageForm->arwindow.e.x; Rect.Bottom = MainImageForm->arwindow.e.y; }*/ ///* BeConverted by linuxjun Don't Forget!! Undo_Method if (Select==0) id = 0xFF; else id = FillColor; stp = (Byte*) bip->pBitmap; pcy = stp; temp = stp; Width = Rect.Right-Rect.Left; Height = Rect.Bottom-Rect.Top; RL = Rect.Right+Rect.Left; TB = Rect.Top+Rect.Bottom; zw = bip->Width*zo; zh = bip->Height*zo; w = Width / zw; rw = Width % zw; if (w==0) w = 1; // if ((ud = Undo->Last)==NULL) { ec = EC_UNDO_NONE; goto fail; } if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_UNDO_NONE; goto fail; } //by linuxjun // www = ud->uBitmap->Width; // hhh = ud->uBitmap->Height; PartialUndoBitmap = ud->uBitmap; //1 PartialUndoBitmap->PartialUndo->LoadLast(ud->FromRgb); //2 // www = ud->uBitmap->Width; // hhh = ud->uBitmap->Height; if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!PartialUndoBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=Rect.Bottom-1; y>=Rect.Top; y--) { switch (Rot) { case 0: case 1: sl = (Byte *)MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *)PartialUndoBitmap->GetUndoScanLine(y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(y); break; case 2: case 3: sl = (Byte *)MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *)PartialUndoBitmap->GetUndoScanLine(TB-1-y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(TB-1-y); break; } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(sl+tot)==id) { if (*pcx==1) { *(sl+tot) = ColIndex; lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } else { if (*(sl+(RL-1-tot))==id) { if ((*pcx)==1) { *(sl+(RL-1-tot)) = ColIndex; lp[RL-1-tot] = 0; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(sl+tot)==id) { if (*pcx==1) { *(sl+tot) = ColIndex; lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } else { if (*(sl+(RL-tot))==id) { if (*pcx==1) { *(sl+(RL-tot)) = ColIndex; lp[RL-tot] = 0; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); MainImageForm->iMainImage->LayerMask->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); MainImageForm->iMainImage->LayerMask->PutScanLine(TB-1-y); break; } } MainImageForm->iMainImage->LayerMask->StopScanLine(); } else { for (y=Rect.Bottom-1; y>=Rect.Top; y--) { switch (Rot) { case 0: case 1: sl = (Byte *)MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *)PartialUndoBitmap->GetUndoScanLine(y); break; case 2: case 3: sl = (Byte *)MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *)PartialUndoBitmap->GetUndoScanLine(TB-1-y); break; } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(sl+tot)==id) { if (*pcx==1) { *(sl+tot) = ColIndex; } else *(sl+tot) = *(ul+tot); } } else { if (*(sl+(RL-1-tot))==id) { if ((*pcx)==1) { *(sl+(RL-1-tot)) = ColIndex; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(sl+tot)==id) { if (*pcx==1) { *(sl+tot) = ColIndex; } else *(sl+tot) = *(ul+tot); } } else { if (*(sl+(RL-tot))==id) { if (*pcx==1) { *(sl+(RL-tot)) = ColIndex; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); break; } } } PartialUndoBitmap->StopUndoScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); // ud->Complete(); return; fail: PartialUndoBitmap->StopUndoScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubIRREFill(TTexBitData *bip, TRect Rect, Byte zo, Byte Rot) { int x, y, j, w, rw, zr, tot, spt, zh, zw; Byte z, r; Byte *sl, *ul, *ml, *lp; THistoryData *ud; //by linuxjun Undo_Method Byte *stp, *temp, *pcx, *pcy; int Width, RL, TB, ec; /* if(MainImageForm->AutoRepeat){ //2001.6.22 by lhskys autorepeat Rect.Left = MainImageForm->arwindow.s.x; Rect.Top = MainImageForm->arwindow.s.y; Rect.Right = MainImageForm->arwindow.e.x; Rect.Bottom = MainImageForm->arwindow.e.y; }*/ ///* BeConverted by linuxjun Don't Forget!! Undo_Method stp = (Byte *) bip->pBitmap; pcy = stp; temp = stp; Width = Rect.Right-Rect.Left; Height = Rect.Bottom-Rect.Top; RL = Rect.Right+Rect.Left; TB = Rect.Top+Rect.Bottom; zw = bip->Width*zo; zh = bip->Height*zo; w = Width / zw; rw = Width % zw; if (w==0) w = 1; if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_UNDO_NONE; goto fail; } PartialUndoBitmap = ud->uBitmap; //1 PartialUndoBitmap->PartialUndo->LoadLast(ud->FromRgb); //2 if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!PartialUndoBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) || (Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(y-Rect.Top); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(y); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(TB-1-y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(Rect.Bottom-1-y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(TB-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) ||(Rot==3)) { if (*(ml+tot-Rect.Left)) { if (*(sl+tot)==FillColor) { if (*pcx==1) { *(sl+tot) = ColIndex; lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } } else { if (*(ml+Rect.Right-1-tot)) { if (*(sl+(RL-1-tot))==FillColor) { if (*pcx==1) { *(sl+(RL-1-tot)) = ColIndex; lp[RL-1-tot] = 0; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if((Rot==0) ||(Rot==3)) { if (*(ml+tot-Rect.Left)) { if (*(sl+tot)==FillColor) { if (*pcx==1) { *(sl+tot) = ColIndex; lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } } else { if (*(ml+Rect.Right-1-tot)) { if (*(sl+(RL-tot))==FillColor) { if (*pcx==1) { *(sl+(RL-tot)) = ColIndex; lp[RL-tot] = 0; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); MainImageForm->iMainImage->LayerMask->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); MainImageForm->iMainImage->LayerMask->PutScanLine(TB-1-y); break; } } MainImageForm->iMainImage->LayerMask->StopScanLine(); } else { for (y=Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) || (Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(y-Rect.Top); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(TB-1-y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(Rect.Bottom-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) ||(Rot==3)) { if (*(ml+tot-Rect.Left)) { if (*(sl+tot)==FillColor) { if (*pcx==1) { *(sl+tot) = ColIndex; } else *(sl+tot) = *(ul+tot); } } } else { if (*(ml+Rect.Right-1-tot)) { if (*(sl+(RL-1-tot))==FillColor) { if (*pcx==1) { *(sl+(RL-1-tot)) = ColIndex; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if((Rot==0) ||(Rot==3)) { if (*(ml+tot-Rect.Left)) { if (*(sl+tot)==FillColor) { if (*pcx==1) { *(sl+tot) = ColIndex; } else *(sl+tot) = *(ul+tot); } } } else { if (*(ml+Rect.Right-1-tot)) { if (*(sl+(RL-tot))==FillColor) { if (*pcx==1) { *(sl+(RL-tot)) = ColIndex; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); break; } } } PartialUndoBitmap->StopUndoScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); // ud->Complete(); return; fail: PartialUndoBitmap->StopUndoScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); //*/ /* BeConverted by linuxjun Don't Forget!! Undo_Method stp = (Byte *) bip->pBitmap; pcy = stp; temp = stp; Width = Rect.Right-Rect.Left; Height = Rect.Bottom-Rect.Top; RL = Rect.Right+Rect.Left; TB = Rect.Top+Rect.Bottom; zw = bip->Width*zo; zh = bip->Height*zo; w = Width / zw; rw = Width % zw; if (w==0) w = 1; if ((ud = Undo->Last)==NULL) { ec = EC_UNDO_NONE; goto fail; } if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!ud->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y=Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) || (Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) ud->Bitmap->GetScanLine(y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(y-Rect.Top); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(y); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) ud->Bitmap->GetScanLine(TB-1-y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(Rect.Bottom-1-y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(TB-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) ||(Rot==3)) { if (*(ml+tot-Rect.Left)) { if (*(sl+tot)==FillColor) { if (*pcx==1) { *(sl+tot) = ColIndex; lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } } else { if (*(ml+Rect.Right-1-tot)) { if (*(sl+(RL-1-tot))==FillColor) { if (*pcx==1) { *(sl+(RL-1-tot)) = ColIndex; lp[RL-1-tot] = 0; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if((Rot==0) ||(Rot==3)) { if (*(ml+tot-Rect.Left)) { if (*(sl+tot)==FillColor) { if (*pcx==1) { *(sl+tot) = ColIndex; lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } } else { if (*(ml+Rect.Right-1-tot)) { if (*(sl+(RL-tot))==FillColor) { if (*pcx==1) { *(sl+(RL-tot)) = ColIndex; lp[RL-tot] = 0; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); MainImageForm->iMainImage->LayerMask->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); MainImageForm->iMainImage->LayerMask->PutScanLine(TB-1-y); break; } } MainImageForm->iMainImage->LayerMask->StopScanLine(); } else { for (y=Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) || (Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) ud->Bitmap->GetScanLine(y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(y-Rect.Top); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) ud->Bitmap->GetScanLine(TB-1-y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(Rect.Bottom-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) ||(Rot==3)) { if (*(ml+tot-Rect.Left)) { if (*(sl+tot)==FillColor) { if (*pcx==1) { *(sl+tot) = ColIndex; } else *(sl+tot) = *(ul+tot); } } } else { if (*(ml+Rect.Right-1-tot)) { if (*(sl+(RL-1-tot))==FillColor) { if (*pcx==1) { *(sl+(RL-1-tot)) = ColIndex; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if((Rot==0) ||(Rot==3)) { if (*(ml+tot-Rect.Left)) { if (*(sl+tot)==FillColor) { if (*pcx==1) { *(sl+tot) = ColIndex; } else *(sl+tot) = *(ul+tot); } } } else { if (*(ml+Rect.Right-1-tot)) { if (*(sl+(RL-tot))==FillColor) { if (*pcx==1) { *(sl+(RL-tot)) = ColIndex; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); break; } } } ud->Bitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); ud->Complete(); return; fail: ud->Bitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); */ } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubNONEEffect(TTexBitData *bip, TRect Rect, Byte zo, Byte Rot) { int x, y, j, w, rw, zr, tot, spt, zh, zw, uc; Byte z, r; Byte *sl, *ul, *lp; THistoryData *ud; //by linuxjun Undo_Method Byte *stp, *temp, *pcx, *pcy; int RL, TB, ec; /* if(MainImageForm->AutoRepeat){ //2001.6.22 by lhskys autorepeat Rect.Left = MainImageForm->arwindow.s.x; Rect.Top = MainImageForm->arwindow.s.y; Rect.Right = MainImageForm->arwindow.e.x; Rect.Bottom = MainImageForm->arwindow.e.y; }*/ ///* BeConverted by linuxjun Don't Forget!! Undo_Method stp = (Byte *) bip->pBitmap; pcy = stp; temp = stp; RL = Rect.Right+Rect.Left; TB = Rect.Top+Rect.Bottom; zw = bip->Width*zo; zh = bip->Height*zo; w = (Rect.Right-Rect.Left) / zw; rw = (Rect.Right-Rect.Left) % zw; if (w==0) w = 1; if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_UNDO_NONE; goto fail; } PartialUndoBitmap = ud->uBitmap; //1 PartialUndoBitmap->PartialUndo->LoadLast(ud->FromRgb); //2 uc = MainImageForm->Palette->UseColor; if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!PartialUndoBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y= Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) ||(Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(y); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(TB-1-y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(TB-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } else { if ((*(sl+(RL-1-tot))==0) || (*(sl+(RL-1-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-1-tot)) = uc-1+*(sl+(RL-1-tot)); lp[RL-1-tot] = 0; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } else { if ((*(sl+(RL-tot))==0) || (*(sl+(RL-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-tot)) = uc-1+*(sl+(RL-tot)); lp[RL-tot] = 0; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); MainImageForm->iMainImage->LayerMask->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); MainImageForm->iMainImage->LayerMask->PutScanLine(TB-1-y); break; } } MainImageForm->iMainImage->LayerMask->StopScanLine(); } else { for (y= Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) ||(Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(y); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(TB-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); } else *(sl+tot) = *(ul+tot); } else { if ((*(sl+(RL-1-tot))==0) || (*(sl+(RL-1-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-1-tot)) = uc-1+*(sl+(RL-1-tot)); } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); } else *(sl+tot) = *(ul+tot); } else { if ((*(sl+(RL-tot))==0) || (*(sl+(RL-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-tot)) = uc-1+*(sl+(RL-tot)); } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); break; } } } PartialUndoBitmap->StopUndoScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); // ud->Complete(); return; fail: PartialUndoBitmap->StopUndoScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); /* BeConverted by linuxjun Don't Forget!! Undo_Method stp = (Byte *) bip->pBitmap; pcy = stp; temp = stp; RL = Rect.Right+Rect.Left; TB = Rect.Top+Rect.Bottom; zw = bip->Width*zo; zh = bip->Height*zo; w = (Rect.Right-Rect.Left) / zw; rw = (Rect.Right-Rect.Left) % zw; if (w==0) w = 1; if ((ud = Undo->Last)==NULL) { ec = EC_UNDO_NONE; goto fail; } uc = MainImageForm->Palette->UseColor; if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!ud->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y= Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) ||(Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) ud->Bitmap->GetScanLine(y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(y); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) ud->Bitmap->GetScanLine(TB-1-y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(TB-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } else { if ((*(sl+(RL-1-tot))==0) || (*(sl+(RL-1-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-1-tot)) = uc-1+*(sl+(RL-1-tot)); lp[RL-1-tot] = 0; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } else { if ((*(sl+(RL-tot))==0) || (*(sl+(RL-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-tot)) = uc-1+*(sl+(RL-tot)); lp[RL-tot] = 0; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); MainImageForm->iMainImage->LayerMask->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); MainImageForm->iMainImage->LayerMask->PutScanLine(TB-1-y); break; } } MainImageForm->iMainImage->LayerMask->StopScanLine(); } else { for (y= Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) ||(Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) ud->Bitmap->GetScanLine(y); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) ud->Bitmap->GetScanLine(TB-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); } else *(sl+tot) = *(ul+tot); } else { if ((*(sl+(RL-1-tot))==0) || (*(sl+(RL-1-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-1-tot)) = uc-1+*(sl+(RL-1-tot)); } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); } else *(sl+tot) = *(ul+tot); } else { if ((*(sl+(RL-tot))==0) || (*(sl+(RL-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-tot)) = uc-1+*(sl+(RL-tot)); } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); break; } } } ud->Bitmap->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); ud->Complete(); return; fail: ud->Bitmap->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); */ } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubIRREEffect(TTexBitData *bip, TRect Rect, Byte zo, Byte Rot) { int x, y, j, w, rw, zr, tot, spt, zh, zw, uc; Byte z, r; Byte *sl, *ul, *ml, *lp; THistoryData *ud; //by linuxjun Undo_Method Byte *stp, *temp, *pcx, *pcy; int Width, RL, TB, ec; /* if(MainImageForm->AutoRepeat){ //2001.6.22 by lhskys autorepeat Rect.Left = MainImageForm->arwindow.s.x; Rect.Top = MainImageForm->arwindow.s.y; Rect.Right = MainImageForm->arwindow.e.x; Rect.Bottom = MainImageForm->arwindow.e.y; }*/ ///* BeConverted by linuxjun Don't Forget!! Undo_Method stp = (Byte *) bip->pBitmap; pcy = stp; temp = stp; Width = Rect.Right-Rect.Left; Height = Rect.Bottom-Rect.Top; RL = Rect.Right+Rect.Left; TB = Rect.Top+Rect.Bottom; zw = bip->Width*zo; zh = bip->Height*zo; w = (Rect.Right-Rect.Left) / zw; rw = (Rect.Right-Rect.Left) % zw; if (w==0) w = 1; if ((ud = MainImageForm->Undo->GetLast())==NULL) { ec = EC_UNDO_NONE; goto fail; } PartialUndoBitmap = ud->uBitmap; //1 PartialUndoBitmap->PartialUndo->LoadLast(ud->FromRgb); //2 uc = MainImageForm->Palette->UseColor; if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!PartialUndoBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y= Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) ||(Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(y-Rect.Top); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(y); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(TB-1-y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(Rect.Bottom-y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(TB-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(ml+tot-Rect.Left)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } else { if (*(ml+Rect.Right-1-tot)) { if ((*(sl+(RL-1-tot))==0) || (*(sl+(RL-1-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-1-tot)) = uc-1+*(sl+(RL-1-tot)); lp[RL-1-tot] = 0; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(ml+tot-Rect.Left)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } else { if (*(ml+Rect.Right-1-tot)) { if ((*(sl+(RL-tot))==0) || (*(sl+(RL-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-tot)) = uc-1+*(sl+(RL-tot)); lp[RL-tot]; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); MainImageForm->iMainImage->LayerMask->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); MainImageForm->iMainImage->LayerMask->PutScanLine(TB-1-y); break; } } MainImageForm->iMainImage->LayerMask->StopScanLine(); } else { for (y= Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) ||(Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(y-Rect.Top); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) PartialUndoBitmap->GetUndoScanLine(TB-1-y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(Rect.Bottom-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(ml+tot-Rect.Left)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); } else *(sl+tot) = *(ul+tot); } } else { if (*(ml+Rect.Right-1-tot)) { if ((*(sl+(RL-1-tot))==0) || (*(sl+(RL-1-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-1-tot)) = uc-1+*(sl+(RL-1-tot)); } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(ml+tot-Rect.Left)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); } else *(sl+tot) = *(ul+tot); } } else { if (*(ml+Rect.Right-1-tot)) { if ((*(sl+(RL-tot))==0) || (*(sl+(RL-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-tot)) = uc-1+*(sl+(RL-tot)); } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); break; } } } PartialUndoBitmap->StopUndoScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); // ud->Complete(); return; fail: PartialUndoBitmap->StopUndoScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); /* BeConverted by linuxjun Don't Forget!! Undo_Method stp = (Byte *) bip->pBitmap; pcy = stp; temp = stp; Width = Rect.Right-Rect.Left; Height = Rect.Bottom-Rect.Top; RL = Rect.Right+Rect.Left; TB = Rect.Top+Rect.Bottom; zw = bip->Width*zo; zh = bip->Height*zo; w = (Rect.Right-Rect.Left) / zw; rw = (Rect.Right-Rect.Left) % zw; if (w==0) w = 1; if ((ud = Undo->Last)==NULL) { ec = EC_UNDO_NONE; goto fail; } uc = MainImageForm->Palette->UseColor; if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (!ud->Bitmap->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; goto fail; } for (y= Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) ||(Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) ud->Bitmap->GetScanLine(y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(y-Rect.Top); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(y); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) ud->Bitmap->GetScanLine(TB-1-y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(Rect.Bottom-y); lp = MainImageForm->iMainImage->LayerMask->GetScanLine(TB-1-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(ml+tot-Rect.Left)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } else { if (*(ml+Rect.Right-1-tot)) { if ((*(sl+(RL-1-tot))==0) || (*(sl+(RL-1-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-1-tot)) = uc-1+*(sl+(RL-1-tot)); lp[RL-1-tot] = 0; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(ml+tot-Rect.Left)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); lp[tot] = 0; } else *(sl+tot) = *(ul+tot); } } else { if (*(ml+Rect.Right-1-tot)) { if ((*(sl+(RL-tot))==0) || (*(sl+(RL-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-tot)) = uc-1+*(sl+(RL-tot)); lp[RL-tot]; } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); MainImageForm->iMainImage->LayerMask->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); MainImageForm->iMainImage->LayerMask->PutScanLine(TB-1-y); break; } } MainImageForm->iMainImage->LayerMask->StopScanLine(); } else { for (y= Rect.Bottom-1; y>=Rect.Top; y--) { if ((Rot==0) ||(Rot==1)) { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(y); ul = (Byte *) ud->Bitmap->GetScanLine(y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(y-Rect.Top); } else { sl = (Byte *) MainImageForm->iMainImage->uBitmap->GetScanLine(TB-1-y); ul = (Byte *) ud->Bitmap->GetScanLine(TB-1-y); ml = (Byte *) MainImageForm->WorkArea->Mask->GetScanLine(Rect.Bottom-y); } spt = Rect.Bottom-1-y; if ((spt % zo)pBitmap; for (j=0; jWidth; r++) { zr = r*zo; for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(ml+tot-Rect.Left)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); } else *(sl+tot) = *(ul+tot); } } else { if (*(ml+Rect.Right-1-tot)) { if ((*(sl+(RL-1-tot))==0) || (*(sl+(RL-1-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-1-tot)) = uc-1+*(sl+(RL-1-tot)); } else *(sl+(RL-1-tot)) = *(ul+(RL-1-tot)); } } } pcx++; pcy = pcx; } } if ((Width>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if ((Rot==0) || (Rot==3)) { if (*(ml+tot-Rect.Left)) { if ((*(sl+tot)==0) || (*(sl+tot)==1)) continue; if (*pcx==1) { *(sl+tot) = uc-1+*(sl+tot); } else *(sl+tot) = *(ul+tot); } } else { if (*(ml+Rect.Right-1-tot)) { if ((*(sl+(RL-tot))==0) || (*(sl+(RL-tot))==1)) continue; if (*pcx==1) { *(sl+(RL-tot)) = uc-1+*(sl+(RL-tot)); } else *(sl+(RL-tot)) = *(ul+(RL-tot)); } } } pcx++; } } switch (Rot) { case 0: case 1: MainImageForm->iMainImage->uBitmap->PutScanLine(y); break; case 2: case 3: MainImageForm->iMainImage->uBitmap->PutScanLine(TB-1-y); break; } } } ud->Bitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); ud->Complete(); return; fail: ud->Bitmap->StopScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); */ } //--------------------------------------------------------------------------- bool __fastcall TJacquardForm::ComboNoMethod(TTexpiaBitmap *Pattern, TSize r) { TSize s; TRect Src, Re; RGBQUAD rgb[256]; if (MainImageForm->WorkArea->Mask) { Src = (TRect) MainImageForm->WorkArea->Range; s.cx = Src.Right - Src.Left; s.cy = Src.Bottom - Src.Top; } else { Src = Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height); s.cx = MainImageForm->iMainImage->uBitmap->Width; s.cy = MainImageForm->iMainImage->uBitmap->Height; } MainImageForm->Palette->ToRGBQUAD(rgb, 256); if (!Pattern->Create(s.cx*r.cx, s.cy*r.cy, 8, rgb)) return false; Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); return Repeat_Method(r, s, Src, Pattern); } //--------------------------------------------------------------------------- bool __fastcall TJacquardForm::Repeat_Method(TSize r, TSize s, TRect Src, TTexpiaBitmap *Pattern) { TRect Dst; int x, y; HDC /*dcSrc = NULL,*/ dcDst = NULL; // if ((dcSrc = MainImageForm->iMainImage->uBitmap->CreateDC())==NULL) goto fail; if ((dcDst = Pattern->CreateDC())==NULL) goto fail; SetStretchBltMode(dcDst, COLORONCOLOR); for (y=0; yiMainImage->uBitmap->UnionStretchBlt(dcDst, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), Src.Left, Src.Top, (Src.Right-Src.Left), (Src.Bottom-Src.Top), SRCCOPY); // convert by celberus if (MainImageForm->WorkArea->Mask) Irregularrect(Dst, dcDst); } } Pattern->DeleteDC(dcDst); // MainImageForm->iMainImage->uBitmap->DeleteDC(dcSrc); return true; fail: if (dcDst) Pattern->DeleteDC(dcDst); // if (dcSrc) MainImageForm->iMainImage->uBitmap->DeleteDC(dcSrc); return false; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::Irregularrect(TRect Dst, HDC dcDst) { HDC hDC; RGBQUAD rgb[256]; TTexpiaBitmap *Mask = NULL; if (MainImageForm->iMainImage->uBitmap->BitsPerPixel==8) { MainImageForm->Palette->ToRGBQUAD(rgb, 256); Mask = MainImageForm->WorkArea->Mask; Mask->PutColors(0, 256, rgb); } hDC = Mask->CreateDC(); if (hDC) { SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, Dst.Left, Dst.Top, (Dst.Right-Dst.Left), (Dst.Bottom-Dst.Top), hDC, 0, 0, Mask->Width, Mask->Height, MERGEPAINT); Mask->DeleteDC(hDC); } } //--------------------------------------------------------------------------- bool __fastcall TJacquardForm::ComboYesMethod(TTexpiaBitmap *Pattern) { TRect Src, Dst, Re, PDst; TTexpiaBitmap *UsedColBit = NULL; int w, h, temp, ht, width, height; RGBQUAD rgb[256]; HDC /*dcSrc = NULL,*/ dcDst = NULL, dcUse = NULL; TPItemImage *Image = MainImageForm->iMainImage; if ((UsedColBit = new TTexpiaBitmap) == NULL ) goto fail; if (MainImageForm->WorkArea->Mask) { Src = (TRect) MainImageForm->WorkArea->Range; width = Src.Right - Src.Left; height = Src.Bottom - Src.Top; } else { width = Image->uBitmap->Width; height = Image->uBitmap->Height; } if (DrawUsedColor(UsedColBit)== false) goto fail; w = UsedColBit->Width*MainImageForm->CanvasInfor.DotsPerInch/160; h = UsedColBit->Height*MainImageForm->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 (Pattern->Height>ht) height = ht+h; Pattern->Create(width, height, 24); // { White·Î PatternÀüü¸¦ ä¿ì±â } Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); // if ((dcSrc = Image->uBitmap->CreateDC()) == NULL) goto fail; if ((dcDst = Pattern->CreateDC()) == NULL) goto fail; if (MainImageForm->WorkArea->Mask) { Dst = Rect(0, 0, Src.Right-Src.Left, temp); // BitBlt(dcDst, Dst.Left, Dst.Top, Dst.Right, Dst.Bottom, dcSrc, Src.Left, Src.Top, SRCCOPY); Image->uBitmap->UnionBitBlt(dcDst, Dst.Left, Dst.Top, Dst.Right, Dst.Bottom, Src.Left, Src.Top, SRCCOPY, false); // convert by celberus Irregularrect(Dst, dcDst); } else { // BitBlt(dcDst, 0, 0, Image->uBitmap->Width, Image->uBitmap->Height, dcSrc, 0, 0, SRCCOPY); Image->uBitmap->UnionBitBlt(dcDst, 0, 0, Image->uBitmap->Width, Image->uBitmap->Height, 0, 0, SRCCOPY, false); // convert by celberus } // Image->uBitmap->DeleteDC(dcSrc); PDst = Rect(0, temp , w, temp+h); if (Pattern->Height > ht) PDst = Rect(0, ht, w, ht+h); Src = Rect(0, 0, UsedColBit->Width, UsedColBit->Height); dcUse = UsedColBit->CreateDC(); SetStretchBltMode(dcDst, COLORONCOLOR); StretchBlt(dcDst, 0, temp, w, h, dcUse, 0, 0, UsedColBit->Width, UsedColBit->Height, SRCCOPY); Pattern->DeleteDC(dcDst); UsedColBit->DeleteDC(dcUse); delete UsedColBit; return true; fail: // if (dcSrc) Image->uBitmap->DeleteDC(dcSrc); if (dcDst) Pattern->DeleteDC(dcDst); if (dcUse) UsedColBit->DeleteDC(dcUse); if (UsedColBit) delete UsedColBit; EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return false; } //--------------------------------------------------------------------------- bool __fastcall TJacquardForm::DrawUsedColor(TTexpiaBitmap *Pattern) { TChoiceColor *ChoiceColor = NULL; int i, j, k, l, row, tab, temph, toth, w, h; AnsiString NameStr; RGBQUAD rgb[256]; TRect BitRect, StrRect, Re; TCanvas *ca = NULL; if ((ChoiceColor = new TChoiceColor) == NULL) goto fail; if (MainImageForm->WorkArea->Mask) MainImageForm->SearchWorkAreaColor(ChoiceColor); else MainImageForm->SearchWholeColor(ChoiceColor); w = GetDeviceCaps(Printer()->Handle, HORZRES)*160 /GetDeviceCaps(Printer()->Handle, LOGPIXELSX); h = GetDeviceCaps(Printer()->Handle, VERTRES)*160 /GetDeviceCaps(Printer()->Handle, LOGPIXELSY); Pattern->Create(w, h, 24); Pattern->FillRect(Rect(0, 0, Pattern->Width, Pattern->Height), clWhite); l = (Pattern->Width-34) / 100; // Pattern Height Á¤Çϱâ row = 1+ChoiceColor->Count / l; temph = row*70+60; j = 0; k = 0; for (i = 0; i < ChoiceColor->Count; i++, k++) { if ((i % l)==0) { j = i / l; k = 0; } BitRect = Rect(44+k*100, 30+j*70, 134+k*100, 80+j*70); PrintColorChip24TP(Pattern, BitRect, ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue); // convert by celberus } ca = Pattern->CreateCanvas(); ca->Font->Size = 10; for (i =0, j = 0, k = 0; i < ChoiceColor->Count; i++, k++) { if ((i % l) == 0) { j = i / l; k = 0; } StrRect = Rect(44+k*100, 80+j*70, 134+k*100, 100+j*70); 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; break; } tab = (90 - ca->TextWidth(NameStr)) / 2; // Adjust Center if (tab<0) tab = 0; ca->TextRect(StrRect, 44+tab+100*k, 82+j*70, NameStr); } Pattern->DeleteCanvas(ca); toth = DrawPrtTexture(Pattern, temph); Pattern->Resize(Pattern->Width, temph+toth+10, clWhite); delete ChoiceColor; return true; fail: if (ChoiceColor) delete ChoiceColor; if (ca) Pattern->DeleteCanvas(ca); EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); return false; } //--------------------------------------------------------------------------- int __fastcall TJacquardForm::DrawPrtTexture(TTexpiaBitmap *bmp, int th) { int cw, ch, i, j, w, h, k, l, tab; TRect chip, StrRect, StrRect1; TTexBitData *bip; AnsiString str, str1; PTextureData jd; TCanvas *ca = NULL; w = (bmp->Width-60) / 7; h = w+30; cw = w-15; ch = cw; k = 0; j = 0; i = 0; for (l=0; lCount; l++) { jd = (PTextureData) store->Items[l]; if (jd->use) { if ((i % 7)==0) { k = 0; j = i / 7; } chip = Rect(37+w*k, th+h*j, 37+cw+w*k, th+ch+h*j); str = GeTTextureData(l, &bip); SubDrawPrtTexture(bmp, chip, bip, jd->zoom); ca = bmp->CreateCanvas(); if (ca) { tab = (cw - ca->TextWidth(str)) / 2; if (tab<0) tab = 0; StrRect = Rect(37+w*k, th+ch+h*j, 37+cw+w*k, th+ch+25+h*j); ca->Font->Color = clBlue; ca->TextRect(StrRect, tab+37+w*k, th+ch+5+h*j, str); str1 = Format("< %d: %d x %d >", OPENARRAY (TVarRec, (jd->num+1, bip->Width, bip->Height))); tab = (cw - ca->TextWidth(str1)) / 2; if (tab<0) tab = 0; StrRect1 = Rect(37+w*k, th+ch+25+h*j, 37+cw+w*k, th+h*(j+1)); ca->Font->Color = clBlack; ca->TextRect(StrRect1, tab+37+w*k, th+ch+25+h*j, str1); LineTexptr(ca, chip, jd->zoom, bip); bmp->DeleteCanvas(ca); ca = NULL; k++; i++; } } } return h * ((i / 7) + 1); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubDrawPrtTexture(TTexpiaBitmap *bmp, TRect Rect, TTexBitData *bip, Byte zm) { int x, y, j, w, rw, zr, tot, spt, zh, zw, chipw; Byte z, r; Byte *sl; Byte *stp, *temp, *pcx, *pcy; COLORREF col; stp = bip->pBitmap; pcy = stp; temp = stp; chipw = Rect.Right-Rect.Left; zw = bip->Width*zm; zh = bip->Height*zm; w = chipw / zw; rw = chipw % zw; if (w==0) w = 1; bmp->StartScanLine(); for (y=Rect.Bottom-1; y>=Rect.Top; y--) { sl = bmp->GetScanLine(y) + Rect.Left * 3; spt = Rect.Bottom-1-y; if ((spt % zm)pBitmap; for (j=0; jWidth; r++) { zr = r*zm; for (z=0; z=Rect.Right) break; if (*pcx==1) col = 0; else col = clWhite; SetPixel24(sl, col); } pcx++; pcy = pcx; } } if ((chipw>zw) && (rw)) { pcx = stp; for (r=0; rWidth; r++) { for (z=0; z=Rect.Right) break; if (*pcx==1) col = 0; else col = clWhite; SetPixel24(sl, col); } pcx++; } } bmp->PutScanLine(y); } bmp->StopScanLine(); } //--------------------------------------------------------------------------- AnsiString __fastcall TJacquardForm::GeTTextureData(Byte i, TTexBitData **bip) { Byte Ind, num; TFound *fd; TDeriv *dt; TSpecial *sp; PTextureData jd; jd = (PTextureData)store->Items[i]; switch (jd->Itm) { case 0: FoundDrawData(jd, Ind, num); fd = (TFound *)TextureForm->Texture->f[jd->pts]->Items[Ind]; *bip = (TTexBitData *) fd->data->Items[num]; return Format("< %d x %d >", OPENARRAY (TVarRec, (fd->size, fd->size))); case 1: DerivDrawData(jd, Ind, num); dt = (TDeriv *) TextureForm->Texture->d[jd->pts]->Items[Ind]; *bip = (TTexBitData *) dt->data->Items[num]; return Format("< %s >", OPENARRAY(TVarRec, (dt->name))); case 2: SpecialDrawData(jd, Ind, num); sp = (TSpecial *) TextureForm->Texture->s->Items[Ind]; *bip = (TTexBitData *) sp->data->Items[num]; return Format("< %s >", OPENARRAY(TVarRec, (sp->name))); } return ""; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::LineTexptr(TCanvas *cv, TRect Rect, Byte i, TTexBitData *bip) { int w, h, x, y, vj, wid, hei; wid = Rect.Right - Rect.Left; hei = Rect.Bottom - Rect.Top; w = bip->Width*i; h = bip->Height*i; for (x=0; xPen->Color = clRed; cv->MoveTo(Rect.Left+x, Rect.Top); cv->LineTo(Rect.Left+x, Rect.Bottom); } } for (y=hei-1; y>=0; y--) { vj = hei-1-y; if ((vj % h)==0) { cv->Pen->Color = clRed; cv->MoveTo(Rect.Left, Rect.Bottom-1-vj); cv->LineTo(Rect.Right, Rect.Bottom-1-vj); } } cv->Pen->Color = clBlack; cv->MoveTo(Rect.Left, Rect.Top); cv->LineTo(Rect.Left, Rect.Bottom); cv->LineTo(Rect.Right, Rect.Bottom); cv->LineTo(Rect.Right, Rect.Top); cv->LineTo(Rect.Left, Rect.Top); } //--------------------------------------------------------------------------- bool __fastcall TJacquardForm::Load_File(AnsiString FileName, int Index, TUnionBitmap *pBitmap, TPalette *pPalette, TPCanvasInfor &pi) // convert by celberus { TEXPIAFILEHEADER tpfh; int i, ec = EC_NONE; bool sw; TJaqdFiledata tjfd; TJtxtData jtxt; PTextureData jd = NULL; short wid, hei; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; 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; // convert by celberus #ifndef ACADEMY UserColorLibForm->ThisFileHasUserColor(pPalette); #endif pi = tpfh.CanvasInfor; if (tpfh.Version.Method == 'T') { if (tpfh.Version.Number < 200) sw = true; else sw = false; } else sw = true; if (sw) { if (!ReadFile(hFile, &(tjfd.base), 1, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &(tjfd.tcnt), 1, &dwRead, NULL)) goto fail; if (tjfd.tcnt) { for (i=0; iItm = jtxt.g[0]; jd->pts = jtxt.g[1]; jd->Ind = jtxt.g[2]; jd->num = jtxt.g[3]; jd->name = AnsiString(jtxt.name); jd->use = true; jd->zoom = 3; jd->Rot = jtxt.mode; jd->disname = Format("%d", OPENARRAY (TVarRec, (jd->num+1))); store->Add(jd); } } } else { if (!ReadFile(hFile, &(tjfd.tcnt), 1, &dwRead, NULL)) goto fail; for (i=0; iItm), 1, &dwRead, NULL)) goto fail; if ( !ReadFile(hFile, &(jd->pts), 1, &dwRead, NULL)) goto fail; if (!ReadFile(hFile, jtxt.name, 22, &dwRead, NULL)) goto fail; //window¿¡¼­´Â jd^.Ind¸¦ ´ë½ÅÇÑ´Ù. jd->name = AnsiString(jtxt.name); if ( !ReadFile(hFile, jtxt.name, 22, &dwRead, NULL)) goto fail; jd->disname = AnsiString (jtxt.name); //window¿¡¼­´Â jd^.num¸¦ ´ë½ÅÇÑ´Ù. if ( !ReadFile(hFile, &(jd->Rot), 1, &dwRead, NULL)) goto fail; if ( !ReadFile(hFile, &(jd->zoom), 1, &dwRead, NULL)) goto fail; jd->use = true; store->Add(jd); } } CloseHandle(hFile); if (store->Count>0) { mm = true; ImgScrollBar->Max = store->Count-1; ImgScrollBar->Position = store->Count-1; ImgChange(store->Count-1); } InitFunc(0); return true; fail: if (hFile == INVALID_HANDLE_VALUE) CloseHandle(hFile); if (ec == EC_NONE) ec = EC_FILE_NOT_READ; EXCEPTION_MESSAGE_OK(ec); return false; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::OpenImage() { TPItemImage *Image = MainImageForm->iMainImage; TPoint p; RECT rc; p.x = Image->SubRange.left; p.y = Image->SubRange.top; rc = Rect(p.x, p.y, p.x+Image->SubBitmap->Width, p.y+Image->SubBitmap->Height); Image->uBitmap->CopyToRect(rc.left, rc.top, Image->SubBitmap, SRCCOPY); if (Image->LayerMask) Image->LayerMask->FillRect(rc, 0); MainImageForm->WorkArea->SetRectangle(rc); MainImageForm->WorkAreaChange(); ColIndex = MainImageForm->Palette->UseColor + 1; MainImageForm->Palette->ColorData[ColIndex]->RGB.rgbRed = 0; MainImageForm->Palette->ColorData[ColIndex]->RGB.rgbGreen = 0; MainImageForm->Palette->ColorData[ColIndex]->RGB.rgbBlue = 0; PaletteForm->DIB256Palette->ChoiceIndex = ColIndex; PaletteForm->DIB256Palette->Repaint(); Image->SubVisible = false; Image->SubEnabled = false; ::RepaintColor(); Item = 0; } //--------------------------{Public Method}---------------------------------- void __fastcall TJacquardForm::InitForm() { RGBQUAD rgb[2]; ParentHeight = Parent->Height+20; ClientHeight = 223; Parent->Height = ParentHeight+ClientHeight; TextureForm = new TTextureForm(MainForm); if (TextureForm->InitForm() == false) goto fail; TextureForm->Parent = MainForm; TextureForm->Visible = true; TextureForm->OnChange = TextureOnChange; store = new TList; IniTTextureData(); RunRearrange(); ColIndex = MainImageForm->Palette->UseColor+1; U_Col = MainImageForm->Palette->UseColor; MainImageForm->Palette->ColorData[ColIndex]->RGB.rgbRed = 0; MainImageForm->Palette->ColorData[ColIndex]->RGB.rgbBlue = 0; MainImageForm->Palette->ColorData[ColIndex]->RGB.rgbGreen = 0; PaletteForm->DIB256Palette->ChoiceIndex = ColIndex; PaletteForm->DIB256Palette->Repaint(); TextureButton->Down = true; Effect = false; DrawGImage(); sep = true; //Effect fill¿¡¼­ ÆÈ·¹Æ®¼ö¸¦ Ãʰú½Ã false setPalette¸¦ Åë°ú.; Item = 0; Bitmap = new Graphics::TBitmap; Bitmap->PixelFormat = pf8bit; Bitmap->Width = Image->Width; Bitmap->Height = Image->Height; if (Bitmap->Empty) goto fail; rgb[0].rgbRed = 255; rgb[0].rgbGreen = 255; rgb[0].rgbBlue = 255; rgb[1].rgbRed =0; rgb[1].rgbGreen = 0; rgb[1].rgbBlue = 0; SetDIBColorTable(Bitmap->Canvas->Handle, 0, 2, rgb); ReadJacIni(); ::RepaintImage(); return; fail: EXCEPTION_MESSAGE_OK(EC_MEMORY_LACK); PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::ExitForm() { TextureForm->Visible = false; PTextureData jd; WriteJacIni(); while (store->Count>0) { jd = (PTextureData)store->Last(); store->Remove(jd); delete jd; } if (store) delete store; if (Bitmap) delete Bitmap; if (TextureForm) delete TextureForm; MainImageForm->iMainImage->SubVisible = false; MainImageForm->iMainImage->SubEnabled = false; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::TextureOnChange(TObject *Sender) { PTextureData jd; TFound *fd; TDeriv *dt; TSpecial *sp; TTexBitData *bip; TTextureForm *Form = (TTextureForm*) Sender; jd = new TTextureData; jd->Itm = Form->Item; jd->pts = Form->ptsItem; switch (Form->Item) { case 0: fd = (TFound *) TextureForm->Texture->f[Form->ptsItem]->Items[Form->Index]; jd->name = Format("%d x %d", OPENARRAY (TVarRec, (fd->size, fd->size))); jd->Ind = Form->Index; jd->num = Form->TextureGrid->Row*Form->TextureGrid->ColCount+Form->TextureGrid->Col; bip = (TTexBitData *)fd->data->Items[jd->num]; jd->disname = AnsiString(bip->Name); break; case 1: dt = (TDeriv *) TextureForm->Texture->d[Form->ptsItem]->Items[Form->Index]; jd->name = AnsiString (dt->name); jd->Ind = Form->Index; jd->num = Form->TextureGrid->Row*Form->TextureGrid->ColCount+Form->TextureGrid->Col; bip = (TTexBitData *)dt->data->Items[jd->num]; jd->disname = AnsiString(bip->Name); break; case 2: sp = (TSpecial *) TextureForm->Texture->s->Items[Form->Index]; jd->name = AnsiString (sp->name); jd->Ind = Form->Index; jd->num = Form->TextureGrid->Row*Form->TextureGrid->ColCount+Form->TextureGrid->Col; bip = (TTexBitData *)sp->data->Items[jd->num]; jd->disname = AnsiString(bip->Name); break; } jd->zoom = StrToInt(Form->ZoEdit->Text); jd->use = false; jd->Rot = 0; FindData(jd); if (find==false) { store->Add(jd); ImgScrollBar->Enabled = true; ImgScrollBar->Max = store->Count-1; ImgScrollBar->Position = store->Count-1; ImgChange(store->Count-1); InitFunc(0); mm = true; } find = false; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::iMainImageMouseDown(TMouseButton Button, TShiftState Shift, int X, int Y) { PTextureData jd; COLORREF Value; if (Button==mbMiddle || (Shift.Contains(ssShift) && Button==mbLeft)){ //lhskys iMainImage ¿¡¼­ Ä®¶ó¼±ÅÃ... Value = MainImageForm->iMainImage->uBitmap->GetPixelColor(X, Y); FGChange(Value); //lhskys } if (Item==1) { MainImageForm->SubBitmapPosition(X, Y, false); OpenImage(); FGChange(PaletteForm->DIB256Palette->ChoiceIndex); } else { if (mm) { if ((Button==mbLeft) && (IsDraw)) { MainImageForm->UndoSave(UK_ALL, Rect(0, 0, MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height)); FillColor = MainImageForm->iMainImage->uBitmap->GetPixelColor(X, Y); First = Point(X, Y); jd = (PTextureData) store->Items[ImgScrollBar->Position]; jd->use = true; j_use = true; //2001.7.26 lhskys Jacquard ¿¡¼­ ¹«Á¶°ÇÀúÀå ¹æÁö Jacstart = Point(X, Y); switch (Select) { case 0: SelectColorFill(); break; case 1: AreaFill(); break; case 2: EffectFill(); if (sep) { U_Col = MainImageForm->Palette->UseColor; MainImageForm->Palette->UseColor = MainImageForm->Palette->UseColor*2-1; SetPaletteColor(); } else jd->use = false; draw = true; break; } // if (MainImageForm->AutoRepeat) MainImageForm->RedrawingRepeat(false, false); ::RepaintColor(); } } else { Sysutils::Beep(); MessageDlg(IDS_MESSAGE_NOTEXTURE, mtWarning, TMsgDlgButtons()<Enabled) ImgScrollBar->SetFocus(); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::iMainImageMouseMove(int X, int Y) { if (Item==1) { if (!MainImageForm->iMainImage->Cross)MainImageForm->iMainImage->Cursor = crCross; MainImageForm->SubBitmapPosition(X, Y, true); } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FGChange(int Value) { ColIndex = Value; shEffect->Brush->Color = RGB2TColor(MainImageForm->Palette->ColorData[Value]->RGB.rgbRed, MainImageForm->Palette->ColorData[Value]->RGB.rgbGreen, MainImageForm->Palette->ColorData[Value]->RGB.rgbBlue); } //--------------------------------------------------------------------------- TPException __fastcall TJacquardForm::JQDOnRead(TFMReadParameter rp) { TRect r; TPCanvasInfor pi; RGBQUAD color[256]; TPItemImage *Image = MainImageForm->iMainImage; MainImageForm->WorkAreaReset(true); r = Rect(0, 0, Image->uBitmap->Width, Image->uBitmap->Height); MainImageForm->UndoSave(UK_ALL, r); Image->SubEnabled = true; IniTTextureData(); // Jacquard TextureÀÇ Store ¸¦ ºñ¿î´Ù. if (!Load_File(rp.FileName, rp.ExtIndex, Image->SubBitmap, MainImageForm->Palette, pi)) { return EC_FILE_NOT_READ; } Image->uBitmap->FillRect(r, PALETTEINDEX(BackgroundColor)); if (Image->LayerMask) Image->LayerMask->FillRect(r, PALETTEINDEX(255)); if ((Image->SubBitmap->Width > Image->uBitmap->Width) || (Image->SubBitmap->Height > Image->uBitmap->Height) || (MainImageForm->CanvasInfor.DotsPerInch != pi.DotsPerInch)) { MainImageForm->Undo->RemoveAll(); //may be bug don't ignore pi.SetSize(cstFree, Image->SubBitmap->Width, Image->SubBitmap->Height); MainImageForm->ResizePattern(pi, 8); } Image->uBitmap->FillRect(r, PaletteForm->DIB256Palette->GetBGCOLORREF(Image->uBitmap->BitsPerPixel)); Image->SubBitmap->GetColors(0, 256, color); Image->SubMask->Create(Image->SubBitmap->Width, Image->SubBitmap->Height, 8, color); Image->SubMask->FillRect(Rect(0, 0, Image->SubMask->Width, Image->SubMask->Height), PALETTEINDEX(0)); MainImageForm->Center.x = Image->SubBitmap->Width / 2; MainImageForm->Center.y = Image->SubBitmap->Height / 2; // Image->SubVisible = true; ::RepaintColor(); Item = 1; return EC_NONE; } //--------------------------------------------------------------------------- AnsiString __fastcall TJacquardForm::JQDOnFileName(AnsiString FileName, TGraphicFileFormat ExtIndex) { PChar s; int FileNameLength, last1, last2, last3, last4; char FileIndex1, FileIndex2, FileIndex3, FileIndex4; //=============================================================== FileNameLength = FileName.Length(); if(FileNameLength > 4){ last1 = FileNameLength-3; last2 = FileNameLength-2; last3 = FileNameLength-1; last4 = FileNameLength; FileIndex1 = '.'; FileIndex2 = 'j'; FileIndex3 = 'q'; FileIndex4 = 'd'; if((FileIndex1 == FileName[last1])&&(FileIndex2 == FileName[last2]) && (FileIndex3 == FileName[last3])&&(FileIndex4 == FileName[last4])){ s = "PASS"; }else s=NULL; }else s=NULL; //=============================================================== // PChar s = AnsiStrScan(FileName.c_str(), '.'); if (s==NULL) { AnsiString fn = FileName+".jqd"; return fn; } else { return FileName; } } //--------------------------------------------------------------------------- TPException __fastcall TJacquardForm::JQDOnSave(AnsiString DirName, AnsiString FileName, TGraphicFileFormat ExtIndex, TCompressMethod cm) { int lim, i, ec = EC_NONE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256]; Byte cnt; char jtxt[22]; PTextureData jd; // HDC dcSrc = NULL; //blocked for removing warning TTexpiaBitmap *tag = NULL; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwWrite; if ((hFile = CreateFile(FullPathName(DirName, FileName).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', 300); // 222 -> 300 convert by celberus tpfh.CanvasInfor = MainImageForm->CanvasInfor; tpfh.BitsPerPixel = 8; tpfh.Compress = cm; if (MainImageForm->WorkArea->Mask) { src = MainImageForm->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 = MainImageForm->iMainImage->uBitmap->Width; src.Bottom = MainImageForm->iMainImage->uBitmap->Height; } MainImageForm->Palette->ToRGBQUAD(rgb, 256); if ((tag = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; goto fail; } MakeTexpiaTag(tag, MainImageForm->iMainImage->uBitmap, src, 0); if (MainImageForm->WorkArea && MainImageForm->WorkArea->Mask) { if (!SaveToTexpiaFile(hFile, MainImageForm->Palette, tpfh, tag, MainImageForm->iMainImage->uBitmap, &MainImageForm->WorkArea->Range)) goto fail; } else { if (!SaveToTexpiaFile(hFile, MainImageForm->Palette, tpfh, tag, MainImageForm->iMainImage->uBitmap)) goto fail; } delete tag; tag = NULL; lim = store->Count-1; cnt = 0; for (i=0; i<=lim; i++) { jd = (PTextureData) store->Items[i]; if (jd->use) cnt = cnt+1; } if (!WriteFile(hFile, &cnt, 1, &dwWrite, NULL)) goto fail; for (i=0; i<=lim; i++) { jd = (PTextureData) store->Items[i]; if (jd->use) { if (!WriteFile(hFile, &jd->Itm, 1, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &jd->pts, 1, &dwWrite, NULL)) goto fail; StrCopy(jtxt, jd->name.c_str()); if (!WriteFile(hFile, jtxt, 22, &dwWrite, NULL)) goto fail; //window¿¡¼­´Â jd^.Ind¸¦ ´ë½ÅÇÑ´Ù. StrCopy(jtxt, jd->disname.c_str()); if (!WriteFile(hFile, jtxt, 22, &dwWrite, NULL)) goto fail; //window¿¡¼­´Â jd^.num¸¦ ´ë½ÅÇÑ´Ù. if (!WriteFile(hFile, &jd->Rot, 1, &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &jd->zoom, 1, &dwWrite, NULL)) goto fail; } } CloseHandle(hFile); return EC_NONE; fail: if (tag) delete tag; if (hFile!=INVALID_HANDLE_VALUE) CloseHandle(hFile); if (ec == EC_NONE) ec = EC_FILE_NOT_WRITE; return ec; } //--------------------------------------------------------------------------- bool __fastcall TJacquardForm::Jac_read_layer8_nonezero(Byte *p, Byte *lp, int x) { return true;//Selector->Number[*(p+x)]<255 && (*(lp + x) != 0); } //---------------------------------------------------------------------------- bool __fastcall TJacquardForm::Jac_read_none8(Byte *p, int x) { return true;//Selector->Number[*(p+x)]<255; } //---------------------------------------------------------------------------- bool __fastcall TJacquardForm::Jac_read_layer8_zero(Byte *p, Byte *lp, int x) { return true;//Selector->Number[*(p+x)]<255 && (*(lp + x) == 0); } //----------------------------------------------------------------------------