当前位置: 首页>>代码示例>>Java>>正文


Java BitmapHelper类代码示例

本文整理汇总了Java中com.mob.tools.utils.BitmapHelper的典型用法代码示例。如果您正苦于以下问题:Java BitmapHelper类的具体用法?Java BitmapHelper怎么用?Java BitmapHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BitmapHelper类属于com.mob.tools.utils包,在下文中一共展示了BitmapHelper类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: a

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
private Bitmap a(Context context, String str) {
    File file = new File(str);
    if (file.exists()) {
        CompressFormat bmpFormat = BitmapHelper.getBmpFormat(str);
        int dipToPx = R.dipToPx(context, 120);
        if (CompressFormat.PNG == bmpFormat) {
            dipToPx = R.dipToPx(context, 90);
        }
        Bitmap decodeFile = BitmapFactory.decodeFile(str, new Options());
        if (file.length() > this.b) {
            Bitmap bitmap = decodeFile;
            while (dipToPx > 40 && a(bitmap, bmpFormat) > 32768) {
                int i = dipToPx - 5;
                int width = bitmap.getWidth();
                int height = bitmap.getHeight();
                double d = (height > i || width > i) ? height > width ? ((double) i) / ((double) height) : ((double) i) / ((double) width) : PathListView.NO_ZOOM;
                bitmap = Bitmap.createScaledBitmap(bitmap, (int) (((double) width) * d), (int) (d * ((double) height)), true);
                dipToPx = i;
            }
            OutputStream fileOutputStream = new FileOutputStream(File.createTempFile("sina_bm_tmp", "." + bmpFormat.name().toLowerCase()));
            bitmap.compress(bmpFormat, 100, fileOutputStream);
            fileOutputStream.flush();
            fileOutputStream.close();
            return bitmap;
        }
        Ln.i("sina weibo decode bitmap size ==>>" + a(decodeFile, bmpFormat), new Object[0]);
        return decodeFile;
    }
    throw new FileNotFoundException();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:31,代码来源:SinaActivity.java

示例2: getCropedBitmap

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
public Bitmap getCropedBitmap(Rect rect) {
    try {
        Bitmap captureView = BitmapHelper.captureView(this, getWidth(), getHeight());
        if (captureView == null) {
            Ln.w("ivPhoto.getDrawingCache() returns null", new Object[0]);
            return null;
        }
        Bitmap createBitmap = Bitmap.createBitmap(captureView, rect.left, rect.top, rect
                .width(), rect.height());
        captureView.recycle();
        return createBitmap;
    } catch (Throwable th) {
        Ln.w(th);
        return null;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:ScaledImageView.java

示例3: setBitmap

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
public void setBitmap(Bitmap bitmap) {
    this.bitmap = bitmap;
    setImageBitmap(bitmap);
    int[] iArr = new int[]{this.bitmap.getWidth(), this.bitmap.getHeight()};
    int[] fixRect = BitmapHelper.fixRect(iArr, new int[]{getWidth(), getHeight()});
    int[] iArr2 = new int[]{(r0[0] - fixRect[0]) / 2, (r0[1] - fixRect[1]) / 2};
    float[] fArr = new float[]{((float) fixRect[0]) / ((float) iArr[0]), ((float) fixRect[1])
            / ((float) iArr[1])};
    this.matrix = new Matrix();
    this.matrix.set(getImageMatrix());
    this.matrix.postScale(fArr[0], fArr[1]);
    this.matrix.postTranslate((float) iArr2[0], (float) iArr2[1]);
    if (this.listener != null) {
        this.listener.onMactrixChage(this.matrix);
    }
    setImageMatrix(this.matrix);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:ScaledImageView.java

示例4: a

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
private void a(cn.sharesdk.framework.Platform.ShareParams shareParams) {
    if (shareParams.getImageData() == null && TextUtils.isEmpty(shareParams.getImagePath()) && !TextUtils.isEmpty(shareParams.getImageUrl())) {
        try {
            File file = new File(BitmapHelper.downloadBitmap(getContext(), shareParams.getImageUrl()));
            if (file.exists()) {
                shareParams.setImagePath(file.getAbsolutePath());
            }
        } catch (Throwable th) {
            Ln.e(th);
        }
    }
    Intent intent = new Intent();
    intent.putExtra("platformID", 1);
    intent.putExtra("action", 2);
    a aVar = new a(this, this.a, this.c);
    aVar.a(this.listener, shareParams, this.d);
    aVar.show(getContext(), intent);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:SinaWeibo.java

示例5: setViewToShare

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
/** 设置一个将被截图分享的View , surfaceView是截不了图片的*/
public void setViewToShare(View viewToShare) {
	try {
		Bitmap bm = BitmapHelper.captureView(viewToShare, viewToShare.getWidth(), viewToShare.getHeight());
		params.put("viewToShare", bm);
	} catch (Throwable e) {
		e.printStackTrace();
	}
}
 
开发者ID:gaolhjy,项目名称:cniao5,代码行数:10,代码来源:OnekeyShare.java

示例6: onPicCrop

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
protected void onPicCrop(Bitmap bitmap) {
	aivAvatar.setBitmap(bitmap);
	try {
		userAvatar = BitmapHelper.saveBitmap(activity, bitmap);
	} catch (Throwable t) {
		t.printStackTrace();
	}
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:9,代码来源:PageInitProfile.java

示例7: goCrop

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
private Bitmap goCrop(Bitmap bitmap) {
    float width = (float) bitmap.getWidth();
    float height = (float) bitmap.getHeight();
    if (!(width == 0.0f || height == 0.0f)) {
        int[] size = getSize();
        if (!(size[0] == 0 || size[1] == 0)) {
            float f = (((float) size[1]) * width) / ((float) size[0]);
            if (f != height) {
                int[] iArr = new int[4];
                if (f < height) {
                    iArr[1] = (int) ((height - f) / 2.0f);
                    iArr[3] = iArr[1];
                } else {
                    iArr[0] = (int) ((width - ((height * ((float) size[0])) / ((float)
                            size[1]))) / 2.0f);
                    iArr[2] = iArr[0];
                }
                try {
                    bitmap = BitmapHelper.cropBitmap(bitmap, iArr[0], iArr[1], iArr[2],
                            iArr[3]);
                } catch (Throwable th) {
                    Ln.w(th);
                }
            }
        }
    }
    return bitmap;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:AsyncImageView.java

示例8: goRound

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
private Bitmap goRound(Bitmap bitmap) {
    try {
        int[] size = getSize();
        bitmap = BitmapHelper.roundBitmap(bitmap, size[0], size[1], this.rect[0], this
                .rect[1], this.rect[2], this.rect[3]);
    } catch (Throwable th) {
        Ln.w(th);
    }
    return bitmap;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:AsyncImageView.java

示例9: setViewToShare

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
public void setViewToShare(View viewToShare) {
    try {
        this.shareParamsMap.put("viewToShare", BitmapHelper.captureView(viewToShare, viewToShare.getWidth(), viewToShare.getHeight()));
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:OnekeyShare.java

示例10: genBackground

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
private void genBackground() {
    this.background = new ColorDrawable(DIM_COLOR);
    if (this.backgroundView != null) {
        try {
            Bitmap bgBm = BitmapHelper.blur(BitmapHelper.captureView(this.backgroundView, this.backgroundView.getWidth(), this.backgroundView.getHeight()), 20, 8);
            this.background = new LayerDrawable(new Drawable[]{new BitmapDrawable(this.activity.getResources(), bgBm), this.background});
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:EditPage.java

示例11: a

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
private byte[] a(Context context, byte[] bArr) {
    CompressFormat bmpFormat = BitmapHelper.getBmpFormat(bArr);
    int dipToPx = R.dipToPx(context, 120);
    if (CompressFormat.PNG == bmpFormat) {
        dipToPx = R.dipToPx(context, 90);
    }
    Options options = new Options();
    if (bArr.length > 32768) {
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeByteArray(bArr, 0, bArr.length, options);
        options.inSampleSize = a(options, dipToPx, dipToPx);
    }
    options.inJustDecodeBounds = false;
    return a(context, BitmapFactory.decodeByteArray(bArr, 0, bArr.length, options), bmpFormat);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:WechatHelper.java

示例12: setViewToShare

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
/** 设置一个将被截图分享的View , surfaceView是截不了图片的 */
public void setViewToShare(View viewToShare) {
  try {
    Bitmap bm = BitmapHelper.captureView(viewToShare, viewToShare.getWidth(), viewToShare.getHeight());
    params.put("viewToShare", bm);
  } catch (Throwable e) {
    e.printStackTrace();
  }
}
 
开发者ID:zfdang,项目名称:zSMTH-Android,代码行数:10,代码来源:OnekeyShare.java

示例13: cropSquareBitmap

import com.mob.tools.utils.BitmapHelper; //导入依赖的package包/类
private void cropSquareBitmap(final String imgPath, final int sideWidth) {
	new Thread() {
		public void run() {
			try {
				Bitmap bitmap = BitmapHelper.getBitmapByCompressSize(imgPath, sideWidth, sideWidth);
				int bWidth = bitmap.getWidth();
				int bHeight = bitmap.getHeight();
				Bitmap scaledBitmap;
				if (bWidth < sideWidth && bHeight < sideWidth) {
					if (bWidth > bHeight) {
						bWidth = bWidth * sideWidth / bHeight;
						bHeight = sideWidth;
					} else {
						bHeight = bHeight * sideWidth / bWidth;
						bWidth = sideWidth;
					}
					scaledBitmap = Bitmap.createScaledBitmap(bitmap, bWidth, bHeight, false);
				} else if (bWidth <= sideWidth) {
					scaledBitmap = Bitmap.createScaledBitmap(bitmap, sideWidth, bHeight * sideWidth / bWidth, false);
				} else if (bHeight <= sideWidth) {
					scaledBitmap = Bitmap.createScaledBitmap(bitmap, bWidth * sideWidth / bHeight, sideWidth, false);
				} else {
					scaledBitmap = bitmap;
				}
				int scaledWidth = scaledBitmap.getWidth();
				int scaledHeight = scaledBitmap.getHeight();
				int x = 0;
				int y = 0;
				if (scaledWidth > sideWidth) {
					x = (scaledWidth - sideWidth) / 2;
				}
				if (scaledHeight > sideWidth) {
					y = (scaledHeight - sideWidth) / 2;
				}
				Bitmap cropBitmap = Bitmap.createBitmap(scaledBitmap, x, y, sideWidth, sideWidth);
				sendPicCrop(cropBitmap);
				return;
			} catch (Throwable t) {
				t.printStackTrace();
			}
			sendPicCrop(null);
		}
	}.start();
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:45,代码来源:SelectPicBasePageWithTitle.java


注:本文中的com.mob.tools.utils.BitmapHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。