示例#1
0
 /**
  * * Get the Drawable from URL
  *
  * @param urlString
  * @return
  */
 public Drawable fetchDrawable(String urlString) {
   try {
     Bitmap bitmap =
         ImageLoader.getInstance()
             .loadImageSync(urlString, ImageHelper.getDefaultDisplayImageOptions());
     //                InputStream is = fetch(urlString);
     //                Drawable drawable = Drawable.createFromStream(is, "src");
     Drawable drawable = new BitmapDrawable(bitmap);
     int tempWidth =
         bitmap.getScaledWidth(MainApplication.getInstance().getResources().getDisplayMetrics());
     int height =
         bitmap.getScaledHeight(MainApplication.getInstance().getResources().getDisplayMetrics())
             * 2
             / 3;
     //                drawable.setBounds(0,0,tempWidth,height);
     LogHelper.e("omg", "normal  " + tempWidth + " -" + height);
     LogHelper.e(
         "omg",
         "page  "
             + MainApplication.getInstance().getPageWidth()
             + " -"
             + MainApplication.getInstance().getPageHeight());
     int width = MainApplication.getInstance().getPageWidth();
     float leftPadding =
         MainApplication.getInstance()
             .getResources()
             .getDimension(R.dimen.ct_personal_desc_left_padding);
     float topPadding =
         MainApplication.getInstance()
             .getResources()
             .getDimension(R.dimen.ct_personal_desc_top_padding);
     //                height =  width * height /tempWidth ;
     drawable.setBounds(
         (int) leftPadding,
         0,
         (width > 0 ? width : 0) - (int) leftPadding * 2,
         (height > 0 ? height : 0));
     LogHelper.e(
         "omg", "bound " + drawable.getBounds().width() + " - " + drawable.getBounds().height());
     return drawable;
   } catch (Exception e) {
     return null;
   }
 }
 private void computeBitmapSize() {
   mBitmapWidth = mBitmap.getScaledWidth(mTargetDensity);
   mBitmapHeight = mBitmap.getScaledHeight(mTargetDensity);
 }