Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.graphics.Bitmap;
import android.graphics.Color;

public class Main {
    /**
     * Fill the hole in the image (version 2)
     */
    public static void fillHole2(Bitmap bmp) {

        for (int j = 1; j < bmp.getWidth(); j++) {
            for (int i = 1; i < bmp.getHeight() - 1; i++) {
                if ((bmp.getPixel(i, j) == Color.TRANSPARENT) && (bmp.getPixel(i + 1, j) != Color.TRANSPARENT)) {
                    bmp.setPixel(i, j, bmp.getPixel(i + 1, j)); // set to the next-below pixel
                }
            }
        }
    }
}