Example usage for android.graphics Bitmap toString

List of usage examples for android.graphics Bitmap toString

Introduction

In this page you can find the example usage for android.graphics Bitmap toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:Main.java

/**
 * Allows decoding of a bitmap with a specified height and width.
 * // www.  j  a  v a2  s . c  o  m
 * Modified from the Android developer tutorial. Original source can be
 * found at {@link http
 * ://developer.android.com/training/displaying-bitmaps/load-bitmap.html}
 * 
 * @param filename
 *            The filename of the file to be decoded.
 * @param reqWidth
 *            The preferred width of the output bitmap.
 * @param reqHeight
 *            The preferred height of the output bitmap.
 * @return the decoded bitmap, or null
 */
public static Bitmap decodeSampledBitmapFromFile(String filename, float reqWidth, float reqHeight) {
    Log.v(TAG, "Recieved " + filename + " with (w,h): (" + reqWidth + ", " + reqHeight + ").");
    // First decode with inJustDecodeBounds=true to check dimensions
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(filename, options);

    // Calculate inSampleSize
    options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

    // Decode bitmap with inSampleSize set
    options.inJustDecodeBounds = false;
    Bitmap decodedBitmap = BitmapFactory.decodeFile(filename, options);
    Log.v(TAG, "The Bitmap is " + decodedBitmap.toString());
    return decodedBitmap;
}

From source file:com.google.samples.apps.iosched.nearby.MetadataResolver.java

/**
 * Asynchronously download the image for the nearby device.
 * @param metadata/*from  w ww .j  av a 2  s .  c  om*/
 * @param listener
 */
private static void downloadIcon(final DeviceMetadata metadata, final OnMetadataListener listener) {
    ImageRequest imageRequest = new ImageRequest(metadata.iconUrl, new Response.Listener<Bitmap>() {
        @Override
        public void onResponse(Bitmap response) {
            Log.i(TAG, "Got an image: " + response.toString());
            metadata.icon = response;
            listener.onDeviceInfo(metadata);
        }
    }, 0, 0, null, null);
    mRequestQueue.add(imageRequest);
}

From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.Safe.java

