本文整理汇总了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();
}
示例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;
}
}
示例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);
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
}
示例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);
}
示例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();
}
}
示例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();
}