mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-10-04 18:03:21 +08:00
Merged NinePatchMaskTransformation to MaskTransformation
1.merged the NinePatchMaskTransformation to the maskTransformation. 2.replace mask resource.
This commit is contained in:
@@ -19,7 +19,6 @@ import jp.wasabeef.glide.transformations.CropSquareTransformation;
|
||||
import jp.wasabeef.glide.transformations.CropTransformation;
|
||||
import jp.wasabeef.glide.transformations.GrayscaleTransformation;
|
||||
import jp.wasabeef.glide.transformations.MaskTransformation;
|
||||
import jp.wasabeef.glide.transformations.NinePatchMaskTransformation;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.BrightnessFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.ContrastFilterTransformation;
|
||||
@@ -77,19 +76,23 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
||||
@Override public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
|
||||
switch (mDataSet.get(position)) {
|
||||
case Mask:
|
||||
int width = Utils.dip2px(mContext, 133.33f);
|
||||
int height = Utils.dip2px(mContext, 126.33f);
|
||||
Glide.with(mContext)
|
||||
.load(R.drawable.demo)
|
||||
.override(210, 210)
|
||||
.load(R.drawable.check)
|
||||
.override(width, height)
|
||||
.bitmapTransform(new CenterCrop(mContext),
|
||||
new MaskTransformation(mContext, R.drawable.mask210))
|
||||
new MaskTransformation(mContext, R.drawable.mask_starfish))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case NinePatchMask:
|
||||
width = Utils.dip2px(mContext, 150.0f);
|
||||
height = Utils.dip2px(mContext, 100.0f);
|
||||
Glide.with(mContext)
|
||||
.load(R.drawable.demo)
|
||||
.override(300, 300)
|
||||
.load(R.drawable.check)
|
||||
.override(width, height)
|
||||
.bitmapTransform(new CenterCrop(mContext),
|
||||
new NinePatchMaskTransformation(mContext, R.drawable.chat_me_mask))
|
||||
new MaskTransformation(mContext, R.drawable.mask_chat_right))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case CropTop:
|
||||
|
27
example/src/main/java/jp/wasabeef/example/glide/Utils.java
Normal file
27
example/src/main/java/jp/wasabeef/example/glide/Utils.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package jp.wasabeef.example.glide;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static int dip2px(Context context, float dp) {
|
||||
float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dp * scale + 0.5f);
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
BIN
example/src/main/res/drawable-xxhdpi/mask_starfish.png
Normal file
BIN
example/src/main/res/drawable-xxhdpi/mask_starfish.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
Reference in New Issue
Block a user