Mike
Here is a code example, to show you how to create on the fly a complex GDImage polypolygon, and add it to gT.hZoomCtrl, just the same than using drag and drop from gT.hMarkerParent.
void UsaMap() {
// USA map xy coordinates
POINTS xy[] = {146,218,166,224,168,230,162,235,168,240,175,236,175,224,175,206,244,216,350,222,
468,210,500,203,518,210,529,205,546,210,573,207,554,235,566,232,570,236,577,233,
585,243,591,243,606,240,616,253,618,259,613,265,618,262,622,291,629,299,628,310,
637,317,644,308,644,287,637,272,633,253,641,250,639,242,647,229,663,233,670,242,
673,250,666,259,666,266,673,271,678,261,683,258,691,272,687,283,686,295,691,298,
703,297,730,269,733,259,731,248,747,240,755,237,759,220,766,198,792,188,810,176,
814,161,812,138,813,131,829,128,842,147,855,152,852,168,840,176,841,185,833,189,
833,203,830,214,838,218,833,227,844,228,851,224,852,231,846,236,840,236,840,244,
831,251,837,254,830,265,814,277,816,291,813,304,802,306,809,314,814,325,810,329,
811,337,807,343,804,336,806,328,796,319,791,306,788,305,786,319,794,324,792,329,
800,336,801,345,795,347,802,352,806,349,813,352,815,359,811,368,823,370,818,383,
811,381,812,389,818,388,821,390,809,399,803,412,795,416,794,423,791,435,775,459,
775,464,776,478,772,489,781,497,783,513,797,531,809,545,819,567,820,575,814,592,
809,592,803,588,801,581,791,576,772,557,770,547,767,546,763,531,747,517,735,517,
727,526,719,525,703,517,682,523,677,525,673,520,669,523,661,527,652,535,649,540,
656,541,652,549,663,557,662,559,648,552,645,553,649,557,640,560,634,560,622,551,
614,551,611,556,603,559,599,552,589,554,581,559,574,555,567,555,563,558,572,560,
574,564,555,585,547,584,548,593,536,600,534,613,531,616,537,630,538,639,516,636,
506,626,502,613,502,608,494,608,475,583,457,573,450,576,440,590,429,592,418,581,
411,565,385,543,383,541,358,542,354,547,340,546,309,548,253,526,254,522,212,522,
206,505,189,489,168,480,148,442,150,431,144,426,147,421,149,421,150,415,141,414,
130,392,128,380,129,364,134,347,132,328,133,314,145,291,151,259,153,237,147,226};
short XYcount = (sizeof(xy) / sizeof(xy[0]));
long K = 0;
short BorderSize = 5, minx = 9999, miny = 9999, maxx = -9999, maxy = -9999;
for (K = 0; K < XYcount; K++) {
minx = min(xy[K].x, minx);
miny = min(xy[K].y, miny);
maxx = max(xy[K].x, maxx);
maxy = max(xy[K].y, maxy);
}
long nW = maxx - minx, nH = maxy - miny;
for (K = 0; K < XYcount; K++) {
xy[K].x -= minx; xy[K].x += BorderSize / 2;
xy[K].y -= miny; xy[K].y += BorderSize / 2;
}
nW += BorderSize; nH += BorderSize;
const long nCount = 2;
ZOBJECT arrayobj[nCount]; ClearMemory(&arrayobj[0], sizeof(arrayobj));
ZI_CreatePolyLineObject (arrayobj[0], &xy[0], XYcount, ZD_ColorARGB(128, RGB(128,0,0)), BorderSize, ZS_VISIBLE | ZS_DRAFT, ZD_DRAW_FILLED, 0);
ZI_CreatePolyLineObject (arrayobj[1], &xy[0], XYcount, ZD_ColorARGB(255, RGB(100,250,150)), BorderSize, ZS_VISIBLE | ZS_DRAFT, ZD_DRAW_OUTLINE, 0);
WCHAR zFile[MAX_PATH]; ClearMemory(zFile, sizeof(zFile));
Path_Combine(zFile, zGetTempPath(), L"zBidon.png");
ZI_CreateImageComposited(zFile, nW, nH, arrayobj, nCount);
HBITMAP hBitmap = ZI_CreateBitmapFromFile(zFile, nW, nH);
if (hBitmap) {
long top_left_X = 100, top_left_Y = 100;
WCHAR szDrive[_MAX_DRIVE] = {0}, szDir[MAX_PATH] = {0}, szName[_MAX_FNAME] = {0}, szExt[_MAX_EXT] = {0};
wsplitpath(zFile, szDrive, szDir, szName, szExt);
long newID = IncrID(); // Increment ID and ga_Sprite array
// In order to save memory, we detect if we have used already the same sprite
long nIDtoClone = 0;
long nSpriteCount = UBOUND(ga_Sprite) - 1;
for (K = 0; K < nSpriteCount; K++) {
if (_wcsicmp(ga_Sprite[K].filename, zFile) == 0) {
if (ga_Sprite[K].clone == 0) {
if (ga_Sprite[K].id) { // We found one
nIDtoClone = ga_Sprite[K].id; break;
}
}
}
}
if (nIDtoClone) { // Get rid of the bitmap to save memory, and clone nIDtoClone.
DeleteObject(hBitmap);
CloneObject(newID, $NULL, top_left_X, top_left_Y, nIDtoClone);
// Because this is a clone, assign a new set of properties to it (else we inherit everyting from the original).
ZD_SetObjectRotation(newID, 0);
ZD_SetObjectFlipMode(newID, 0);
ZD_SetObjectAngle(newID, 0, 0);
ZD_SetObjectScale(newID, 0);
ZD_SetObjectAlpha(newID, 255, FALSE);
ZD_SetObjectFlipMode(newID, ZD_GetObjectFlipMode(newID));
ZD_SetObjectVisibility(newID, ZS_VISIBLE);
} else { // We must use this bitmap.
ZD_DrawBitmapToCtrl(gT.hZoomCtrl, top_left_X, top_left_Y, hBitmap, ZD_ColorARGB(255, 0), newID, ZS_VISIBLE);
}
ZD_SetObjectImageLabel(newID, szName);
ZD_SetObjectScroll(newID, TRUE);
ZD_SetObjectQuality(newID, gT.UseQuality, FALSE);
SpriteArrayInit(newID, gT.szdropname); // Initialize the global Sprite array
ZI_UpdateWindow(gT.hZoomCtrl, FALSE); // Show new sprite
// ShowSaveButton();
}
zKillFile(zFile);
}
We could use each xy[] POINTS as hot spot to redraw the polypolygon on the fly.
If you want i can send you a Tor.cpp with a TEST button to try it out.