//--------------------------------------------------------------------------- #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 "FullView.h" #include "Undo.h" #include "UserColor_F.h" #include "define.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "RzButton" #pragma link "RzCmboBx" #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] #define IDS_JACQUARDERROR StringTable[7] //--------------------------------------------------------------------------- TJacquardForm *JacquardForm; typedef struct tagTJtxtData { Byte g[4]; Byte mode; Char name[TNameLength]; 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; sbTexture->Hint = IDS_TEXTURE; sbFile->Hint = IDS_COMMON_FILE; sbPrint->Hint = 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; rzcbOption->Items->Clear(); rzcbOption->Items->Add(IDS_SELECTCOLOR); rzcbOption->Items->Add(IDS_INAREA); rzcbOption->Items->Add(IDS_EFFECT); rzcbOption->ItemIndex = 0; //====================================================================== } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FormCreate(TObject *Sender) { store = NULL; Bitmap = NULL; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FormDestroy(TObject *Sender) { int count; String str; TIniFile* JacIni = new TIniFile(AppDataItem+"\\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::sbAllDeleteClick(TObject *Sender) { BEGIN_LOG(""); IniTTextureData(); END_LOG; } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::sbDeleteClick(TObject *Sender) { BEGIN_LOG(""); int r; PTextureData jd; if (store && 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); } } END_LOG; } //---------------------------------------------------------------------------- void __fastcall TJacquardForm::sbRotateClick(TObject *Sender) { BEGIN_LOG(""); 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); } sbRotate->Tag = (sbRotate->Tag + 1)%2; Graphics::TBitmap *bitmap = new Graphics::TBitmap; ImageList1->GetBitmap(sbRotate->Tag, bitmap); sbRotate->Glyph->Assign(bitmap); delete bitmap; END_LOG; } //---------------------------------------------------------------------------- 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) { BEGIN_LOG(""); if (Effect) { ImgClick = true; DrawGImage(); LigLine(Point(X-length, 0), Point(X+length, 19)); } END_LOG; } //---------------------------------------------------------------------------- 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) { rzcbOption->Enabled = true; } else { rzcbOption->Enabled = false; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::ReadJacIni() { int i, count, J_use; String str; PTextureData jd = NULL; TPException ec = EC_NONE; TIniFile* JacIni = new TIniFile(AppDataItem+"\\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) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::WriteJacIni() { int count, i, J_use; String str; PTextureData jd; TIniFile* JacIni = new TIniFile(AppDataItem+"\\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() { BEGIN_LOG(""); 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(); END_LOG; } //--------------------------------------------------------------------------- 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) { TTextureItem *aTextureItem = NULL; String 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, (aTextureItem->size, aTextureItem->size))); if (str1==jd->name) { i = x; break; } } aTextureItem = (TTextureItem*) TextureForm->Texture->f[jd->pts]->Items[i]; cnt = aTextureItem->data->Count; for (x=0; xdata->Items[x]; str2 = String(bip->Name); if (str2==jd->disname) n = x; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::DerivDrawData(PTextureData jd, Byte &i, Byte &n) { TTextureItem *aTextureItem = NULL; String str1, str2; int cnt, x; TTexBitData *bip; cnt = TextureForm->Texture->d[jd->pts]->Count; for (x=0; xTexture->d[jd->pts]->Items[x]; str1 = String (aTextureItem->name); if (str1==jd->name) { i = x; break; } } aTextureItem = (TTextureItem*) TextureForm->Texture->d[jd->pts]->Items[i]; cnt = aTextureItem->data->Count; for (x=0; xdata->Items[x]; str2 = String (bip->Name); if (str2==jd->disname) n = x; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SpecialDrawData(PTextureData jd, Byte &i, Byte &n) { TTextureItem *aTextureItem = NULL; String str1, str2; int cnt, x; TTexBitData *bip; cnt = TextureForm->Texture->s->Count; for (x=0; xTexture->s->Items[x]; str1 = String (aTextureItem->name); if (str1==jd->name) { i = x; break; } } aTextureItem = (TTextureItem*) TextureForm->Texture->s->Items[i]; cnt = aTextureItem->data->Count; for (x=0; xdata->Items[x]; str2 = String (bip->Name); if (str2==jd->disname) n = x; } } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::ImgChange(int Pos) { BEGIN_LOG(""); // ÃʱâÈ­ ÇÊ¿ä - by monkman (2009,10.07) Byte i = 0, n = 0; 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; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FoundDraw(Byte p, Byte i, Byte n, Byte Rot) { BEGIN_LOG(""); TTextureItem *dstTextureItem = (TTextureItem*) TextureForm->Texture->f[p]->Items[i]; NameText->Caption = Format("F: <<%d>> %d x %d", OPENARRAY(TVarRec, (n+1, dstTextureItem->size, dstTextureItem->size))); TTexBitData *bip = (TTexBitData *) dstTextureItem->data->Items[n]; DrawBitmap(bip, Rot); Image->Canvas->Draw(0, 0, Bitmap); LineDraw(bip, Rot); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::DerivDraw(Byte p, Byte i, Byte n, Byte Rot) { BEGIN_LOG(""); TTextureItem *dstTextureItem = (TTextureItem*) TextureForm->Texture->d[p]->Items[i]; NameText->Caption = Format("D: <<%d>> %s", OPENARRAY(TVarRec, (n+1, dstTextureItem->name))); TTexBitData *bip = (TTexBitData *) dstTextureItem->data->Items[n]; DrawBitmap(bip, Rot); Image->Canvas->Draw(0, 0, Bitmap); LineDraw(bip, Rot); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SpecialDraw(Byte i, Byte n, Byte Rot) { BEGIN_LOG(""); TTextureItem *dstTextureItem = (TTextureItem*) TextureForm->Texture->s->Items[i]; NameText->Caption = Format("S: <<%d>> %s", OPENARRAY(TVarRec, (n+1, dstTextureItem->name))); TTexBitData *bip = (TTexBitData *) dstTextureItem->data->Items[n]; DrawBitmap(bip, Rot); Image->Canvas->Draw(0, 0, Bitmap); LineDraw(bip, Rot); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::DrawBitmap(TTexBitData *bip, Byte Rot) { BEGIN_LOG(""); 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*7; zh = bip->Height*7; 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%7)<7) stp = temp; if ((spt%7)==0)stp = pcy; if ((spt%zh)==0) stp = (Byte *)bip->pBitmap; for (j=0; jWidth; r++) { zr = r*7; for (z=0; z<7; 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<7; z++) { tot = (Bitmap->Width-rw)+(r*7)+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++; } } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::LineDraw(TTexBitData *bip, Byte Rot) { BEGIN_LOG(""); int w, h, i, j, vj; w = bip->Width*7; h = bip->Height*7; switch (Rot) { case 0: case 3: for (i=0; iWidth; i++) { if ((i%7)==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)%7)==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%7)==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%7)==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; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::Clear() { BEGIN_LOG(""); NameText->Caption = ""; Image->Canvas->Brush->Color = clWhite; Image->Canvas->FillRect(Rect(0, 0, Image->Width, Image->Height)); InitFunc(1); DrawGImage(); mm = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::DrawGImage() { Byte *sl; int x, y, xx, i = 0; GImage->Picture->Bitmap->PixelFormat = pf24bit; GImage->Picture->Bitmap->Width = 120; GImage->Picture->Bitmap->Height = 20; GImage->Canvas->Pen->Color = clAqua; for (y=0; y<20; y++) { sl = (Byte *) GImage->Picture->Bitmap->ScanLine[y]; for (x=0; x<120; x++) { xx = x*3; i = 255*x/120; *(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->HLSToRGB(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>120) X = 120; if (X<0) X =0; LigLine(Point(X-length, 0), Point(X+length, 19)); center = (double) X/120; 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() { BEGIN_LOG(""); 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(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::AreaFill() { BEGIN_LOG(""); 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; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::EffectFill() { BEGIN_LOG(""); 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; END_LOG; return; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::MainFill(TRect Rect, Byte code) { BEGIN_LOG(""); TTextureItem *dstTextureItem = NULL; 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); dstTextureItem = (TTextureItem *) TextureForm->Texture->f[jd->pts]->Items[i]; bip = (TTexBitData *) dstTextureItem->data->Items[n]; break; case 1: DerivDrawData(jd, i, n); dstTextureItem = (TTextureItem *) TextureForm->Texture->d[jd->pts]->Items[i]; bip = (TTexBitData *) dstTextureItem->data->Items[n]; break; case 2: SpecialDrawData(jd, i, n); dstTextureItem = (TTextureItem *) TextureForm->Texture->s->Items[i]; bip = (TTexBitData *) dstTextureItem->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; } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubFill(TTexBitData *bip, TRect Rect, Byte zo, Byte Rot) { BEGIN_LOG(""); 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 RL, TB, www, hhh; int width, height; TPException ec = EC_NONE; /* 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; SAVE_EXCEPTION(ec); goto fail; } if (!PartialUndoBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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-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++; } } 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-1-tot))==id) { if (*pcx==1) { *(sl+(RL-1-tot)) = ColIndex; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-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(); END_LOG; // ud->Complete(); return; fail: PartialUndoBitmap->StopUndoScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubIRREFill(TTexBitData *bip, TRect Rect, Byte zo, Byte Rot) { BEGIN_LOG(""); 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, height, RL, TB; TPException 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; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!PartialUndoBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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-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++; } } 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-1-tot))==FillColor) { if (*pcx==1) { *(sl+(RL-1-tot)) = ColIndex; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-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(); END_LOG; // ud->Complete(); return; fail: PartialUndoBitmap->StopUndoScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubNONEEffect(TTexBitData *bip, TRect Rect, Byte zo, Byte Rot) { BEGIN_LOG(""); 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; TPException ec; ///* BeConverted by linuxjun Don't Forget!! Undo_Method int width = Rect.Right - Rect.Left; 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; SAVE_EXCEPTION(ec); goto fail; } if (!PartialUndoBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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-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++; } } 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-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++; } } 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(); END_LOG; // ud->Complete(); return; fail: PartialUndoBitmap->StopUndoScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubIRREEffect(TTexBitData *bip, TRect Rect, Byte zo, Byte Rot) { BEGIN_LOG(""); 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, height, RL, TB; TPException 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; SAVE_EXCEPTION(ec); goto fail; } if (!MainImageForm->WorkArea->Mask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!PartialUndoBitmap->StartUndoScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->iMainImage->LayerMask) { if (!MainImageForm->iMainImage->LayerMask->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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-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]; } else *(sl+(RL-1-tot)) = *(ul+(RL-1-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-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++; } } 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(); END_LOG; // ud->Complete(); return; fail: PartialUndoBitmap->StopUndoScanLine(); MainImageForm->WorkArea->Mask->StopScanLine(); MainImageForm->iMainImage->uBitmap->StopScanLine(); EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- 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) { BEGIN_LOG(""); 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); END_LOG; // MainImageForm->iMainImage->uBitmap->DeleteDC(dcSrc); return true; fail: if (dcDst) Pattern->DeleteDC(dcDst); END_LOG; // 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) { BEGIN_LOG(""); 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; TPException ec = EC_NONE; if ((UsedColBit = new TTexpiaBitmap) == NULL ) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((dcDst = Pattern->CreateDC()) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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; END_LOG; 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); END_LOG; return false; } //--------------------------------------------------------------------------- bool __fastcall TJacquardForm::DrawUsedColor(TTexpiaBitmap *Pattern) { BEGIN_LOG(""); TChoiceColor *ChoiceColor = NULL; int i, j, k, l, row, tab, temph, temph2, toth, w, h; String NameStr; RGBQUAD rgb[256]; TRect BitRect, StrRect, Re, tempRect; TCanvas *ca = NULL; int forDB_H = 0; bool B_DB = false; TPException ec = EC_NONE; if ((ChoiceColor = new TChoiceColor) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (MainImageForm->WorkArea->Mask) { MainImageForm->SearchWorkAreaColor(ChoiceColor); } else { MainImageForm->SearchWholeColor(ChoiceColor); forDB_H = 20;// 080421 by altang } 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); if (!MainImageForm->WorkArea->Mask) j++; // 080421 by altang k = 0; if (B_DB) { B_DB = false; forDB_H += 20; temph += 20; } } BitRect = Rect(44+k*100, 30+j*70+forDB_H, 134+k*100, 80+j*70+forDB_H); PrintColorChip24TP(Pattern, BitRect, ChoiceColor->ColorMap[i]->RGB.rgbRed, ChoiceColor->ColorMap[i]->RGB.rgbGreen, ChoiceColor->ColorMap[i]->RGB.rgbBlue); // convert by celberus //if (ChoiceColor->ColorMap[i]->Kind == 6) { if ((ChoiceColor->ColorMap[i]->Kind & 0x0FFF) == 0x0006) { B_DB = true; } } ca = Pattern->CreateCanvas(); ca->Font->Size = 10; B_DB = false; if (MainImageForm->WorkArea->Mask) forDB_H = 0; else forDB_H = 20; // 080421 by altang for (i =0, j = 0, k = 0; i < ChoiceColor->Count; i++, k++) { if ((i % l) == 0) { j = i / l; if (!MainImageForm->WorkArea->Mask) j++; // 080425 by altang k = 0; if (B_DB) { B_DB = false; forDB_H += 20; } } StrRect = Rect(44+k*100, 80+j*70+forDB_H, 134+k*100, 100+j*70+forDB_H); ca->Brush->Color = clWhite; if ((ChoiceColor->ColorMap[i]->Kind & 0x400F) >= 0x4000){ switch (ChoiceColor->ColorMap[i]->Kind & 0x000F){ case 0: case 3: case 4: case 1: case 2: //³ª¸® ¿äûÀ¸·Î Ãß°¡ 080408 case 6: //Pantone coloe 080324 NameStr = ChoiceColor->ColorMap[i]->ColorName; break; } } else { switch (ChoiceColor->ColorMap[i]->Kind & 0x0FFF) { 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 6: //Pantone coloe 080408 //NameStr = ChoiceColor->ColorMap[i]->PantoneColor; NameStr = (char *)ChoiceColor->ColorMap[i]->additionalColorData->GetData(TAG_PANTONE_COLOR); B_DB = true; 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); if(NameStr != ""){ ca->Font->Color = clBlack; int default_w = StrRect.right - StrRect.left; int default_h = StrRect.bottom - StrRect.top; int left_t = 44+tab+100*k, top_t = 82+j*70+forDB_H; int string_line_count = ca->TextWidth(NameStr) / default_w + 1; //tempRect.left = StrRect.left; tempRect.right = default_w; // //tempRect.top = StrRect.top; tempRect.bottom = default_h; // tempRect = StrRect; if(string_line_count == 1) { //tab = (chip_name_area.cx - ca->TextWidth(NameStr)) / 2; //ca->TextRect(StrRect, tab, 2, NameStr); ca->TextRect(StrRect, left_t, top_t, NameStr); } else { //chip_size.cy -= (default_h * (string_line_count - 1)); //StrRect.top -= (default_h * (string_line_count - 1)); int char_index, start_index = 0, start_line = 0; for(char_index = 1 ; char_index < NameStr.Length() ; ++char_index) { if(ca->TextWidth(NameStr.SubString(start_index, char_index - start_index)) > default_w) { ca->TextRect(tempRect, left_t, top_t + start_line * default_h + 2, NameStr.SubString(start_index, char_index - start_index - 1)); tempRect.bottom += default_h; tempRect.top += default_h; start_index = char_index; ++start_line; } } ca->TextRect(tempRect, left_t, top_t + start_line * default_h + 2, NameStr.SubString(start_index, char_index - start_index + 1)); } } } Pattern->DeleteCanvas(ca); if(!MainImageForm->WorkArea->Mask) temph2 = 90; else temph2 = 0; toth = DrawPrtTexture(Pattern, temph + temph2); //080424 by altang À§Ä¡ ¼öÁ¤ (+20) Pattern->Resize(Pattern->Width, temph+temph2+toth+10, clWhite); delete ChoiceColor; END_LOG; return true; fail: if (ChoiceColor) delete ChoiceColor; if (ca) Pattern->DeleteCanvas(ca); EXCEPTION_MESSAGE_OK(ec); END_LOG; return false; } //--------------------------------------------------------------------------- int __fastcall TJacquardForm::DrawPrtTexture(TTexpiaBitmap *bmp, int th) { BEGIN_LOG(""); int cw, ch, i, j, w, h, k, l, tab; TRect chip, StrRect, StrRect1; TTexBitData *bip; String 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++; } } } END_LOG; return h * ((i / 7) + 1); } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::SubDrawPrtTexture(TTexpiaBitmap *bmp, TRect Rect, TTexBitData *bip, Byte zm) { BEGIN_LOG(""); 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(); END_LOG; } //--------------------------------------------------------------------------- String __fastcall TJacquardForm::GeTTextureData(Byte i, TTexBitData **bip) { Byte Ind, num; TTextureItem *dstTextureItem = NULL; PTextureData jd; jd = (PTextureData)store->Items[i]; switch (jd->Itm) { case 0: FoundDrawData(jd, Ind, num); dstTextureItem = (TTextureItem *)TextureForm->Texture->f[jd->pts]->Items[Ind]; *bip = (TTexBitData *) dstTextureItem->data->Items[num]; return Format("< %d x %d >", OPENARRAY (TVarRec, (dstTextureItem->size, dstTextureItem->size))); case 1: DerivDrawData(jd, Ind, num); dstTextureItem = (TTextureItem *)TextureForm->Texture->d[jd->pts]->Items[Ind]; *bip = (TTexBitData *) dstTextureItem->data->Items[num]; return Format("< %s >", OPENARRAY(TVarRec, (dstTextureItem->name))); case 2: SpecialDrawData(jd, Ind, num); dstTextureItem = (TTextureItem *)TextureForm->Texture->s->Items[Ind]; *bip = (TTexBitData *) dstTextureItem->data->Items[num]; return Format("< %s >", OPENARRAY(TVarRec, (dstTextureItem->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(String FileName, int Index, TUnionBitmap *pBitmap, TPalette *pPalette, TPCanvasInfor &pi) // convert by celberus { TEXPIAFILEHEADER tpfh; int i; TPException ec = EC_NONE; bool sw; TJaqdFiledata tjfd; TJtxtData jtxt; PTextureData jd = NULL; short wid, hei; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwRead; char cTempName[TNameLength]; Char wcTempName[TNameLength]; if ((hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((ec = LoadFromTexpiaFile(hFile, pPalette, tpfh, pBitmap, FindExtension(ExtractFileExt(FileName))))!=EC_NONE) goto fail; // convert by celberus UserColorLibForm->ThisFileHasUserColor(pPalette); pi = tpfh.CanvasInfor; if (tpfh.Version.Method == 'T') { if (tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } // 090527 upper version if (tpfh.Version.Number < 200) sw = true; else sw = false; } else sw = true; if (sw) { if (!ReadFile(hFile, &(tjfd.base), sizeof(Byte), &dwRead, NULL)) goto fail; if (!ReadFile(hFile, &(tjfd.tcnt), sizeof(Byte), &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 = String(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), sizeof(Byte), &dwRead, NULL)) goto fail; for (i=0; iItm), sizeof(Byte), &dwRead, NULL)) goto fail; if ( !ReadFile(hFile, &(jd->pts), sizeof(Byte), &dwRead, NULL)) goto fail; if (tpfh.Version.Texpia == 'P' && tpfh.Version.Method == 'T' && 302 <= tpfh.Version.Number) { if (!ReadFile(hFile, wcTempName, sizeof(Char)*TNameLength, &dwRead, NULL)) goto fail; //window¿¡¼­´Â jd^.Ind¸¦ ´ë½ÅÇÑ´Ù. jd->name = String(wcTempName); if ( !ReadFile(hFile, wcTempName, sizeof(Char)*TNameLength, &dwRead, NULL)) goto fail; jd->disname = String(wcTempName); //window¿¡¼­´Â jd^.num¸¦ ´ë½ÅÇÑ´Ù. } else { if (!ReadFile(hFile, cTempName, sizeof(char)*TNameLength, &dwRead, NULL)) goto fail; //window¿¡¼­´Â jd^.Ind¸¦ ´ë½ÅÇÑ´Ù. jd->name = String(cTempName); if ( !ReadFile(hFile, cTempName, sizeof(char)*TNameLength, &dwRead, NULL)) goto fail; jd->disname = String(cTempName); //window¿¡¼­´Â jd^.num¸¦ ´ë½ÅÇÑ´Ù. } if ( !ReadFile(hFile, &(jd->Rot), sizeof(Byte), &dwRead, NULL)) goto fail; if ( !ReadFile(hFile, &(jd->zoom), sizeof(Byte), &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); //INVALID_HANDLE_VALUEÀ̸é HandleÀÌ ¾ø´Â °ÍÀÌ´Ù. ÀÌ ¶§ CloseHandleÀ» ÇÒ Çʿ䰡 ¾ø´Ù. //µû¶ó¼­ handleÀÌ ÀÖÀ» ¶§ File HandleÀ» CloseÇØ¾ß¸¸ ÆÄÀÏÀ» ´Ù½Ã ÀÐÀ» ¼ö ÀÖ´Ù. //¿Ö ÀÌ·¸°Ô ÇßÀ»±î? ¤Ð¤Ð ¹Ùº¸´Ù.... //by david 090811 if (hFile) CloseHandle(hFile); if (ec == EC_NONE) ec = EC_FILE_NOT_READ; EXCEPTION_MESSAGE_OK(ec); return false; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::OpenImage() { BEGIN_LOG(""); 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; END_LOG; } //--------------------------{Public Method}---------------------------------- void __fastcall TJacquardForm::InitForm() { BEGIN_LOG(""); RGBQUAD rgb[2]; TPException ec = EC_NONE; //ParentHeight = Parent->Height+20; //ClientHeight = 223; //Parent->Height = ParentHeight+ClientHeight; TextureForm = new TTextureForm(MainForm); if (TextureForm->InitForm() == false) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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; if (MainImageForm->Palette->UseColor>=255){ Application->MessageBox(IDS_JACQUARDERROR.c_str(), L"Warning", MB_OK); goto fail; // ÆÈ·¹Æ®°¡ ²Ë Â÷ ÀÖÀ»¶§ ½ÇÇà ¾ÈµÇ°Ô ÇÑ´Ù. by tnmddn85 } 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(); //sbTexture->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) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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(); ChangeOption(rzcbOption->ItemIndex); END_LOG; return; fail: EXCEPTION_MESSAGE_OK(ec); PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::ExitForm() { #ifdef TRIAL Rearrange(); ::RepaintColor(); #endif TextureForm->Visible = false; PTextureData jd; WriteJacIni(); while (store->Count>0) { jd = (PTextureData)store->Last(); store->Remove(jd); delete jd; jd = NULL; } if (store) delete store; store = NULL; if (Bitmap) delete Bitmap; Bitmap = NULL; if (TextureForm) { TextureForm->bFree = true; TextureForm->Close(); } MainImageForm->iMainImage->SubVisible = false; MainImageForm->iMainImage->SubEnabled = false; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::TextureOnChange(TObject *Sender) { BEGIN_LOG(""); PTextureData jd; TTextureItem *dstTextureItem = NULL; TTexBitData *bip; TTextureForm *Form = (TTextureForm*) Sender; jd = new TTextureData; jd->Itm = Form->Item; jd->pts = Form->ptsItem; switch (Form->Item) { case 0: dstTextureItem = (TTextureItem *) Form->Texture->f[Form->ptsItem]->Items[Form->Index]; jd->name = Format("%d x %d", OPENARRAY (TVarRec, (dstTextureItem->size, dstTextureItem->size))); jd->Ind = Form->Index; jd->num = Form->TextureGrid->Row*Form->TextureGrid->ColCount+Form->TextureGrid->Col; bip = (TTexBitData *)dstTextureItem->data->Items[jd->num]; jd->disname = String(bip->Name); break; case 1: dstTextureItem = (TTextureItem *) Form->Texture->d[Form->ptsItem]->Items[Form->Index]; jd->name = String (dstTextureItem->name); jd->Ind = Form->Index; jd->num = Form->TextureGrid->Row*Form->TextureGrid->ColCount+Form->TextureGrid->Col; bip = (TTexBitData *)dstTextureItem->data->Items[jd->num]; jd->disname = String(bip->Name); break; case 2: dstTextureItem = (TTextureItem *) Form->Texture->s->Items[Form->Index]; jd->name = String (dstTextureItem->name); jd->Ind = Form->Index; jd->num = Form->TextureGrid->Row*Form->TextureGrid->ColCount+Form->TextureGrid->Col; bip = (TTexBitData *)dstTextureItem->data->Items[jd->num]; jd->disname = String(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; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::iMainImageMouseDown(TMouseButton Button, TShiftState Shift, int X, int Y) { BEGIN_LOG(""); 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); #ifdef TRIAL RGBQUAD rgb[256]; MainImageForm->iMainImage->uBitmap->GetColors(0, 256, rgb); TTexpiaBitmap *tempBitmap = new TTexpiaBitmap; tempBitmap->Create(MainImageForm->iMainImage->uBitmap->Width, MainImageForm->iMainImage->uBitmap->Height, MainImageForm->iMainImage->uBitmap->BitsPerPixel, rgb); MainImageForm->iMainImage->uBitmap->CopyToTexpia(tempBitmap, 0, 0, tempBitmap->Width, tempBitmap->Height, 0, 0, SRCCOPY); HDC dcDst = tempBitmap->CreateDC(); PaintWaterMark(dcDst, 0, 0, tempBitmap->Width, tempBitmap->Height, 1, 1, random(2) ? random(30)+10 : random(30)+320, false); tempBitmap->DeleteDC(dcDst); MainImageForm->iMainImage->uBitmap->Copy(tempBitmap, SRCCOPY); delete tempBitmap; //MainImageForm->iMainImage->uBitmap->ColorResolution(8, CRF_OPTIMIZEDPALETTE, NULL, 250); MainImageForm->iMainImage->uBitmap->ColorResolution(8, CRF_USERPALETTE, rgb, 250); //Rearrange(); //MainImageForm->WaterMarkPaint = true; #endif 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; } ::RepaintColor(); } } else { Sysutils::Beep(); MessageDlg(IDS_MESSAGE_NOTEXTURE, mtWarning, TMsgDlgButtons()<Enabled) ImgScrollBar->SetFocus(); END_LOG; } //--------------------------------------------------------------------------- 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, bool changeFileFormat) { BEGIN_LOG(""); TRect r; TPCanvasInfor pi; RGBQUAD color[256]; TPItemImage *Image = MainImageForm->iMainImage; MainImageForm->WorkAreaReset(true); MainForm->UpdateMenuItems(NULL); 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)) { SAVE_EXCEPTION(EC_FILE_NOT_READ); END_LOG; 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); //---- int zi, zo; RGBQUAD RGB[256]; MainImageForm->iMainImage->uBitmap->GetColors(0, 256, RGB); FullViewForm->GetZoomRatio(MainImageForm->iMainImage, zi, zo); MainImageForm->iMainImage->InitbmFullView(zi, zo, PaletteForm->DIB256Palette->GetBGCOLORREF(8), RGB); //---- MainImageForm->ResizePattern ¿¡ ³Ö°í½ÍÁö¸¸ ¿¡·¯ À¯¹ß °¡´É¼º ¶§¹®¿¡ ¿©±â´Ù µÐ´Ù... 2003-11-27 by celberus } 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; END_LOG; return EC_NONE; } //--------------------------------------------------------------------------- //String __fastcall TJacquardForm::JQDOnFileName(String FileName, // TGraphicFileFormat ExtIndex) String __fastcall TJacquardForm::JQDOnFileName(String FileName, TGraphicFileFormat ExtIndex) { //PChar s; Char *s; int FileNameLength, last1, last2, last3, last4; //char FileIndex1, FileIndex2, FileIndex3, FileIndex4; wchar_t FileIndex1, FileIndex2, FileIndex3, FileIndex4; //=============================================================== FileNameLength = FileName.Length(); if(FileNameLength > 4){ last1 = FileNameLength-3; last2 = FileNameLength-2; last3 = FileNameLength-1; last4 = FileNameLength; FileIndex1 = L'.'; FileIndex2 = L'j'; FileIndex3 = L'q'; FileIndex4 = L'd'; if((FileIndex1 == FileName[last1])&&(FileIndex2 == FileName[last2]) && (FileIndex3 == FileName[last3])&&(FileIndex4 == FileName[last4])){ s = L"PASS"; }else s=NULL; }else s=NULL; //=============================================================== // PChar s = AnsiStrScan(FileName.c_str(), '.'); if (s==NULL) { String fn = FileName + ".jqd"; return fn; } else { return FileName; } } //--------------------------------------------------------------------------- //TPException __fastcall TJacquardForm::JQDOnSave(String DirName, String FileName, // TGraphicFileFormat ExtIndex, TCompressMethod cm) TPException __fastcall TJacquardForm::JQDOnSave(String DirName, String FileName, TGraphicFileFormat ExtIndex, TCompressMethod cm) { BEGIN_LOG(""); int lim, i; TPException ec = EC_NONE; TEXPIAFILEHEADER tpfh; TRect src; RGBQUAD rgb[256]; Byte cnt; Char wcTempName[TNameLength]; PTextureData jd; // HDC dcSrc = NULL; //blocked for removing warning TTexpiaBitmap *tag = NULL; HANDLE hFile = INVALID_HANDLE_VALUE; DWORD dwWrite; try { //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; SAVE_EXCEPTION(ec); goto fail; } 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; SAVE_EXCEPTION(ec); goto fail; } tpfh.Version = TexVersion('P', 'T', TextileFileVersion); // 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; SAVE_EXCEPTION(ec); 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, sizeof(Byte), &dwWrite, NULL)) goto fail; for (i=0; i<=lim; i++) { jd = (PTextureData) store->Items[i]; if (jd->use) { if (!WriteFile(hFile, &jd->Itm, sizeof(Byte), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &jd->pts, sizeof(Byte), &dwWrite, NULL)) goto fail; _tcsncpy(wcTempName, jd->name.c_str(), TNameLength); if (!WriteFile(hFile, wcTempName, sizeof(Char) * TNameLength, &dwWrite, NULL)) goto fail; //window¿¡¼­´Â jd^.Ind¸¦ ´ë½ÅÇÑ´Ù. _tcsncpy(wcTempName, jd->disname.c_str(), TNameLength); if (!WriteFile(hFile, wcTempName, sizeof(Char) * TNameLength, &dwWrite, NULL)) goto fail; //window¿¡¼­´Â jd^.num¸¦ ´ë½ÅÇÑ´Ù. if (!WriteFile(hFile, &jd->Rot, sizeof(Byte), &dwWrite, NULL)) goto fail; if (!WriteFile(hFile, &jd->zoom, sizeof(Byte), &dwWrite, NULL)) goto fail; } } } catch (...){ SAVE_EXCEPTION(EC_NO_MESSAGE); goto fail; } CloseHandle(hFile); END_LOG; return EC_NONE; fail: if (tag) delete tag; if (hFile!=INVALID_HANDLE_VALUE){ CloseHandle(hFile); DeleteFile(FullPathName(DirName, FileName).c_str()); //shin À߸øµÈ ÆÄÀÏÀ̹ǷΠÁö¿î´Ù } if (ec == EC_NONE) ec = EC_FILE_NOT_WRITE; END_LOG; 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); } //---------------------------------------------------------------------------- /* typedef struct { Byte no; Byte spread; int count; } sColorArrange; */ int __fastcall findList(int current, TList *List) { int k, p, count; sColorArrange *pOrder; k = 0; while (kCount) { pOrder = (sColorArrange *)List->Items[k]; count = pOrder->count; p = k; if (pOrder->spread) { while (true) { k = k+1; pOrder = (sColorArrange *)List->Items[k]; count = count+pOrder->count; if (k+1Count) { pOrder = (sColorArrange *)List->Items[k+1]; if (pOrder->spread==0 || pOrder->spread==1) break; } else break; } } k = k+1; if (current>count) return p; } return List->Count; } //--------------------------------------------------------------------------- bool __fastcall TJacquardForm::Rearrange() { BEGIN_LOG(""); int Code[256]; int ColorCount[256]; int i, j, n, x, y, count; Byte *Scan; TList *List = NULL; sColorArrange *pOrder = NULL; TChoiceColor *ChoiceColor = NULL; RGBQUAD rgb[256]; TPException ec = EC_NONE; if (MainImageForm->Palette->UseColor>2) { if ((ChoiceColor = new TChoiceColor) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if ((List = new TList) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (i=0; i<=255; i++) { Code[i] = -1; ColorCount[i] = 0; } if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yiMainImage->uBitmap->Height; y++) { Scan = MainImageForm->iMainImage->uBitmap->GetScanLine(y); for (x=0; xiMainImage->uBitmap->Width; x++) { n = Scan[x]; ColorCount[n]++; //k3dogs 20010131 } } MainImageForm->iMainImage->uBitmap->StopScanLine(); i = 2; while (i<252) { if (ColorCount[i]) { j = findList(ColorCount[i], List); if ((pOrder = (sColorArrange *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(sColorArrange))) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } pOrder->no = i; pOrder->spread = 0; pOrder->count = ColorCount[i]; if (jCount) List->Insert(j, pOrder); else List->Add(pOrder); } i = i+1; } for (i=0; iCount; i++) { pOrder = (sColorArrange *)List->Items[i]; Code[pOrder->no] = ChoiceColor->Count+1; ChoiceColor->Add(MainImageForm->Palette, pOrder->no); } if (!MainImageForm->iMainImage->uBitmap->StartScanLine()) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (y=0; yiMainImage->uBitmap->Height; y++) { Scan = MainImageForm->iMainImage->uBitmap->GetScanLine(y); for (x=0; xiMainImage->uBitmap->Width; x++) { n = Scan[x]; if (n>1) Scan[x] = Code[n]+1; //k3dogs 20010131 } MainImageForm->iMainImage->uBitmap->PutScanLine(y); } MainImageForm->iMainImage->uBitmap->StopScanLine(); for (i=0; iCount; i++) { MainImageForm->Palette->ColorData[i+2] = ChoiceColor->ColorMap[i]; } if (List->Count) MainImageForm->Palette->UseColor = List->Count+1; else MainImageForm->Palette->UseColor = 2; while (List->Count> 0) { pOrder = (sColorArrange *)List->First(); HeapFree(GetProcessHeap(), 0, pOrder); List->Remove(pOrder); } delete List; List = NULL; delete ChoiceColor; ChoiceColor = NULL; } MainImageForm->Palette->ToRGBQUAD(rgb, 256); MainImageForm->iMainImage->uBitmap->PutColors(0, 256, rgb); PaletteForm->DIB256Palette->ChoiceIndex = 2; END_LOG; return true; fail: if (List) { while (List->Count>0) { pOrder = (sColorArrange *)List->First(); HeapFree(GetProcessHeap(), 0, pOrder); List->Remove(pOrder); } delete List; } MainImageForm->iMainImage->uBitmap->StopScanLine(); if (ChoiceColor) delete ChoiceColor; EXCEPTION_MESSAGE_OK(ec); END_LOG; return false; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::FormClose(TObject *Sender, TCloseAction &Action) { BEGIN_LOG(""); PostMessage(hWnd, TPM_EXITFUNCTION, 0, 0); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::ChangeOption(int index) { BEGIN_LOG(""); switch (index) { case 0: //TextureForm->Visible = false; Effect = false; IsDraw = true; DrawGImage(); Select = 0; break; case 1: //TextureForm->Visible = false; Effect = false; IsDraw = true; DrawGImage(); Select = 1; break; case 2: { 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; break; } } END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::rzcbOptionCloseUp(TObject *Sender) { BEGIN_LOG(""); ChangeOption(rzcbOption->ItemIndex); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::sbTextureClick(TObject *Sender) { BEGIN_LOG(""); TextureForm->Visible = !TextureForm->Visible;//true; //Effect = false; //IsDraw = false; MainImageForm->iMainImage->OnPaintLocate = NULL;/////////////////by jeegeo DrawGImage(); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::sbFileClick(TObject *Sender) { BEGIN_LOG(""); //TFileManagerForm *Form = NULL; TPException ec = EC_NONE; TextureForm->Visible = false; Effect = false; if ((FileManagerForm = new TFileManagerForm(this)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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; rzcbOption->ItemIndex = 0; IsDraw = true; END_LOG; return; fail : EXCEPTION_MESSAGE_OK(ec); END_LOG; } //--------------------------------------------------------------------------- void __fastcall TJacquardForm::sbPrintClick(TObject *Sender) { BEGIN_LOG(""); TJacPrtForm *Form = NULL; TTexpiaBitmap *Pattern = NULL; int DPI; TRect Src, Dst; TSize r; TPException ec = EC_NONE; TextureForm->Visible = false; if ((Form = new TJacPrtForm(this)) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (Form->ShowModal()==mrOk) { if ((Pattern = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); 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)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } DPI = DPI * 100 / Form->EditZoom->IntValue; break; case 1: //Yes if (!ComboYesMethod(Pattern)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } break; } SendToPrinterTP(Pattern, DPI, "Jacquard - "+MainImageForm->FileName, Form->PageEdit->Value, Form->cbMethod->ItemIndex); // convert by celberus delete Pattern; } delete Form; rzcbOption->ItemIndex = 0; IsDraw = true; END_LOG; return; fail: if (Pattern) delete Pattern; if (Form) delete Form; EXCEPTION_MESSAGE_OK(ec); rzcbOption->ItemIndex = 0; IsDraw = true; END_LOG; } //---------------------------------------------------------------------------