com.blankj.utilcode.util.ImageUtils Java Examples

The following examples show how to use com.blankj.utilcode.util.ImageUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageLoader.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
public static void load(final File file, final ImageView imageView) {
    if (!FileUtils.isFileExists(file)) return;
    imageView.post(new Runnable() {
        @Override
        public void run() {
            ThreadUtils.executeByCached(new ThreadUtils.SimpleTask<Bitmap>() {
                @Override
                public Bitmap doInBackground() throws Throwable {
                    return ImageUtils.getBitmap(file, imageView.getWidth(), imageView.getHeight());
                }

                @Override
                public void onSuccess(final Bitmap result) {
                    imageView.setImageBitmap(result);
                }
            });
        }
    });
}
 
Example #2
Source File: FileHelper.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
@FileType
public static int getFileType(File file) {
    if (!FileUtils.isFileExists(file)) return UNKNOWN;
    if (ImageUtils.isImage(file)) {
        return IMAGE;
    }
    if (FileUtils.getFileExtension(file).equals("xml")) {
        File parentFile = file.getParentFile();
        if (parentFile != null) {
            if (StringUtils.equals(parentFile.getName(), "shared_prefs")) {
                return SP;
            }
        }
    }
    if (FileUtils.isUtf8(file)) {
        return UTF8;
    }
    return UNKNOWN;
}
 
Example #3
Source File: LocalVideoAdapter.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
@SuppressLint({"SetTextI18n", "SimpleDateFormat"})
@Override
public void setData(VideoBean data) {
    super.setData(data);
    Bitmap videoThumbnail = data.getVideoThumbnail();
    if(videoThumbnail!=null){
        Drawable drawable = ImageUtils.bitmap2Drawable(videoThumbnail);
        ivCover.setBackground(drawable);
    }
    tvTitle.setText(data.getTitle());
    String string = TimeUtils.millis2String(data.getDuration(), new SimpleDateFormat("mm:ss"));
    tvArtist.setText("时长:"+string+"   分辨率:"+data.getResolution()+"   大小"+data.getFileSize());
    vDivider.setVisibility(View.VISIBLE);
}
 
Example #4
Source File: EditNotePresenter.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Bitmap getNoteShareBitmap(View view) {
    Bitmap bitmap = ImageUtils.view2Bitmap(view);
    int x = bitmap.getWidth() - SizeUtils.sp2px(72);
    int y = bitmap.getHeight() - SizeUtils.sp2px(16);
    int textWaterMarkColor = Utils.getContext().getResources().getColor(R.color.colorBlackAlpha54);
    bitmap = ImageUtils.addTextWatermark(bitmap, EditNoteConstans.watermarkText, 24, textWaterMarkColor, x, y);
    return bitmap;
}
 
Example #5
Source File: SharePresenter.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Uri saveImageAndGetUri() {
    String filePath = mView.getActivity().getExternalFilesDir("share").getPath() + "/" + TimeUtils.getNowMills() + ".jpg";
    File file = new File(filePath);
    ImageUtils.save(mBitmap, file, Bitmap.CompressFormat.JPEG);
    return Uri.fromFile(file);
}
 
Example #6
Source File: SharePresenter.java    From SuperNote with GNU General Public License v3.0 4 votes vote down vote up
private void saveImageToLocation(Bitmap bitmap) {
    File file = new File(Constans.imageSaveFolder + "/" + TimeUtils.getNowMills() + ".jpg");
    ImageUtils.save(bitmap, file, Bitmap.CompressFormat.JPEG);
    ToastUtils.showLong("已保存至" + "/SuperNote/Image/" + "中");
}
 
Example #7
Source File: ImageViewer.java    From AndroidUtilCode with Apache License 2.0 4 votes vote down vote up
@Override
public void onAttach() {
    photoView = findViewById(R.id.imageViewerPv);
    photoView.setImageBitmap(ImageUtils.getBitmap(mFile));
}