Android 处理包含可单击部分的图像
我正在处理一个包含矩形和正方形布局的图像。它们不一定在一个精确的网格中,有些是分散的。总共大约有300个,它们需要在应用程序中可以点击 到目前为止,我已尝试使用此ImageMap库: 我编写了一个程序来为某些部分生成xml,但大多数图像需要通过将坐标硬编码到xml中来定义 我已经研究了一些OpenCV,这可能是一个可行的选择,但我对它太不熟悉了 有没有人有过类似的开发经验 编辑:这是我到目前为止使用ImageMap库得到的 图像地图视图Android 处理包含可单击部分的图像,android,image,opencv,image-processing,imagemap,Android,Image,Opencv,Image Processing,Imagemap,我正在处理一个包含矩形和正方形布局的图像。它们不一定在一个精确的网格中,有些是分散的。总共大约有300个,它们需要在应用程序中可以点击 到目前为止,我已尝试使用此ImageMap库: 我编写了一个程序来为某些部分生成xml,但大多数图像需要通过将坐标硬编码到xml中来定义 我已经研究了一些OpenCV,这可能是一个可行的选择,但我对它太不熟悉了 有没有人有过类似的开发经验 编辑:这是我到目前为止使用ImageMap库得到的 图像地图视图 //add click handler i
//add click handler
imageMap.addOnImageMapClickedHandler( new ImageMap.OnImageMapClickedHandler()
{
@Override
public void onImageMapClicked(int id, ImageMap imageMap)
{
// when the area is tapped, show the name in a
// text bubble
Toast.makeText( imageMap.getContext(), "Booth: " + id , Toast.LENGTH_SHORT ).show();
Log.v("Booth: ", "" + id );
}
用于概念验证的XML
<?xml version="1.0" encoding="utf-8"?>
<maps xmlns:android="http://schemas.android.com/apk/res/android">
<map name="multimap">
<area coords="935,126,963,161" id="@+id/booth36" shape="rect"/>
<area coords="905,126,933,161" id="@+id/booth37" shape="rect"/>
<area coords="875,126,903,161" id="@+id/booth38" shape="rect"/>
<area coords="845,126,873,161" id="@+id/booth39" shape="rect"/>
<area coords="815,126,843,161" id="@+id/booth40" shape="rect"/>
<area coords="785,126,813,161" id="@+id/booth41" shape="rect"/>
<area coords="755,126,783enter code here,161" id="@+id/booth42" shape="rect"/>
<area coords="725,126,753,161" id="@+id/booth43" shape="rect"/>
<area coords="695,126,723,161" id="@+id/booth44" shape="rect"/>
<area coords="665,126,693,161" id="@+id/booth45" shape="rect"/>
<area coords="635,126,663,161" id="@+id/booth46" shape="rect"/>
<area coords="605,126,633,161" id="@+id/booth47" shape="rect"/>
<area coords="575,126,603,161" id="@+id/booth48" shape="rect"/>
<area coords="545,126,573,161" id="@+id/booth49" shape="rect"/>
<area coords="515,126,543,161" id="@+id/booth50" shape="rect"/>
<area coords="485,126,513,161" id="@+id/booth51" shape="rect"/>
<area coords="455,126,483,161" id="@+id/booth52" shape="rect"/>
<area coords="425,126,453,161" id="@+id/booth53" shape="rect"/>
<area coords="395,126,423,161" id="@+id/booth54" shape="rect"/>
<area coords="365,126,393,161" id="@+id/booth55" shape="rect"/>
<area coords="335,126,363,161" id="@+id/booth56" shape="rect"/>
<area coords="305,126,333,161" id="@+id/booth57" shape="rect"/>
<area coords="275,126,303,161" id="@+id/booth58" shape="rect"/>
<area coords="245,126,273,161" id="@+id/booth59" shape="rect"/>
<area coords="215,126,243,161" id="@+id/booth60" shape="rect"/>
<area coords="185,126,213,161" id="@+id/booth61" shape="rect"/>
<area coords="155,126,183,161" id="@+id/booth62" shape="rect"/>
<area coords="125,126,153,161" id="@+id/booth63" shape="rect"/>
<area coords="95,126,123,161" id="@+id/booth64" shape="rect"/>
<area coords="65,126,93,161" id="@+id/booth65" shape="rect"/>
</map>
你能发布你到目前为止所做的代码吗?它必须是一个图像,或者你是说你需要生成一个交错矩形的布局,等等?它可能是一个交错矩形的布局,我只是已经有了一个布局的图像。