Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 CanvasProfile.java
 Copyright (c) 2014 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */

import android.graphics.Bitmap;
import android.graphics.Canvas;

public class Main {
    /**
     * draw the image to viewBitmap in fill mode.
     * @param viewBitmap Bitmap to be displayed on the device.
     * @param bitmap Bitmap image.
     */
    public static void drawImageForFillsMode(final Bitmap viewBitmap, final Bitmap bitmap) {

        float getSizeW = bitmap.getWidth();
        float getSizeH = bitmap.getHeight();

        Canvas canvas = new Canvas(viewBitmap);

        final int width = viewBitmap.getWidth();
        final int height = viewBitmap.getHeight();
        for (int drawY = 0; drawY <= height; drawY += getSizeH) {
            for (int drawX = 0; drawX <= width; drawX += getSizeW) {
                canvas.drawBitmap(bitmap, drawX, drawY, null);
            }
        }
    }
}