Android Open Source - hacktoolkit-android_lib Bitmap Utils






From Project

Back to project page hacktoolkit-android_lib.

License

The source code is released under:

MIT License

If you think the Android project hacktoolkit-android_lib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.hacktoolkit.android.utils;
/* ww  w  .  ja va  2 s .c  o  m*/
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.Rect;

public class BitmapUtils {
  public static Bitmap getRoundedShape(Bitmap scaleBitmapImage) {
    if (scaleBitmapImage == null) {
      return null;
    }
    int sourceWidth = scaleBitmapImage.getWidth();
    int sourceHeight = scaleBitmapImage.getHeight();
      int targetWidth = Math.min(sourceWidth, sourceHeight);
      int targetHeight = targetWidth;
      Bitmap targetBitmap = Bitmap.createBitmap(
          targetWidth,
          targetHeight,
          Bitmap.Config.ARGB_8888
          );

      Canvas canvas = new Canvas(targetBitmap);
      Path path = new Path();
      path.addCircle(
          ((float) targetWidth - 1) / 2,
          ((float) targetHeight - 1) / 2,
          Math.min(((float) targetWidth), ((float) targetHeight)) / 2,
          Path.Direction.CCW
          );

      canvas.clipPath(path);
      Bitmap sourceBitmap = scaleBitmapImage;
      canvas.drawBitmap(
          sourceBitmap,
          new Rect(0, 0, sourceBitmap.getWidth(),
          sourceBitmap.getHeight()),
          new Rect(0, 0, targetWidth, targetHeight),
          null
          );
      return targetBitmap;
  }
}




Java Source Code List

com.hacktoolkit.android.activities.HTKSplashScreenActivity.java
com.hacktoolkit.android.adapters.HTKContactsAdapter.java
com.hacktoolkit.android.api_helpers.FacebookHelper.java
com.hacktoolkit.android.api_helpers.HTKCallback.java
com.hacktoolkit.android.api_helpers.ParseHelper.java
com.hacktoolkit.android.constants.GeoConstants.java
com.hacktoolkit.android.constants.StringConstants.java
com.hacktoolkit.android.constants.TimeConstants.java
com.hacktoolkit.android.constants.UnitConstants.java
com.hacktoolkit.android.fragments.ContactsFragment.java
com.hacktoolkit.android.maps.MapUtils.java
com.hacktoolkit.android.maps.Mapper.java
com.hacktoolkit.android.models.HTKContact.java
com.hacktoolkit.android.user.HTKUser.java
com.hacktoolkit.android.utils.BitmapUtils.java
com.hacktoolkit.android.utils.ContactsUtils.java
com.hacktoolkit.android.utils.FileUtils.java
com.hacktoolkit.android.utils.HTKUtils.java
com.hacktoolkit.android.utils.SystemUiHiderBase.java
com.hacktoolkit.android.utils.SystemUiHiderHoneycomb.java
com.hacktoolkit.android.utils.SystemUiHider.java