In the below exampl e I have added a image with the help of Bitmap. Bitmap is eventually created and displayed on the screen. By using simply bitmap a pixels of rectangle, each pixel can be set to a given color but exactly what color depends on the type of the pixel. You can see below example code it clearly describe you How can use Bitmap in android.
public class MainActivity extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new myView(this));
}
private class myView extends View{
public myView(Context context) {
super(context);
}
@Override
protected void onDraw(Canvas canvas) {
Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.one);
canvas.drawBitmap(myBitmap, 0, 0, null);
Bitmap b = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);
b.eraseColor(Color.RED);
}
}
}
0 Comment(s)