我的项目我有一个类,在这个类中我想要访问图片的属性.但我不想通过这堂课来展示它.在这个课程中,我只想知道图像的宽度和高度,并做一些数学函数来返回一些东西. 我的问题是我不知
          我的问题是我不知道该如何处理这张照片.我的照片在drawable文件夹中.我写的代码是,问题是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;
    }
}
 存储在应用程序资源中的图像,您可以通过android.graphics.Bitmap完全处理 
  
  
 Bitmap image = BitmapFactory.decodeResource(this.getResources(), R.drawable.tasnim);
    imWidth = image.getWidth();
    imHeight = image.getHeight();
        
             