public static void loadPeer() {
    Log.d("onCreateView", "Safe: loadPeer: start");
    /*/*from   w  w  w  .  j  ava2 s .  c  o m*/
     * very IMPORTANT! The list and peers must be clear every time when the
     * Fragment get created, otherwise, duplicate entries might occur!!!
     */
    list.clear();
    peers.clear();

    synchronized (Orgs.monitor) {
        // pull out all safes from database
        if (Application_GUI.dbmail == null)
            Application_GUI.dbmail = new Android_DB_Email(Safe.safeItself.getActivity());
        if (Application_GUI.gui == null)
            Application_GUI.gui = new Android_GUI();
        if (Application.db == null) {
            try {

                DBInterface db = new DBInterface("deliberation-app.db");
                Application.db = db;
            } catch (P2PDDSQLException e1) {
                e1.printStackTrace();
            }
        }
    }
    Log.d("onCreateView", "Safe: loadPeer: database loaded");

    ArrayList<ArrayList<Object>> peer_IDs = D_Peer.getAllPeers();
    Log.d("onCreateView", "Safe: loadPeer: found peers: #" + peer_IDs.size());

    if (peer_IDs.size() == 0) {
        // testPeerCreation();
        // peer_IDs = D_Peer.getAllPeers();
        // Log.d("onCreateView", "Safe: onCreateView: re-found peers: #" +
        // peer_IDs.size());
    } else {
        Main.startServers();
    }

    for (ArrayList<Object> peer_data : peer_IDs) {
        if (peer_data.size() <= 0)
            continue;
        String p_lid = Util.getString(peer_data.get(0));
        D_Peer peer = D_Peer.getPeerByLID(p_lid, true, false);
        if (peer == null || (SAFE_HIDE && peer.getHidden()))
            continue;
        peers.add(peer);
    }

    Log.d("onCreateView", "Safe: loadPeer: build peers data for #" + peers.size());
    data = new String[peers.size()][];
    Log.d(TAG, "safe data size: " + data.length);

    imgData = new ArrayList<Bitmap>();

    for (int k = 0; k < peers.size(); k++) {
        D_Peer p = peers.get(k);

        // if a safe has private key then use getname... to be implemented
        data[k] = new String[] { p.getName_MyOrDefault(), p.getEmail(), p.getSlogan_MyOrDefault() };

        boolean gotIcon = false;
        try {
            byte[] icon = p.getIcon();
            if (icon != null) {
                Bitmap bmp = BitmapFactory.decodeByteArray(icon, 0, icon.length - 1);
                gotIcon = true;
                Log.d(TAG, "image bmp: " + bmp.toString());
                imgData.add(bmp);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!gotIcon) {
            int imgId = R.drawable.placeholder;
            Log.d(TAG, "image path: " + imgId);
            Bitmap bmp = PhotoUtil.decodeSampledBitmapFromResource(Safe.safeItself.getResources(), imgId, 55,
                    55);
            Log.d(TAG, "image bmp: " + bmp.toString());
            imgData.add(bmp);
        }
    }
    if (data.length > 0 && data[0].length > 0)
        Log.d(TAG, "safe name: " + data[0][0]);
    /*
     * Identity.init_Identity();
     * 
     * HandlingMyself_Peer.loadIdentity(null);
     * 
     * try { DD.startUServer(true, Identity.current_peer_ID);
     * DD.startServer(false, Identity.current_peer_ID);
     * DD.startClient(true);
     * 
     * } catch (NumberFormatException | P2PDDSQLException e) {
     * System.err.println("Safe: onCreateView: error"); e.printStackTrace();
     * }
     * 
     * try { DD.load_listing_directories(); } catch (NumberFormatException |
     * UnknownHostException | P2PDDSQLException e) { e.printStackTrace(); }
     * D_Peer myself = HandlingMyself_Peer.get_myself();
     * myself.addAddress(Identity.listing_directories_addr.get(0), true,
     * null);
     */

    // end of data pulling out

    Log.d("onCreateView", "Safe: onCreateView: fill GUI list");
    // using a map datastructure to store data for listview
    /*
     * for (int i = 0; i < this.data.length; i++) { Map<String, String> map
     * = new HashMap<String, String>(); map.put("name", this.data[i][0]);
     * map.put("email", this.data[i][1]); map.put("slogan",
     * this.data[i][2]);
     * 
     * map.put("pic", String.valueOf(R.drawable.placeholder));
     * 
     * this.list.add(map); }
     */

    for (int i = 0; i < Safe.data.length; i++) {
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(SAFE_LIST_NAME, Safe.data[i][0]);
        map.put(SAFE_LIST_EMAIL, Safe.data[i][1]);
        map.put(SAFE_LIST_SLOGAN, Safe.data[i][2]);

        map.put("pic", String.valueOf(R.drawable.placeholder));

        list.add(map);
    }

    Log.d(TAG, "safe size: " + list.size());

    Log.d(TAG, "safe: list hash at safe: " + list.hashCode() + " size: " + Safe.list.size());
}

From source file:com.pizidea.imagepicker.ui.demo.MainActivity.java

@Override
public void onImageCropComplete(Bitmap bmp, float ratio) {
    Log.i(TAG, "=====onImageCropComplete (get bitmap=" + bmp.toString());
    ivCrop.setVisibility(View.VISIBLE);
    ivCrop.setImageBitmap(bmp);//from ww  w.ja  va  2  s. co m
}

From source file:at.wada811.android.library.demos.loader.LoaderListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;/*from w w  w  .  j  a va 2 s .com*/
    View view = convertView;
    if (view == null) {
        view = mLayoutInflater.inflate(R.layout.fragment_loader_list_item, null);
        ImageView imageView = (ImageView) view.findViewById(R.id.image);
        TextView titleView = (TextView) view.findViewById(R.id.title);
        TextView urlView = (TextView) view.findViewById(R.id.url);
        holder = new ViewHolder();
        holder.imageView = imageView;
        holder.titleView = titleView;
        holder.urlView = urlView;
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }
    final ViewHolder viewHolder = holder;
    final LoaderListItem item = (LoaderListItem) getItem(position);
    Bitmap bitmap = LoaderListFragment.sImageCache.get(item.getThumbnailUrl());
    if (bitmap == null) {
        holder.imageView.setImageBitmap(bitmap);
        Bundle args = new Bundle();
        args.putInt(KEY_POSITION, position);
        args.putString(KEY_IMAGE_URL, item.getThumbnailUrl());
        // LoaderListFragment?LoaderId????
        int offset = 100;
        mLoaderIds.put(position, position + offset);
        mLoaderManager.initLoader(mLoaderIds.get(position), args, new LoaderCallbacks<Bitmap>() {
            @Override
            public Loader<Bitmap> onCreateLoader(int id, Bundle args) {
                LogUtils.d("LoaderId: " + id);
                return new AsyncImageDownloadLoader(mContext, args);
            }

            @Override
            public void onLoadFinished(Loader<Bitmap> loader, final Bitmap data) {
                LogUtils.d("LoaderId: " + loader.getId());
                LogUtils.d("data: " + (data == null ? data : data.toString()));
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        viewHolder.imageView.setImageBitmap(data);
                    }
                });
            }

            @Override
            public void onLoaderReset(Loader<Bitmap> loader) {
                LogUtils.i();
            }
        });
    }
    holder.titleView.setText(item.getImageTitle());
    holder.urlView.setText(item.getImageUrl());
    return view;

}

