//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "LogData.h" #include "Data3D.h" #include "define.h" //--------------------------------------------------------------------------- #pragma package(smart_init) //--------------------------------------------------------------------------- // TGridData //--------------------------------------------------------------------------- __fastcall TGridData::TGridData() { lx = ly = 0; cx = cy = 0; d = NULL; } //--------------------------------------------------------------------------- __fastcall TGridData::~TGridData() { if (d) d = NULL; //2001.5.23. by lhskys ¼±Ãß°¡½Ã error ¼öÁ¤... // delete d; } //--------------------------------------------------------------------------- void __fastcall TGridData::Initial() { lx = ly = 0; cx = cy = 0; if (d) { delete d; d = NULL; } } //--------------------------------------------------------------------------- void __fastcall TGridData::se_in(TCoordi *c, int sx, int sy, int ex, int ey, int x, int y) { if (x >= 0 && x < cx && y >= 0 && y < cy) { c = d->pointer(x, y); if (sx > c->x) sx = c->x; if (sy > c->y) sy = c->y; if (ex < c->x) ex = c->x; if (ey < c->y) ey = c->y; } } //--------------------------------------------------------------------------- bool __fastcall TGridData::Copy(TGridData &gd, bool bInit) { BEGIN_LOG("Data3D"); TPMemoryArea *t = NULL; int x, y; if (d==NULL || gd.cx!=cx || gd.cy!=cy) { if ((t = new TPMemoryArea(gd.cx, gd.cy))==NULL) goto fail; if (t->lock()==NULL) goto fail; if (d) delete d; d = t; } cx = gd.cx; cy = gd.cy; lx = gd.lx; ly = gd.ly; *d = *gd.d; if (bInit) gd.Initial(); END_LOG; return true; fail: if (t) delete t; END_LOG; return false; } //--------------------------------------------------------------------------- // TData3D //--------------------------------------------------------------------------- __fastcall TData3D::TData3D() : TObject() { int i, k; bWorkArea = false; GridCount = 0; FabricList = new TList; for (i=0; iCount>0) { fl = (TFabricData *)FabricList->First(); FabricList->Remove(fl); /////////////k3dogs delete fl; // row exchanged } // for (i=0; i < GridCount; i++) GridData[i].Initial(); // because of memory leakage for (i=0; i < T3D_MAX_GRID; i++) { GridData[i].Initial(); //================================= for fit point and size by kjs s_point.GP[i] = Point(0, 0); s_point.FP[i] = Point(0, 0); s_point.LP[i] = Point(-1, -1); } I_Length = 0; M_Length = 0; SizeItem = 0; FitPoint = false; for (i=0; i<8; i++) F_Length[i] = 0; //================================= GridCount = 0; bWorkArea = false; END_LOG; } //--------------------------------------------------------------------------- void __fastcall TData3D::RemoveCopy() { BEGIN_LOG("Data3D"); doDestroy(CopyMask) for (int i=0; i0) { if (CopyData) { HeapFree(GetProcessHeap(), 0, CopyData); CopyData = NULL; } } CopyDataSize = 0; CopyCount = 0; END_LOG; } //--------------------------------------------------------------------------- bool __fastcall TData3D::Resize(double rx, double ry) { BEGIN_LOG("Data3D"); int i, x, y; TCoordi *d; TUnionBitmap *tb = NULL; // convert by celberus if (GridCount) { for (i=0; ilock(); for (y=0; ypointer(x, y); d->x = rx*d->x+0.5; d->y = ry*d->y+0.5; } } GridData[i].d->unlock(); } } if (CopyCount>0) { CopySize.x = CopySize.x*rx+0.5; CopySize.y = CopySize.y*ry+0.5; for (i=0; iCreate(CopyBitmap->Width, CopyBitmap->Height, 24)) goto fail; tb->Copy(CopyBitmap, SRCCOPY); if (!tb->ResizeStretch(CopySize.x, CopySize.y)) goto fail; if (!CopyBitmap->Create(CopySize.x, CopySize.y, 24)) goto fail; CopyBitmap->Copy(tb, SRCCOPY); delete tb; tb = NULL; } if (CopyMask) { if (!CopyMask->ResizeStretch(CopySize.x, CopySize.y)) goto fail; } } END_LOG; return true; fail: if (tb) delete tb; END_LOG; return false; } //--------------------------------------------------------------------------- bool __fastcall TData3D::Lock() { BEGIN_LOG("Data3D"); int i; TFabricData *fl; for (i=0; ilock()==NULL) goto fail; } for (i=0; iCount; i++) { fl = (TFabricData *)FabricList->Items[i]; if (fl->Fabric) { if (fl->Fabric->Lock()==NULL) goto fail; } } END_LOG; return true; fail: Unlock(); END_LOG; return false; } //--------------------------------------------------------------------------- void __fastcall TData3D::Unlock() { BEGIN_LOG("Data3D"); int i; TFabricData *fl; for (i=0; iunlock(); } for (i=0; iCount; i++) { fl = (TFabricData *)FabricList->Items[i]; if (fl->Fabric) fl->Fabric->Unlock(); } END_LOG; } //--------------------------------------------------------------------------- TPException __fastcall TData3D::LoadFromFile(HANDLE fh, TEXPIAFILEHEADER &tpfh, int sx, int sy) { BEGIN_LOG("Data3D"); int i, fcnt; TFabricData *c = NULL, *f; TPMemory *cb = NULL; TPBitmap *cf = NULL; TPException ec = EC_NONE; TGridData *gd; DWORD dwRead; TTexpiaBitmap *tempBitmap = NULL; // convert by celberus RGBQUAD rgb[256]; if (tpfh.Version.Number > TextileFileVersion) { ec = EC_FILE_NOT_OPEN_NEWERVERSION; goto fail; } // 090527 upper version if (tpfh.Version.Number<221) { if (SetFilePointer(fh, 8, NULL, FILE_CURRENT)== 0xFFFFFFFF) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } bWorkArea = false; } else if (tpfh.Version.Number<222) { if (!ReadFile(fh, &waStart, sizeof(TPoint), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, &waSize, sizeof(TPoint), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } bWorkArea = waSize.x>0 && waSize.y>0; } else { if (!ReadFile(fh, &bWorkArea, sizeof(bool), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (bWorkArea) { if (!ReadFile(fh, &waStart, sizeof(TPoint), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, &waSize, sizeof(TPoint), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } } } if (!ReadFile(fh, &GridCount, sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (GridCount) { if (GridCount < 0 || GridCount > T3D_MAX_GRID) { GridCount = 0; ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } for (i = 0; i < GridCount; i++) { if (!ReadFile(fh, &GridData[i], sizeof(int) * 4, &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } #ifdef TPDEBUG if (GridData[i].d) SHOWDEBUG; #endif if ((GridData[i].d = new TPMemoryArea(GridData[i].cx, GridData[i].cy))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (GridData[i].d->lock()==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, GridData[i].d->pointer(), sizeof(TCoordi) * GridData[i].cx * GridData[i].cy, &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } } for (i = 0; i < T3DF_CNT; i++) { if (!ReadFile(fh, &fn[i].cnt, sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (fn[i].cnt) { if (!ReadFile(fh, &fn[i].sn, sizeof(int) * fn[i].cnt, &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } } } if (!ReadFile(fh, &fcnt, sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } for (i = 0; i < fcnt; i++) { if ((c = new TFabricData)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, &c->Size, sizeof(POINT), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, &c->Mean, sizeof(Byte), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (tpfh.Version.Number<222) { if ((cb = new TPMemory(3*c->Size.x*c->Size.y))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (cb->lock()==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!cb->LoadFromFile(fh, tpfh.Compress)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if ((cf = new TPBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!cf->Create(c->Size.x, c->Size.y, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (cf->Lock()==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } cf->LoadFromMemory(cb->pointer(0), 3*c->Size.x); c->Fabric = cf; cf = NULL; delete cb; cb = NULL; } else { if ((cf = new TPBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!cf->Create(c->Size.x, c->Size.y, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (cf->Lock()==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!cf->LoadFromFile(fh, tpfh.Compress)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } c->Fabric = cf; cf = NULL; } FabricList->Add(c); c = NULL; } for (i = 0; i < T3DF_CNT; i++) { if (!ReadFile(fh, &GroupList[i].FIndex, sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (GroupList[i].FIndex>0) { f = (TFabricData *)FabricList->Items[GroupList[i].FIndex - 1]; GroupList[i].FFabric = f->Fabric; } else { GroupList[i].FFabric = NULL; } if (!ReadFile(fh, &GroupList[i].FRatio, sizeof(POINT), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, &GroupList[i].FOverlay, sizeof(double), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, &GroupList[i].FMean, sizeof(Byte), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (tpfh.Version.Number<230) { if (i == 0) GroupList[0].Filter = 0x83; else GroupList[i].Filter = 0x03; } else { if (!ReadFile(fh, &GroupList[i].Filter, sizeof(Byte), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } } } if (tpfh.Version.Number>=223) { if (Source==NULL) { if ((Source = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // convert by celberus } if (!Source->Create(sx, sy, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (tpfh.Version.Number < 300) { if ((tempBitmap = new TTexpiaBitmap) == NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // convert by celberus if (!tempBitmap->Create(sx, sy, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // convert by celberus // if (!Source->LoadFromTexpiaFile(fh, tpfh.Compress)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!tempBitmap->LoadFromTexpiaFile(fh, tpfh.Compress)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } // convert by celberus Source->Copy(tempBitmap, SRCCOPY); // convert by celberus Source->ColorSpace = csHLS; delete tempBitmap; tempBitmap = NULL; // convert by celberus } else { if (!Source->LoadFromTexpiaFile(fh, tpfh.Compress)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } Source->ColorSpace = csHLS; } if (!ReadFile(fh, &CopyCount, sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (CopyCount>0) { if ((CopyData = (POINT *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(POINT)*CopyCount))==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } for (i = 0; i < CopyCount; i++) { if (!ReadFile(fh, &CopyData[i], sizeof(POINT), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } } if (!ReadFile(fh, &CopySize, sizeof(TPoint), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } } CopyDataSize = CopyCount; } //=============================== for fit size and point by kjs -- request from japan... if (tpfh.Version.Number>=232) { if (!ReadFile(fh, &SizeItem, sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, &I_Length, sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (!ReadFile(fh, &M_Length, sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } for (i=0; i<8; i++) { // max of group count is 8 if (!ReadFile(fh, &F_Length[i], sizeof(int), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } } if (!ReadFile(fh, &FitPoint, sizeof(bool), &dwRead, NULL)) { ec = EC_FILE_NOT_READ; SAVE_EXCEPTION(ec); goto fail; } if (FitPoint) { for (i=0; ipointer()) == NULL) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!WriteFile(fh, tmp, sizeof(TCoordi)*GridData[i].cx*GridData[i].cy, &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } } for (i = 0; i < T3DF_CNT; i++) { if (!WriteFile(fh, &fn[i].cnt, sizeof(int), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (fn[i].cnt) { if (!WriteFile(fh, &fn[i].sn, sizeof(int) * fn[i].cnt, &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } } } fcnt = FabricList->Count; if (!WriteFile(fh, &fcnt, sizeof(int), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } for (i = 0; i < FabricList->Count; i++) { //ÆÄÀÏ ¹öÀü¿¡ ¿µÇâÀÌ ¾øÀ½ c = (TFabricData *)FabricList->Items[i]; if (!WriteFile(fh, &c->Size, sizeof(POINT), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!WriteFile(fh, &c->Mean, sizeof(Byte), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!c->Fabric->SaveToFile(fh, tpfh.Compress)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } } for (i = 0; i < T3DF_CNT; i++) { if (!WriteFile(fh, &GroupList[i].FIndex, sizeof(int), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!WriteFile(fh, &GroupList[i].FRatio, sizeof(POINT), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!WriteFile(fh, &GroupList[i].FOverlay, sizeof(double), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!WriteFile(fh, &GroupList[i].FMean, sizeof(Byte), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!WriteFile(fh, &GroupList[i].Filter, sizeof(Byte), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } } if (!Source->SaveToTexpiaFile(fh, tpfh.Compress)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!WriteFile(fh, &CopyCount, sizeof(int), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (CopyCount>0) { for (i = 0; i < CopyCount; i++) { if (!WriteFile(fh, &CopyData[i], sizeof(POINT), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } } if (!WriteFile(fh, &CopySize, sizeof(TPoint), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } } //=============================== for fit size and point by kjs -- request from japan... if (!WriteFile(fh, &SizeItem, sizeof(int), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!WriteFile(fh, &I_Length, sizeof(int), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (!WriteFile(fh, &M_Length, sizeof(int), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } for (i=0; i<8; i++) { if (!WriteFile(fh, &F_Length[i], sizeof(int), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } } if (!WriteFile(fh, &FitPoint, sizeof(bool), &dwWrite, NULL)) { ec = EC_FILE_NOT_WRITE; SAVE_EXCEPTION(ec); return ec; } if (FitPoint) { for (i=0; id->lock(); for (y = 0; y < gp->cy; y++) { for (x = 0; x < gp->cx; x++) { if (max.x < gp->d->pointer(x, y)->x) max.x = gp->d->pointer(x, y)->x; if (max.y < gp->d->pointer(x, y)->y) max.y = gp->d->pointer(x, y)->y; } } gp->d->unlock(); } END_LOG; return max; } //--------------------------------------------------------------------------- bool __fastcall TData3D::MakeCopyGrid() { BEGIN_LOG("Data3D"); double rx1, ry1; int i, x, y; for (i = 0; i < GridCount; i++) { if (!CopyGrid[i].Copy(GridData[i])) { END_LOG; return false; } } #ifdef TPDEBUG if (waSize.x == 0 || waSize.y == 0) { ShowMessage(Format("%s (%d) : Divide by 0", OPENARRAY(TVarRec, (__FILE__, __LINE__)))); } #endif rx1 = (double)CopySize.x / waSize.x; ry1 = (double)CopySize.y / waSize.y; if (GridCount) { for (i = 0; i < GridCount; i++) { for (y = 0; y < CopyGrid[i].cy; y++) { for (x = 0; x < CopyGrid[i].cx; x++) { TCoordi *d = CopyGrid[i].d->pointer(x, y); d->x = rx1 * (d->x - waStart.x) + 0.5; d->y = ry1 * (d->y - waStart.y) + 0.5; } } } } END_LOG; return true; } //--------------------------------------------------------------------------- TPException __fastcall TData3D::MakeCopyBitmap(TTexpiaBitmap **bp) { BEGIN_LOG("Data3D"); TTexpiaBitmap *c = NULL; HDC cDC = NULL/*, sDC = NULL*/; TPException ec = EC_NONE; if ((c = new TTexpiaBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } if (!c->Create(CopySize.x, CopySize.y, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } c->ColorSpace = csHLS; if ((cDC = c->CreateDC())==NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } // if ((sDC = Source->CreateDC())==NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } // SetStretchBltMode(cDC, COLORONCOLOR); // StretchBlt(cDC, 0, 0, CopySize.x, CopySize.y, sDC, waStart.x, waStart.y, // waSize.x, waSize.y, SRCCOPY); if(!Source->UnionStretchBlt(cDC, 0, 0, CopySize.x, CopySize.y, waStart.x, waStart.y, waSize.x, waSize.y, SRCCOPY)) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } // convert by celberus // Source->DeleteDC(sDC); sDC = NULL; c->DeleteDC(cDC); cDC = NULL; if (CopyBitmap==NULL) { if ((CopyBitmap = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // convert by celberus } if (!CopyBitmap->Create(CopySize.x, CopySize.y, 24)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } CopyBitmap->Copy(c, SRCCOPY); if (bp) *bp = c; else delete c; END_LOG; return ec; fail: doDestroy(CopyBitmap) // if (sDC) Source->DeleteDC(sDC); if (cDC) c->DeleteDC(cDC); if (c) delete c; END_LOG; return ec; } //--------------------------------------------------------------------------- TPException __fastcall TData3D::MakeCopyMask(TUnionBitmap *mp) // convert by celberus { BEGIN_LOG("Data3D"); // HDC cmDC = NULL, mDC = NULL; TPException ec = EC_NONE; if (CopyMask==NULL) { if ((CopyMask = new TUnionBitmap)==NULL) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } } if (!CopyMask->Create(CopySize.x, CopySize.y, 1)) { ec = EC_MEMORY_LACK; SAVE_EXCEPTION(ec); goto fail; } // if ((cmDC = CopyMask->CreateDC())==NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } // if ((mDC = mp->CreateDC())==NULL) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } // SetStretchBltMode(cmDC, COLORONCOLOR); // StretchBlt(cmDC, 0, 0, CopySize.x, CopySize.y, mDC, waStart.x, waStart.y, // waSize.x, waSize.y, SRCCOPY); // mp->DeleteDC(mDC); // CopyMask->DeleteDC(cmDC); if (!CopyMask->UnionStretchBlt(0, 0, CopySize.x, CopySize.y, mp, waStart.x, waStart.y, waSize.x, waSize.y, SRCCOPY)) { ec = EC_RESOURCE_LACK; SAVE_EXCEPTION(ec); goto fail; } END_LOG; return ec; fail: // if (mDC) mp->DeleteDC(mDC); // if (cmDC) CopyMask->DeleteDC(cmDC); doDestroy(CopyMask) END_LOG; return ec; } //---------------------------------------------------------------------------