Skip to content

Instantly share code, notes, and snippets.

public class resizeUtils {
public static Bitmap successiveResize(Bitmap src, int resizeNum) {
int srcWidth = src.getWidth();
int srcHeight = src.getHeight();
Bitmap output = src;
for (int i = 0; i < resizeNum; i++) {
srcWidth /= 2;
srcHeight /= 2;
Bitmap temp = Bitmap.createScaledBitmap(output, srcWidth, srcHeight, true);
@Petrakeas
Petrakeas / renderscriptresize.java
Last active February 17, 2021 06:57
A method that uses RenderScript to downscale an image without aliasing.
public static Bitmap resizeBitmap2(RenderScript rs, Bitmap src, int dstWidth) {
Bitmap.Config bitmapConfig = src.getConfig();
int srcWidth = src.getWidth();
int srcHeight = src.getHeight();
float srcAspectRatio = (float) srcWidth / srcHeight;
int dstHeight = (int) (dstWidth / srcAspectRatio);
float resizeRatio = (float) srcWidth / dstWidth;
/* Calculate gaussian's radius */
@Petrakeas
Petrakeas / starting_library_project_AS.md
Created January 19, 2016 14:49 — forked from daniellevass/starting_library_project_AS.md
Getting Started with a library project in Android Studio

Getting Started with a library project in Android Studio

So we're working on creating Android Material Awesome, a library which will hopefully incorperate the benefits of Material Design, Twitter's Bootstrap, and FontAwesome. What we really wanted is a project other people can easily include into their projects using gradle dependencies. To do this we needed to create a standalone library project so we could make it as lightweight as possible for including as a dependency, and a sample app that would use it for testing. These are the steps we took to get started in Android Studio (version 1.1).

Create Projects

The first thing we needed to do was to create two new projects, with all the default settings (Blank Activity etc). One for our sample app, and one for our library. We added both of ours into the same GitHub repo, however you can save them wherever you like.

Fix Up Library Project

@Petrakeas
Petrakeas / SynchronousHandler.java
Last active August 16, 2024 04:24
Android - Posts a runnable on a handler's thread and waits until it has finished running.
import android.os.Handler;
import android.os.Looper;
/**
* A helper class that provides more ways to post a runnable than {@link android.os.Handler}.
*
* Created by Petros Douvantzis on 19/6/2015.
*/
public class SynchronousHandler {