From source file:com.general.myapplication.ImagePickerActivity.java

@Override
public void onClick(View v) {

    Intent intent = new Intent();
    int requestCode = REQ_IMAGE;

    boolean isShowCamera = cbShowCamera.isChecked();

    switch (v.getId()) {

    case R.id.btn_single:
        /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_SINGLE);
        AndroidImagePicker.getInstance().setShouldShowCamera(false);
        break;*///from w  w w  .  jav a  2 s.  co m
        AndroidImagePicker.getInstance().pickSingle(ImagePickerActivity.this, isShowCamera,
                new AndroidImagePicker.OnImagePickCompleteListener() {
                    @Override
                    public void onImagePickComplete(List<ImageItem> items) {
                        if (items != null && items.size() > 0) {
                            Log.i(TAG, "=====" + items.get(0).path);
                            mAdapter.clear();
                            mAdapter.addAll(items);
                        }
                    }
                });
        return;
    case R.id.btn_multi:
        /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_MULTI);
        AndroidImagePicker.getInstance().setShouldShowCamera(false);
        break;*/
        AndroidImagePicker.getInstance().pickMulti(ImagePickerActivity.this, isShowCamera,
                new AndroidImagePicker.OnImagePickCompleteListener() {
                    @Override
                    public void onImagePickComplete(List<ImageItem> items) {
                        if (items != null && items.size() > 0) {
                            Log.i(TAG, "=====" + items.get(0).path);
                            mAdapter.clear();
                            mAdapter.addAll(items);
                        }
                    }
                });
        return;

    case R.id.btn_crop:

        AndroidImagePicker.getInstance().pickAndCrop(ImagePickerActivity.this, true, 120,
                new AndroidImagePicker.OnImageCropCompleteListener() {
                    @Override
                    public void onImageCropComplete(Bitmap bmp, float ratio) {
                        Log.i(TAG, "=====onImageCropComplete (get bitmap=" + bmp.toString());
                        ivCrop.setVisibility(View.VISIBLE);
                        ivCrop.setImageBitmap(bmp);
                    }
                });

        return;

    /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_SINGLE);
    AndroidImagePicker.getInstance().setShouldShowCamera(true);
    intent.putExtra("isCrop", true);
    AndroidImagePicker.getInstance().cropMode = true;
    requestCode = REQ_IMAGE_CROP;*/
    default:
        break;

    }

    intent.setClass(this, ImagesGridActivity.class);
    startActivityForResult(intent, requestCode);

}

From source file:com.mgfypy.esafeboximagelibrary.MainActivity.java

