我需要將圖片分成多個扇區并計算每個扇區中黑點的數量。我為此使用區域。我可以以某種方式使用“編輯”輸入欄位執行此操作嗎?
HRGN region [n];
HRGN 需要一個常數值,如
const n = 35;
如果有可能以某種方式將 HRGN 與 Edit 聯系起來,請幫忙,例如,如果 Edit 設定如下:
int n = Edit1-> Text.ToIntDef (0);
uj5u.com熱心網友回復:
我想您是在問如何使用 aTEdit指定陣列的計數來分配陣列,對嗎?
考慮使用T(C)SpinEdit代替TEdit數字輸入。
您可以使用new[]以下方法在運行時動態分配陣列:
HRGN *region = NULL;
...
int n = Edit1->Text.ToInt(); // or SpinEdit1->Value
region = new HRGN[n];
// use region as needed...
delete[] region;
或者更好的是,使用std::vector, 或System::DynamicArray, 代替:
#include <vector>
std::vector<HRGN> region;
...
int n = Edit1->Text.ToInt(); // or SpinEdit1->Value
region.resize(n);
// use region as needed...
// freed automatically when out of scope...
#include <sysdyn.h>
DynamicArray<HRGN> region;
...
int n = Edit1-> Text.ToInt(); // or SpinEdit1->Value
region.Length = n;
// use region as needed...
// freed automatically when out of scope...
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/328139.html
標籤:C 数组 图片 时间:2019-05-06 标签:c builder 地区
