Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Bitmap;

import android.graphics.Color;

public class Main {
    public static void invertImage(Bitmap b) {
        int A, R, G, B;
        int pixelColor;
        int height = b.getHeight();
        int width = b.getWidth();

        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                pixelColor = b.getPixel(x, y);
                A = Color.alpha(pixelColor);

                R = 255 - Color.red(pixelColor);
                G = 255 - Color.green(pixelColor);
                B = 255 - Color.blue(pixelColor);

                b.setPixel(x, y, Color.argb(A, R, G, B));
            }
        }
    }
}