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 1)
     */
    public static void fillHole1(Bitmap bmp) {

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