- private static Double hue2rgb(Double p, Double q, Double t){
- if(t < 0) t += 1;
- if(t > 1) t -= 1;
- if(t < 1/6) return p + (q - p) * 6 * t;
- if(t < 1/2) return q;
- if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
- return p;
+ private static float HueToRGB(float p, float q, float h){
+ if (h < 0) h += 1;
+
+ if (h > 1 ) h -= 1;
+
+ if (6 * h < 1)
+ {
+ return p + ((q - p) * 6 * h);
+ }
+
+ if (2 * h < 1 )
+ {
+ return q;
+ }
+
+ if (3 * h < 2)
+ {
+ return p + ( (q - p) * 6 * ((2.0f / 3.0f) - h) );
+ }
+
+ return p;
+ }
+
+ /**
+ * Checks if file passed is an image
+ * @param file
+ * @return true/false
+ */
+ public static boolean isImage(File file) {
+ Uri selectedUri = Uri.fromFile(file);
+ String fileExtension = MimeTypeMap.getFileExtensionFromUrl(selectedUri.toString().toLowerCase());
+ String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
+
+ return (mimeType != null && mimeType.startsWith("image/"));