Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
// Use of this source code is governed by a BSD-style license that can be

import android.content.Context;

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

import android.graphics.Rect;

public class Main {
    /**
     * Draw the favicon with dominant color.
     * @param context Context used to create the intent.
     * @param favicon favicon bitmap.
     * @param canvas Canvas that holds the favicon.
     */
    private static void drawFaviconToCanvas(Context context, Bitmap favicon, Canvas canvas) {
        Rect iconBounds = new Rect(0, 0, canvas.getWidth(), canvas.getHeight());
        int faviconSize = iconBounds.width() / 3;
        Bitmap scaledFavicon = Bitmap.createScaledBitmap(favicon, faviconSize, faviconSize, true);
        canvas.drawBitmap(scaledFavicon, iconBounds.exactCenterX() - scaledFavicon.getWidth() / 2.0f,
                iconBounds.exactCenterY() - scaledFavicon.getHeight() / 2.0f, null);
    }
}