@Override
public void onClick(View v) {

    Intent intent = new Intent();
    int requestCode = REQ_IMAGE;

    boolean isShowCamera = cbShowCamera.isChecked();

    switch (v.getId()) {

    case R.id.btn_single:
        /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_SINGLE);
        AndroidImagePicker.getInstance().setShouldShowCamera(false);
        break;*//*from   w w  w.ja  va2s  .  c o m*/
        AndroidImagePicker.getInstance().pickSingle(MainActivity.this, isShowCamera,
                new AndroidImagePicker.OnImagePickCompleteListener() {
                    @Override
                    public void onImagePickComplete(List<ImageItem> items) {
                        if (items != null && items.size() > 0) {
                            Log.i(TAG, "=====" + items.get(0).path);
                            mAdapter.clear();
                            mAdapter.addAll(items);
                        }
                    }
                });
        return;
    case R.id.btn_multi:
        /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_MULTI);
        AndroidImagePicker.getInstance().setShouldShowCamera(false);
        break;*/
        AndroidImagePicker.getInstance().pickMulti(MainActivity.this, isShowCamera,
                new AndroidImagePicker.OnImagePickCompleteListener() {
                    @Override
                    public void onImagePickComplete(List<ImageItem> items) {
                        if (items != null && items.size() > 0) {
                            Log.i(TAG, "=====" + items.get(0).path);
                            mAdapter.clear();
                            mAdapter.addAll(items);
                        }
                    }
                });
        return;

    case R.id.btn_crop:

        AndroidImagePicker.getInstance().pickAndCrop(MainActivity.this, true, 120,
                new AndroidImagePicker.OnImageCropCompleteListener() {
                    @Override
                    public void onImageCropComplete(Bitmap bmp, float ratio) {
                        Log.i(TAG, "=====onImageCropComplete (get bitmap=" + bmp.toString());
                        ivCrop.setVisibility(View.VISIBLE);
                        ivCrop.setImageBitmap(bmp);
                    }
                });

        return;

    /*AndroidImagePicker.getInstance().setSelectMode(AndroidImagePicker.Select_Mode.MODE_SINGLE);
    AndroidImagePicker.getInstance().setShouldShowCamera(true);
    intent.putExtra("isCrop", true);
    AndroidImagePicker.getInstance().cropMode = true;
    requestCode = REQ_IMAGE_CROP;*/
    default:
        break;

    }

    intent.setClass(this, ImagesGridActivity.class);
    startActivityForResult(intent, requestCode);

}

From source file:com.lcl6.cn.imagepickerl.AndroidImagePicker.java

public void notifyImageCropComplete(Bitmap bmp, int ratio) {
    if (mImageCropCompleteListeners != null) {
        Log.i(TAG, "=====notify onImageCropCompleteListener  bitmap=" + bmp.toString() + "  ratio=" + ratio);
        for (OnImageCropCompleteListener l : mImageCropCompleteListeners) {
            l.onImageCropComplete(bmp, ratio);
        }//from   w ww  .  j a  va  2 s  .co  m
    }
}

From source file:com.sina.weibo.sdk.demo.sample.activity.TestFragment.java

public void showLargeImg(final Context context, final String url) {
    View view = LayoutInflater.from(context).inflate(R.layout.img_large, null);
    final ZoomImageView zoomImageView = (ZoomImageView) view.findViewById(R.id.id_iv_large);
    final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.id_pb_load);
    alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setView(view);/* ww w  .ja  v  a 2 s .  co  m*/
    alertDialog.show();
    progressBar.setVisibility(View.VISIBLE);
    Target target = new Target() {
        @Override
        public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
            Log.d("", "?" + bitmap.toString());
            progressBar.setVisibility(View.GONE);
            zoomImageView.setImageBitmap(bitmap, iZoomViewListener);
            zoomImageView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onBitmapFailed(Drawable errorDrawable) {

        }

        @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {
            Log.d("", "onPrepareLoad");
        }
    };
    zoomImageView.setTag(target);
    Picasso.with(context).load(url).into(target);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            alertDialog.cancel();
            progressBar.setVisibility(View.GONE);
        }
    });
}

From source file:com.pizidea.imagepicker.AndroidImagePicker.java

public synchronized void notifyImageCropComplete(Bitmap bmp, int ratio) {
    if (mImageCropCompleteListeners != null && mImageCropCompleteListeners.size() > 0 && bmp != null) {
        Log.i(TAG, "=====notify onImageCropCompleteListener  bitmap=" + bmp.toString() + "  ratio=" + ratio);
        for (OnImageCropCompleteListener l : mImageCropCompleteListeners) {
            l.onImageCropComplete(bmp, ratio);
        }/*from ww  w. j a v a 2 s . c o  m*/
    }
}