本文整理汇总了Java中id.zelory.compressor.Compressor类的典型用法代码示例。如果您正苦于以下问题:Java Compressor类的具体用法?Java Compressor怎么用?Java Compressor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Compressor类属于id.zelory.compressor包,在下文中一共展示了Compressor类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: CompressImage
import id.zelory.compressor.Compressor; //导入依赖的package包/类
public static File CompressImage(int w, Context context, String path) {
File f = new File(path);
if(f.exists()) {
Pair<Integer, Integer> p = getDimentions(/*mFile.getAbsolutePath()*/ path, w);
return new Compressor.Builder(context)
.setMaxWidth(p.first)
.setMaxHeight(p.second)
.setQuality(75)
.setCompressFormat(Bitmap.CompressFormat.JPEG)
.build()
.compressToFile(/*ImageConverter.mFile*/new File(path));
}
else return null;
}
开发者ID:Elbehiry,项目名称:Viajes,代码行数:21,代码来源:Utils.java
示例2: CompressImage
import id.zelory.compressor.Compressor; //导入依赖的package包/类
public static File CompressImage(int w, Context context, String path) {
Pair<Integer, Integer> p = getDimentions(/*mFile.getAbsolutePath()*/ path, w);
return new Compressor.Builder(context)
.setMaxWidth(p.first)
.setMaxHeight(p.second)
.setQuality(75)
.setCompressFormat(Bitmap.CompressFormat.JPEG)
.build()
.compressToFile(/*ImageConverter.mFile*/new File(path));
}
开发者ID:shawara,项目名称:ChatUp,代码行数:11,代码来源:ImageUtils.java
示例3: onOkClick
import id.zelory.compressor.Compressor; //导入依赖的package包/类
/**
* This method processes current cover selection and performs needed operation (copy image
* from external storage to internal, compress it, etc) and finally notify through callback.
*/
@OnClick(R.id.dialog_edit_doc_ok)
public void onOkClick() {
// if there is no callback, avoid performs useless operations
if (mCallback == null) {
dismiss();
return;
}
int position = mViewPager.getCurrentItem();
switch (position) {
case 0:
// color tab is selected
int currentColor = mDocument.coverColor;
int newColor = mAdapter.mColorFragment.mColor;
// notify only if color has changed
if (currentColor != newColor) {
mCallback.onColorChanged(mAdapter.mColorFragment.mColor);
}
dismiss();
return;
case 1:
// image tab is selected
final String currentImage = mDocument.coverImage;
final String newImage = mAdapter.mImageFragment.mImagePath;
// notify only if image has changed
if (currentImage.equals(newImage)) {
dismiss();
return;
}
// disable dialog fragment buttons meanwhile it is processing image operations
// in background
mOkButton.setEnabled(false);
mCancelButton.setEnabled(false);
new AsyncTask<Void, Void, String>() {
@Override
protected String doInBackground(Void... params) {
// copy and compress selected image to internal storage
ContextWrapper cw = new ContextWrapper(getActivity());
File directory = cw.getDir("media", Context.MODE_PRIVATE);
String randomName = UUID.randomUUID().toString();
try {
File compressedImage = new Compressor(getActivity())
.setMaxWidth(IMAGE_MAX_WIDTH_PX)
.setMaxHeight(IMAGE_MAX_HEIGHT_PX)
.setQuality(25)
.setCompressFormat(Bitmap.CompressFormat.JPEG)
.setDestinationDirectoryPath(directory.getAbsolutePath())
.compressToFile(new File(newImage), randomName);
return compressedImage.getAbsolutePath();
} catch (IOException e) {
Timber.d(e);
return null;
}
}
@Override
protected void onPostExecute(String imagePath) {
// if image was processed correctly notify it
if (!TextUtils.isEmpty(imagePath)) {
mCallback.onImageChanged(imagePath);
dismiss();
} else {
Toast.makeText(getActivity(),
R.string.dialog_edit_doc_cover_image_process_msg,
Toast.LENGTH_SHORT).show();
mOkButton.setEnabled(true);
mCancelButton.setEnabled(true);
}
}
}.execute();
return;
default:
Timber.e("Unexpected pager position: " + position);
}
}
开发者ID:nfdz,项目名称:foco,代码行数:79,代码来源:EditDocCoverDialog.java
示例4: compressPhoto
import id.zelory.compressor.Compressor; //导入依赖的package包/类
public File compressPhoto(File src) {
return Compressor.getDefault(context).compressToFile(src);
}
开发者ID:ukevgen,项目名称:BizareChat,代码行数:4,代码来源:Converter.java
注:本文中的id.zelory.compressor.Compressor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论