Posts

Showing posts with the label Java

Android Preferences Time Picker

When developing the preferences page for an Android app you can add a time picker with this class. import android.content.*; import android.content.res.*; import android.preference.*; import android.util.*; import android.view.*; import android.widget.*; import java.text.*; import java.util.*; /* * Use in preferences.xml like this: *   <net.intrepidis.library.prefs.TimePreference *       android:key="mytime_preference" *       android:title="@string/mytime_preftitle" *       android:summary="@string/mytime_prefsummary" *       android:defaultValue="00:10" *       positiveButtonText="@string/ok_button" *       negativeButtonText="Close me" /> */ public class TimePreference extends DialogPreference { private final Calendar calendar; private final TimePicker p...

xBRZ in Java

xBRZ is a graphics upscaling routine which adopts the "scale by rules" approach, rather than the more traditional "filtered scaling" approach. This works best for pixel art, because the edges of objects remain sharp, rather than becoming blurry. The original xBRZ routine was written in C/C++ and here I have converted it to Java. The reason for doing this was for a personal project I was working on. I wanted to have a lot of graphics, that don't take up too much space, but still look good and sharp. Also, drawing pixel graphics is easiest for me, so in all, this seemed like the best solution. And who knows, maybe one day I'll convert this to C# as well. (Unless someone beats me to it.) Converting from Java to C# should be trivial, actually. The most fun might come from making specific optimisations. Converting from C/C++ to Java was a little tricky. The original source code used a lot of static templating, in order to let the compiler do a lot of the...