Skip to content

Commit

Permalink
修复: 对自由比例的图片进行单图滤镜处理时,最终结果出现黑边
Browse files Browse the repository at this point in the history
  • Loading branch information
JessYanCoding committed Jul 31, 2020
1 parent d913861 commit 2a6ecf7
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ public class InstagramMediaSingleImageContainer extends FrameLayout implements I
private int mSelectionPosition;
private final View mLoadingView;
private PictureSelectionConfig mConfig;
private Bitmap mBitmap;
private int mSelectionFilter;
private PictureCustomDialog mDialog;
private GPUImage mGpuImage;

public InstagramMediaSingleImageContainer(@NonNull Context context, PictureSelectionConfig config, Bitmap bitmap, boolean isAspectRatio, int selectionFilter) {
super(context);
mConfig = config;
mBitmap = bitmap;
mSelectionFilter = selectionFilter;
setWillNotDraw(false);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
Expand All @@ -73,6 +76,8 @@ public InstagramMediaSingleImageContainer(@NonNull Context context, PictureSelec
mPaint.setColor(Color.parseColor("#efefef"));
}

mGpuImage = new GPUImage(context);

mImageView = new GPUImageView(context);
addView(mImageView);
if (isAspectRatio) {
Expand Down Expand Up @@ -144,6 +149,7 @@ public void onItemClick(View view, int position, FilterType filterType) {

if (mSelectionPosition != position) {
mImageView.setFilter(FilterType.createFilterForType(getContext(), filterType));
mGpuImage.setFilter(FilterType.createFilterForType(getContext(), filterType));

int previousPosition = mSelectionPosition;
mSelectionPosition = position;
Expand Down Expand Up @@ -245,9 +251,10 @@ public SaveTask(final Context context, final String folderName, final String fil
@Override
protected Void doInBackground(final Void... params) {
try {
Bitmap result = width != 0 ? mImageView.capture(width, height) : mImageView.capture();
// Bitmap result = width != 0 ? mImageView.capture(width, height) : mImageView.capture();
Bitmap result = mGpuImage.getBitmapWithFilterApplied(mBitmap);
saveImage(folderName, fileName, result);
} catch (InterruptedException e) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
Expand Down

0 comments on commit 2a6ecf7

Please sign in to comment.