0

有什么办法可以提高设置图像的速度吗?我想说的是假设我有数百张图像,并且每个图像都可以自动更改或通过按前进/后退按钮进行更改。(想想媒体播放器的情况,您可以前进或倒退尽可能多的文件,就像我对图像和后面的一些音频所做的那样)。

现在,如果我连续按住 RW/FW 按钮,布局会显示一段时间为黑色或要求强制关闭或等待应用程序。

有人知道如何提高读取位图并将其设置为图像视图的速度吗?

这是我的代码的一部分,

  private void playAudio() {
    msg = new Message();
    msg.obj = (filepath);
    imageHandler.sendMessage(msg);
 } 

 private Handler imageHandler = new Handler() {
    public void handleMessage(Message msg) {

        try {
            path = (String) msg.obj;
            imagePath = RaconTours.PATH + path;
            imagenamearray = imagePath.split("/");
            currentImagename = imagenamearray[8];
            i++;
            if (!imagePath.equalsIgnoreCase(staticpath)) {
                isSeekBarChangedManually = false;
                staticpath = imagePath;
                Bitmap snoop = readBitmap(Uri.fromFile(new File(filepath)));
                image.setImageBitmap(snoop);
                image.setMaxZoom(4f);
           } catch (Exception e) {
                e.printStackTrace();
          }
     }
};

希望您对这段代码有所了解,这只是大蛋糕的一小部分。

我没有得到解决这个问题的方法。我也尝试禁用该按钮,直到正在执行某些操作,但这也没有用。

任何帮助,干杯

4

1 回答 1

0

I think the only way to make this process "faster" is to load and cache the bitmaps in a buffer before you actually need them. When you need a bitmap, you check this forward-cache to see if it's already loaded. If it is, then it means it's already in memory -> you just need to set it for the proper ImageView (or whatever you use). If not, then you load it from the disk.

Of course, you need to know that which bitmaps you'll need most likely in the near future for this to work.

You can't really make disk I/O work any faster you see.

于 2012-04-24T10:43:49.747 回答