Hi Guys!
Today I ma sharing the code how to copy the same bitmap image to new bitmap image.
Example of copy bitmap using Bitmap.getPixels() and Bitmap.setPixels().
You can download the source code Copy Bitmap
Cheers Guys!
Today I ma sharing the code how to copy the same bitmap image to new bitmap image.
Example of copy bitmap using Bitmap.getPixels() and Bitmap.setPixels().
activity_main.xml
MainAcitivity.java
package com.sunil.copybitmap;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.widget.ImageView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView image1 = (ImageView)findViewById(R.id.image1);
ImageView image2 = (ImageView)findViewById(R.id.image2);
Bitmap oldBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
int orgWidth = oldBitmap.getWidth();
int orgHeight = oldBitmap.getHeight();
Bitmap newBitmap = Bitmap.createBitmap(orgWidth, orgHeight, Bitmap.Config.ARGB_8888);
int[] pixels = new int[orgWidth * orgHeight];
oldBitmap.getPixels(pixels, 0, orgWidth, 0, 0, orgWidth, orgHeight);
newBitmap.setPixels(pixels, 0, orgWidth, 0, 0, orgWidth, orgHeight);
image1.setImageBitmap(oldBitmap);
image2.setImageBitmap(newBitmap);
}
}
You can download the source code Copy Bitmap
Cheers Guys!
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :