我想用图像渲染地图。 (不使用Map API)
所以我使用React-leaflet的ImageOverlay。
但是这使ImageOverlay的高度固定。
我认为图像的高度和宽度带有“ bounds”属性。
void __fastcall Tviewer_ui::viewerPageMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
if (_selecting)
{
TColor to_color = 0;
TColor from_color = 0;
Tviewer_page* vp = static_cast<Tviewer_page *>(Sender);
Tsel_data* sel_data = &vp->_sel_datas[vp->_c_sel];
// Scroll window if needed
int sb_pos = _scrollBox->VertScrollBar->Position;
if (Y > sb_pos - vp->_top + _scrollBox->Height - 10)
_scrollBox->VertScrollBar->Position += 10;
else
if (Y < sb_pos - vp->_top + 10)
_scrollBox->VertScrollBar->Position -= 10;
int y1 = 0;
int y2 = 0;
if (Y > sel_data->_start_y)
{
if (Y > sel_data->_last_y)
{
y1 = sel_data->_last_y;
y2 = Y;
from_color = clWhite;
to_color = clHighlight;
}
else if (Y < sel_data->_last_y)
{
y1 = Y;
y2 = sel_data->_last_y;
from_color = clHighlight;
to_color = clWhite;
}
sel_data->_rect.Bottom = Y;
}
else if (Y < sel_data->_start_y)
{
if (Y < sel_data->_last_y)
{
y1 = Y;
y2 = sel_data->_last_y;
from_color = clWhite;
to_color = clHighlight;
}
else if (Y > sel_data->_last_y)
{
y1 = sel_data->_last_y;
y2 = Y;
from_color = clHighlight;
to_color = clWhite;
}
sel_data->_rect.Top = Y;
}
int height = abs(y1 - y2);
if (height > 0)
{
TRect srect = Rect(sel_data->_rect.Left, y1, sel_data->_rect.Right, y2);
int width = srect.Width();
TRect drect = Rect(sel_data->_rect.Left,0,sel_data->_rect.Right, height);
Graphics::TBitmap* bm1 = new Graphics::TBitmap;
bm1->Width = width;
bm1->Height = height;
Graphics::TBitmap* bm2 = new Graphics::TBitmap;
bm2->Width = width;
bm2->Height = height;
bm1->Canvas->CopyRect(drect, vp->Canvas, srect);
bm2->Canvas->Brush->Color = to_color;
bm2->Canvas->BrushCopy(drect, bm1, drect, from_color);
BitBlt(vp->Canvas->Handle, srect.Left, srect.Top, width, height, bm2->Canvas->Handle, 0, 0, SRCCOPY);
vp->Refresh();
delete bm1;
delete bm2;
}
sel_data->_last_y = Y;
}
}
这是代码。 这就是图片。
然后,我将范围更改为100,
最后,我将范围更改为300
出了什么问题?? 然后,标记的位置是[90,200]