本文整理汇总了Java中com.netease.nim.uikit.common.util.media.ImageUtil类的典型用法代码示例。如果您正苦于以下问题:Java ImageUtil类的具体用法?Java ImageUtil怎么用?Java ImageUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageUtil类属于com.netease.nim.uikit.common.util.media包,在下文中一共展示了ImageUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setImageView
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
private void setImageView(final IMMessage msg) {
String path = ((SnapChatAttachment) msg.getAttachment()).getPath();
if (TextUtils.isEmpty(path)) {
image.setImageBitmap(ImageUtil.getBitmapFromDrawableRes(getImageResOnLoading()));
return;
}
Bitmap bitmap = BitmapDecoder.decodeSampledForDisplay(path, false);
bitmap = ImageUtil.rotateBitmapInNeeded(path, bitmap);
if (bitmap == null) {
Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
image.setImageBitmap(ImageUtil.getBitmapFromDrawableRes(getImageResOnFailed()));
} else {
image.setImageBitmap(bitmap);
}
}
示例2: setThumbnail
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
/**
* ******************************** 设置图片 *********************************
*/
private void setThumbnail(IMMessage msg) {
String thumbPath = ((ImageAttachment) msg.getAttachment()).getThumbPath();
String path = ((ImageAttachment) msg.getAttachment()).getPath();
Bitmap bitmap = null;
if (!TextUtils.isEmpty(thumbPath)) {
bitmap = BitmapDecoder.decodeSampledForDisplay(thumbPath);
bitmap = ImageUtil.rotateBitmapInNeeded(thumbPath, bitmap);
} else if (!TextUtils.isEmpty(path)) {
bitmap = BitmapDecoder.decodeSampledForDisplay(path);
bitmap = ImageUtil.rotateBitmapInNeeded(path, bitmap);
}
if (bitmap != null) {
image.setImageBitmap(bitmap);
return;
}
image.setImageBitmap(ImageUtil.getBitmapFromDrawableRes(getImageResOnLoading()));
}
示例3: setImageView
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
private void setImageView(final IMMessage msg) {
String path = ((ImageAttachment) msg.getAttachment()).getPath();
if (TextUtils.isEmpty(path)) {
image.setImageBitmap(ImageUtil.getBitmapFromDrawableRes(getImageResOnLoading()));
return;
}
Bitmap bitmap = BitmapDecoder.decodeSampledForDisplay(path, false);
bitmap = ImageUtil.rotateBitmapInNeeded(path, bitmap);
if (bitmap == null) {
Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
image.setImageBitmap(ImageUtil.getBitmapFromDrawableRes(getImageResOnFailed()));
} else {
image.setImageBitmap(bitmap);
}
}
示例4: initCropImageView
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
private void initCropImageView() {
cropImageView = (CropImageView) findViewById(R.id.cropable_image_view);
Intent intent = getIntent();
final String srcFile = intent.getStringExtra(Extras.EXTRA_SRC_FILE);
int outputX = intent.getIntExtra(Extras.EXTRA_OUTPUTX, 0);
int outputY = intent.getIntExtra(Extras.EXTRA_OUTPUTY, 0);
cropImageView.setOutput(outputX, outputY);
// 抛到下一个UI循环,等到我们的activity真正到了前台
// 否则可能会获取不到openGL的最大texture size,导致解出的bitmap过大,显示不了
new Handler().post(new Runnable() {
@Override
public void run() {
Bitmap src = BitmapDecoder.decodeSampledForDisplay(srcFile);
src = ImageUtil.rotateBitmapInNeeded(srcFile, src);
cropImageView.setImageBitmap(src);
}
});
}
示例5: setImageView
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
public void setImageView(PhotoInfo info) {
if (info == null) {
return;
}
if(info.getAbsolutePath() == null){
return;
}
Bitmap bitmap = BitmapDecoder.decodeSampledForDisplay(info.getAbsolutePath());
if (bitmap == null) {
currentImageView.setImageBitmap(ImageUtil.getDefaultBitmapWhenGetFail());
Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
} else {
try{
bitmap = ImageUtil.rotateBitmapInNeeded(info.getAbsolutePath(), bitmap);
} catch (OutOfMemoryError e) {
e.printStackTrace();
}
currentImageView.setImageBitmap(bitmap);
}
}
示例6: loadAsPath
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
public void loadAsPath(final String path, final int width, final int height, final int maskId, final String ext) {
if (TextUtils.isEmpty(path)) {
loadAsResource(R.drawable.nim_image_default, maskId);
return;
}
setBlendDrawable(maskId);
RequestBuilder builder;
if (ImageUtil.isGif(ext)) {
builder = Glide.with(getContext().getApplicationContext()).asGif().load(new File(path));
} else {
RequestOptions options = new RequestOptions()
.override(width, height)
.fitCenter()
.placeholder(R.drawable.nim_image_default)
.error(R.drawable.nim_image_default);
builder = Glide.with(getContext().getApplicationContext())
.asBitmap()
.apply(options)
.load(new File(path))
;
}
builder.into(this);
}
示例7: setImageView
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
public void setImageView(PhotoInfo info) {
if (info == null) {
return;
}
if (info.getAbsolutePath() == null) {
return;
}
Bitmap bitmap = BitmapDecoder.decodeSampledForDisplay(info.getAbsolutePath());
if (bitmap == null) {
currentImageView.setImageBitmap(ImageUtil.getDefaultBitmapWhenGetFail());
Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
} else {
try {
bitmap = ImageUtil.rotateBitmapInNeeded(info.getAbsolutePath(), bitmap);
} catch (OutOfMemoryError e) {
e.printStackTrace();
}
currentImageView.setImageBitmap(bitmap);
}
}
示例8: setThumbnail
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
/**
* ******************************** 设置图片 *********************************
*/
private void setThumbnail() {
String path = ((SnapChatAttachment) message.getAttachment()).getThumbPath();
if (!TextUtils.isEmpty(path)) {
Bitmap bitmap = BitmapDecoder.decodeSampledForDisplay(path);
bitmap = ImageUtil.rotateBitmapInNeeded(path, bitmap);
if (bitmap != null) {
image.setImageBitmap(bitmap);
return;
}
}
image.setImageBitmap(ImageUtil.getBitmapFromDrawableRes(getImageResOnLoading()));
}
示例9: handleImagePath
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
/**
* 是否可以获取图片
*/
private boolean handleImagePath(Intent intent, Intent data) {
String photoPath = data.getStringExtra(Extras.EXTRA_FILE_PATH);
if (TextUtils.isEmpty(photoPath)) {
Toast.makeText(getActivity(), R.string.picker_image_error, Toast.LENGTH_LONG).show();
return false;
}
File imageFile = new File(photoPath);
intent.putExtra("OrigImageFilePath", photoPath);
File scaledImageFile = ImageUtil.getScaledImageFileWithMD5(imageFile, MIME_JPEG);
boolean local = data.getExtras().getBoolean(Extras.EXTRA_FROM_LOCAL, true);
if (!local) {
// 删除拍照生成的临时文件
AttachmentStore.delete(photoPath);
}
if (scaledImageFile == null) {
Toast.makeText(getActivity(), R.string.picker_image_error, Toast.LENGTH_LONG).show();
return false;
} else {
ImageUtil.makeThumbnail(getActivity(), scaledImageFile);
}
intent.putExtra("ImageFilePath", scaledImageFile.getAbsolutePath());
return true;
}
示例10: bindContentView
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
@Override
protected void bindContentView() {
final LocationAttachment location = (LocationAttachment) message.getAttachment();
addressText.setText(location.getAddress());
int[] bound = ImageUtil.getBoundWithLength(getLocationDefEdge(), R.drawable.nim_location_bk, true);
int width = bound[0];
int height = bound[1];
setLayoutParams(width, height, mapView);
setLayoutParams(width, (int) (0.38 * height), addressText);
mapView.loadAsResource(R.drawable.nim_location_bk, R.drawable.nim_message_item_round_bg);
}
示例11: onGetLocalPictureResult
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
public void onGetLocalPictureResult(int requestCode, int resultCode, final Intent data) {
if (data == null) {
return;
}
final String photoPath = data.getStringExtra(Extras.EXTRA_FILE_PATH);
if (TextUtils.isEmpty(photoPath)) {
return;
}
imageFile = new File(photoPath);
String mimeType = FileUtil.getExtensionName(photoPath);
imageFile = ImageUtil.getScaledImageFileWithMD5(imageFile, mimeType);
if (imageFile == null) {
Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
return;
} else {
ImageUtil.makeThumbnail(PreviewImageFromLocalActivity.this,
imageFile);
}
origImageList.add(photoPath);
selectImageList.add(imageFile.getAbsolutePath());
imageViewPagerAdapter.notifyDataSetChanged();
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
imageViewPager.setCurrentItem(selectImageList.size() - 1);
}
}, 100);
//有可用的图片
if(selectImageList.size() >= 1){
sendButton.setEnabled(true);
}
}
示例12: setImageView
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
public void setImageView(String imageFilePath) {
if (imageFilePath == null) {
return;
}
Bitmap bitmap = BitmapDecoder.decodeSampledForDisplay(imageFilePath);
if (bitmap == null) {
currentImageView.setImageBitmap(ImageUtil.getDefaultBitmapWhenGetFail());
Toast.makeText(this, R.string.picker_image_error, Toast.LENGTH_LONG).show();
} else {
currentImageView.setImageBitmap(bitmap);
}
}
示例13: bindContentView
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
@Override
protected void bindContentView() {
final LocationAttachment location = (LocationAttachment) message.getAttachment();
addressText.setText(location.getAddress());
int[] bound = ImageUtil.getBoundWithLength(getLocationDefEdge(), R.drawable.nim_location_bk, true);
int width = bound[0];
int height = bound[1];
setLayoutParams(width, height, mapView);
setLayoutParams(width, (int) (0.38 * height), addressText);
mapView.loadAsResource(R.drawable.nim_location_bk, width, height, R.drawable.nim_message_item_round_bg);
}
示例14: queryImageMessages
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
private void queryImageMessages() {
IMMessage anchor = MessageBuilder.createEmptyMessage(message.getSessionId(), message.getSessionType(), 0);
NIMClient.getService(MsgService.class).queryMessageListByType(MsgTypeEnum.image, anchor, Integer.MAX_VALUE).setCallback(new RequestCallback<List<IMMessage>>() {
@Override
public void onSuccess(List<IMMessage> param) {
for (IMMessage imMessage : param) {
if (!ImageUtil.isGif(((ImageAttachment) imMessage.getAttachment()).getExtension())){
imageMsgList.add(imMessage);
}
}
// imageMsgList.addAll(param);
Collections.reverse(imageMsgList);
setDisplayIndex();
setViewPagerAdapter();
}
@Override
public void onFailed(int code) {
Log.i(TAG, "query msg by type failed, code:" + code);
}
@Override
public void onException(Throwable exception) {
}
});
}
示例15: onDownloadFailed
import com.netease.nim.uikit.common.util.media.ImageUtil; //导入依赖的package包/类
private void onDownloadFailed() {
loadingLayout.setVisibility(View.GONE);
if (mode == MODE_NOMARL) {
image.setImageBitmap(ImageUtil.getBitmapFromDrawableRes(getImageResOnFailed()));
} else if (mode == MODE_GIF) {
simpleImageView.setImageBitmap(ImageUtil.getBitmapFromDrawableRes(getImageResOnFailed()));
}
Toast.makeText(this, R.string.download_picture_fail, Toast.LENGTH_LONG).show();
}