Currently I am working on a project with Particle which works fine with colour constants, but I want to use drawable/bitmap instead.
DATA = new int[]{16777215, -2130706433, 16777215};
and than passing onto create bitmap with DATA
.
BMP = Bitmap.createBitmap(DATA, 0, 5, 1, 1, Bitmap.Config.ARGB_8888);
How should I use drawable resource and pass it on to create bitmap?
I have already tried context.getResources()
and also have tried with a class
public class App extends Application {
private static Context mContext;
@Override
public void onCreate() {
super.onCreate();
mContext = this;
}
public static Context getContext() {
return mContext;
}
}
And use App.getContext().getResources()
, but it's not working. I am trying to create Bitmap in abstract static class.
使用位图工厂方法来解码可绘制资源,例如
Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.your_resource);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.