Image create and modify

0

Good morning classmates!

First of all I told you that I am a beginner in Android, I use android studio.

In my Android project I have an image in the path: app/assets/imagen_origen.png and I have to make a copy of image_origin.png to imagen_destino.png and in the latter change the color of several pixels, for example change the color red (argb->255,255,0,0) by the green color (argb->255,0,255,0) of the pixel that is in x=0 e y=0 . And save i magen_destino.png in the internal memory in project files, also in a specific path of the internal memory for example Download or Pictures , also in assets , also in drawable (I want to know how I can save it in these routes for knowledge and to later know which one suits me to use).

This should not be shown in the application, it should be transparent to the user.

I generated the following code:

public class MainActivity extends AppCompatActivity {

    ImageView iv_imagen;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv_color = (TextView) findViewById(R.id.tv_color);
        Bitmap bmp = null;
        byte[] byteArray = null;
        try {
            InputStream inputStream = getAssets().open("imagen_origen.png");
            bmp_image_origen = BitmapFactory.decodeStream(inputStream);
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bmp_image_origen.compress(Bitmap.CompressFormat.PNG, 100, stream);
            byteArray = stream.toByteArray();
            int pixel = bmp_image_origen.getPixel(0,0);
            int a = Color.alpha(pixel);
            int r = Color.red(pixel);
            int g = Color.green(pixel);
            int b = Color.blue(pixel);
            if(a == 255 && r==255 && g==0 && b==0){
                //bmp_image_destino.setPixel(0, 0, Color.argb(255,0,255,0));
            }
        }catch (IOException io){
            io.printStackTrace();
        }
    }
}

Beforehand, thank you.

    
asked by Luis Delgado 24.08.2018 в 16:51
source

0 answers