我的项目我有一个类,在这个类中,我想访问图片的属性。但我不想在这堂课上表现出来。在这门课上,我只想知道图像的宽度和高度,并做一些数学函数来返回一些东西。
我的问题是我不知道该怎么处理这张照片。我的照片在可抽出的文件夹里。我编写的代码是,问题是image=(ImageView)findViewById(R.id.imViewRaw);:
import android.view.View;
import android.widget.ImageView;
public class Stego
{
private ImageView image;
private int imWidth, imHeight;
public Stego()
{
// Instantiate an ImageView and define its properties
image = (ImageView)findViewById(R.id.imViewRaw);
image.setImageResource(R.drawable.tasnim);
imWidth = image.getWidth();
imHeight = image.getHeight();
}
public int getImageWidth(){
return imWidth;
}
public int getImageHeight(){
return imHeight;
}
public int getMaxMessageChars(){
int i = imWidth * imHeight; //Number of Pixels
i *= 3; //Number of bytes. (Each pixel includes of three RGB bytes)
i /= 4; //Maximum number of characters to store in the picture
return i;
}
}