Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * Copyright 2014 sailaway(https://github.com/sailaway)
 *
 * Licensed under theGNU GENERAL PUBLIC LICENSE Version 3 (the "License");
 *  Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 * Everyone is permitted to copy and distribute verbatim copies
 * of this license document, but changing it is not allowed.
 * 
 */

import android.graphics.Bitmap;

import android.graphics.Canvas;

public class Main {
    public static Bitmap converttoBitmap565(Bitmap b) {
        if (b == null) {
            return null;
        }
        if (b.getConfig() == Bitmap.Config.RGB_565) {
            return b;
        }
        Bitmap b565 = Bitmap.createBitmap(b.getWidth(), b.getHeight(), Bitmap.Config.RGB_565);
        Canvas c = new Canvas(b565);
        c.drawBitmap(b, 0, 0, null);
        return b565;
    }
}