Android 如何从parse中提取我想要的图片?

Android 如何从parse中提取我想要的图片?,android,parse-platform,Android,Parse Platform,我需要从解析中提取所有图像,我有这个代码,但它只返回最后一个图像,如何获得特定图像或根据连接的用户 public void PullImage(){ progressDialog = ProgressDialog.show(this, "", "Downloading Image...", true); ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("User"); /

我需要从解析中提取所有图像,我有这个代码,但它只返回最后一个图像,如何获得特定图像或根据连接的用户

public void PullImage(){

    progressDialog = ProgressDialog.show(this, "", "Downloading Image...", true);


    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("User");
    //  query.whereEqualTo("Column", bitmap);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        public void done(ParseObject object, ParseException e) {
            if (object != null) {

                ParseFile file = (ParseFile) object.get("ImageFile");

                file.getDataInBackground(new GetDataCallback() {


                    public void done(byte[] data, ParseException e) {
                        if (e == null) {

                            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);

                                    progressDialog.dismiss();
                        } else {
                            // something went wrong
                        }
                    }
                });

            } else {
                Toast.makeText(getApplicationContext(), "Exception", Toast.LENGTH_SHORT).show();

            }
        }
    });
}
public void PullImage(){
progressDialog=progressDialog.show(此为“,”正在下载图像…”,为true);
ParseQuery查询=新的ParseQuery(“用户”);
//query.whereEqualTo(“列”,位图);
getFirstInBackground(新的GetCallback(){
公共无效完成(ParseObject对象,parsee异常){
if(对象!=null){
ParseFile file=(ParseFile)object.get(“ImageFile”);
getDataInBackground(新的GetDataCallback(){
公共无效完成(字节[]数据,解析异常e){
如果(e==null){
位图=位图工厂.decodeByteArray(数据,0,数据.length);
progressDialog.disclose();
}否则{
//出了点问题
}
}
});
}否则{
Toast.makeText(getApplicationContext(),“Exception”,Toast.LENGTH\u SHORT.show();
}
}
});
}
尝试以下方法-

    public static Bitmap getBitmapFromParseImage(ParseFile image, int width , int height) {
    try {

            byte[] file = image.getData();
            InputStream inputStream = new ByteArrayInputStream(file);
            Bitmap image1 = CompressBitmap
                    .decodeSampledBitmapFromResourceMemOpt(inputStream, width,
                            height);
            return image1; 

        } catch (Exception e) {
            e.printStackTrace();
        }
     return null;
    }
CompressBitmap.java-

import java.io.InputStream;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class CompressBitmap {

    public static int calculateInSampleSize(BitmapFactory.Options options,
            int reqWidth, int reqHeight) {
        // Raw height and width of image
        final int height = options.outHeight;
        final int width = options.outWidth;
        int inSampleSize = 1;

        if (height > reqHeight || width > reqWidth) {



            final int halfHeight = height / 2;
            final int halfWidth = width / 2;

            // Calculate the largest inSampleSize value that is a power of 2 and
            // keeps both
            // height and width larger than the requested height and width.
            while ((halfHeight / inSampleSize) > reqHeight
                    && (halfWidth / inSampleSize) > reqWidth) {
                inSampleSize *= 2;
            }
        }

        return inSampleSize;
    }
      public static Bitmap decodeSampledBitmapFromResourceMemOpt(
                InputStream inputStream, int reqWidth, int reqHeight) {

            byte[] byteArr = new byte[0];
            byte[] buffer = new byte[1024];
            int len;
            int count = 0;

            try {
                while ((len = inputStream.read(buffer)) > -1) {
                    if (len != 0) {
                        if (count + len > byteArr.length) {
                            byte[] newbuf = new byte[(count + len) * 2];
                            System.arraycopy(byteArr, 0, newbuf, 0, count);
                            byteArr = newbuf;
                        }

                        System.arraycopy(buffer, 0, byteArr, count, len);
                        count += len;
                    }
                }

                final BitmapFactory.Options options = new BitmapFactory.Options();
                options.inJustDecodeBounds = true;
                BitmapFactory.decodeByteArray(byteArr, 0, count, options);

                options.inSampleSize = calculateInSampleSize(options, reqWidth,
                        reqHeight);
                options.inPurgeable = true;
                options.inInputShareable = true;
                options.inJustDecodeBounds = false;
                options.inPreferredConfig = Bitmap.Config.ARGB_8888;

               // int[] pids = { android.os.Process.myPid() };
               // MemoryInfo myMemInfo = mAM.getProcessMemoryInfo(pids)[0];
               // Log.e(TAG, "dalvikPss (decoding) = " + myMemInfo.dalvikPss);

                return BitmapFactory.decodeByteArray(byteArr, 0, count, options);

            } catch (Exception e) {
                e.printStackTrace();

                return null;
            }
        }
}

我在压缩位图中出错。我需要把代码放在哪里?很抱歉,我是这个topicok的新手,我现在没有错误,但我需要了解这段代码需要向我显示什么?首先,我提到的代码名显示为位图,当我将此位图发送到imagview时,它会在imageview中向我显示保存的最后一幅图像