Permalink
Browse files

* Add files for the app.

  • Loading branch information...
1 parent e3762d3 commit 44f8d48c8fef54bf23503afda0b40d4f9e5eb8a0 @adstro adstro committed May 24, 2012
Showing 716 changed files with 105,489 additions and 4 deletions.
View
@@ -14,3 +14,17 @@ gen/
# Local configuration file (sdk path, etc)
local.properties
+
+db/*.sqlite3
+log/*.log
+tmp/**/*
+.prefs
+target
+log
+.settings
+workspace
+*~
+.DS_Store
+.svn
+nbproject
+.metadata
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="jjil.android"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="9" />
+
+ <application android:icon="@drawable/icon" android:label="@string/app_name">
+ <activity android:name=".JJILAndroidActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+</manifest>
View
Binary file not shown.
View
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native <methods>;
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public <init>(android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
@@ -0,0 +1,12 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+android.library=true
+# Project target.
+target=android-15
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ >
+<TextView
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/hello"
+ />
+</LinearLayout>
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="hello">Hello World, JJILAndroidActivity!</string>
+ <string name="app_name">JJIL-Android</string>
+</resources>
@@ -0,0 +1,42 @@
+package jjil.android;
+
+import android.graphics.Color;
+
+public class AndroidColors {
+ /**
+ * Converts the YUV used in the Android NV21 format into an
+ * RGB value using code from
+ * http://msdn.microsoft.com/en-us/library/ms893078
+ * @param nY - y value (from WxH byte array)
+ * @param nU - u value (second byte in WxH/2 byte array)
+ * @param nV - v value (first byte in WxH/2 byte array)
+ * @return Android Color for the converted color
+ */
+ public static int yuv2Color(int nY, int nU, int nV) {
+ int nC = nY - 16;
+ int nD = nU - 128;
+ int nE = nV - 128;
+
+ int nR = Math.max(0, Math.min(255, (( 298 * nC + 409 * nE + 128) >> 8)));
+ int nG = Math.max(0, Math.min(255, (( 298 * nC - 100 * nD - 208 * nE + 128) >> 8)));
+ int nB = Math.max(0, Math.min(255, (( 298 * nC + 516 * nD + 128) >> 8)));
+ return Color.argb(255, nR, nG, nB);
+ }
+
+ /**
+ * Converts from RGB to YUV using code from
+ * http://msdn.microsoft.com/en-us/library/ms893078.
+ * Returns the value as a Android Color value in with the red byte
+ * is the Y value, green the U value, and blue the V value.
+ * @param nR - red value (0-255)
+ * @param nG - green value (0-255)
+ * @param nB - blue value (0-255)
+ * @return
+ */
+ public static int rgb2yuv(int nR, int nG, int nB) {
+ int nY = ( ( 66 * nR + 129 * nG + 25 * nB + 128) >> 8) + 16;
+ int nU = ( ( -38 * nR - 74 * nG + 112 * nB + 128) >> 8) + 128;
+ int nV = ( ( 112 * nR - 94 * nG - 18 * nB + 128) >> 8) + 128;
+ return Color.argb(255, nY, nU, nV);
+ }
+}
@@ -0,0 +1,61 @@
+package jjil.android;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class CrosshairOverlay extends View {
+ private Integer mnHorizStart, mnHorizEnd;
+ private Integer mnVertStart, mnVertEnd;
+
+ public CrosshairOverlay(Context context) {
+ super(context);
+ }
+
+ public CrosshairOverlay(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ }
+
+ public CrosshairOverlay(Context context, AttributeSet attrs, int defStyle)
+ {
+ super(context, attrs, defStyle);
+ }
+
+ public void clearLimits() {
+ mnHorizStart = mnHorizEnd = mnVertStart = mnVertEnd = null;
+ }
+
+ @Override
+ public void onDraw(Canvas c) {
+ super.onDraw(c);
+
+ // draw a partially transparent crosshairs on the canvas
+ Paint p = new Paint();
+ p.setColor(Color.RED);
+ p.setAlpha(128);
+ c.drawLine(0.0f, getHeight()/2, getWidth(), getHeight()/2, p);
+ c.drawLine(getWidth()/2, 0.0f, getWidth()/2, getHeight(), p);
+ if (mnHorizStart != null) {
+ c.drawLine(mnHorizStart, getHeight()/2-5, mnHorizStart, getHeight()/2+5, p);
+ c.drawLine(mnHorizEnd, getHeight()/2-5, mnHorizEnd, getHeight()/2+5, p);
+ }
+ if (mnVertStart != null) {
+ c.drawLine(getWidth()/2-5, mnVertStart, getWidth()/2+5, mnVertStart, p);
+ c.drawLine(getWidth()/2-5, mnVertEnd, getWidth()/2+5, mnVertEnd, p);
+ }
+ }
+
+ public void setHorizLimits(int nStart, int nEnd) {
+ mnHorizStart = nStart;
+ mnHorizEnd = nEnd;
+ }
+
+ public void setVertLimits(int nStart, int nEnd) {
+ mnVertStart = nStart;
+ mnVertEnd = nEnd;
+ }
+}
@@ -0,0 +1,181 @@
+package jjil.android;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import jjil.core.RgbVal;
+
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.CompressFormat;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.os.Environment;
+
+public class DebugImage {
+ public static class Nv21Image {
+ public Nv21Image(byte[] data, int width, int height) {
+ this.mData = data;
+ this.mWidth = width;
+ this.mHeight = height;
+ }
+
+ public byte[] getData() {
+ return mData;
+ }
+
+ public int getHeight() {
+ return mHeight;
+ }
+
+ public int getWidth() {
+ return mWidth;
+ }
+
+ private byte[] mData;
+ private int mHeight, mWidth;
+ }
+ public static Nv21Image readGrayImage(String szFilename) {
+ Bitmap bmp = readBitmap(szFilename);
+ int width = bmp.getWidth();
+ int height = bmp.getHeight();
+ byte[] bResult = new byte[width * height];
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ // turn the color image to gray
+ int pix = bmp.getPixel(j, i);
+ int r = (pix & 0x00ff0000) >> 16;
+ int g = (pix & 0x0000ff00) >> 8;
+ int b = (pix & 0x000000ff);
+ int gray = (r + g + b) / 3;
+ bResult[i * width + j] = RgbVal.unsignedIntToSignedByte[gray];
+ }
+ }
+ return new Nv21Image(bResult, width, height);
+ }
+
+ public static Nv21Image readImage2Nv21(String szFilename) {
+ Bitmap bmp = readBitmap(szFilename);
+ int width = bmp.getWidth();
+ int height = bmp.getHeight();
+ byte[] bResult = new byte[width * height + width * height / 2];
+ int nVuOffset = width * height;
+ // we compute the VU value on each 4 pixel block and the gray
+ // value on every pixel
+ for (int i = 0; i < height; i += 2) {
+ for (int j = 0; j < width; j += 2) {
+ int pix = bmp.getPixel(j, i);
+ int r = (pix & 0x00ff0000) >> 16;
+ int g = (pix & 0x0000ff00) >> 8;
+ int b = (pix & 0x000000ff);
+ int nSumR = r;
+ int nSumG = g;
+ int nSumB = b;
+ int nGray = (r + g + b) / 3;
+ bResult[i * width + j] = RgbVal.unsignedIntToSignedByte[nGray];
+ pix = bmp.getPixel(j + 1, i);
+ r = (pix & 0x00ff0000) >> 16;
+ g = (pix & 0x0000ff00) >> 8;
+ b = (pix & 0x000000ff);
+ nSumR += r;
+ nSumG += g;
+ nSumB += b;
+ nGray = (r + g + b) / 3;
+ bResult[i * width + j + 1] = RgbVal.unsignedIntToSignedByte[nGray];
+ pix = bmp.getPixel(j, i + 1);
+ r = (pix & 0x00ff0000) >> 16;
+ g = (pix & 0x0000ff00) >> 8;
+ b = (pix & 0x000000ff);
+ nSumR += r;
+ nSumG += g;
+ nSumB += b;
+ nGray = (r + g + b) / 3;
+ bResult[(i + 1) * width + j] = RgbVal.unsignedIntToSignedByte[nGray];
+ pix = bmp.getPixel(j + 1, i + 1);
+ r = (pix & 0x00ff0000) >> 16;
+ g = (pix & 0x0000ff00) >> 8;
+ b = (pix & 0x000000ff);
+ nSumR += r;
+ nSumG += g;
+ nSumB += b;
+ nGray = (r + g + b) / 3;
+ bResult[(i + 1) * width + j + 1] = RgbVal.unsignedIntToSignedByte[nGray];
+ // now compute the UV value for the 4-pixel block
+ int nYUV = AndroidColors.rgb2yuv(nSumR / 4, nSumG / 4,
+ nSumB / 4);
+ bResult[nVuOffset + i / 2 * width + j] = RgbVal.unsignedIntToSignedByte[nYUV & 0x000000ff];
+ bResult[nVuOffset + i / 2 * width + j + 1] = RgbVal.unsignedIntToSignedByte[(nYUV & 0x0000ff00) >> 8];
+ }
+ }
+ return new Nv21Image(bResult, width, height);
+ }
+
+ private static Bitmap readBitmap(String szFilename) {
+ File path = Environment
+ .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
+ File file = new File(path, szFilename);
+ return BitmapFactory.decodeFile(file.getAbsolutePath());
+ }
+
+ private static boolean writeBitmap(String szFilename, Bitmap bmp) {
+ try {
+ File path = Environment
+ .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
+ path.mkdirs();
+ File file = new File(path, szFilename);
+ OutputStream os = new FileOutputStream(file);
+ if (szFilename.toLowerCase().endsWith(".jpg")) {
+ bmp.compress(CompressFormat.JPEG, 100, os);
+ } else {
+ bmp.compress(CompressFormat.PNG, 100, os);
+ }
+ os.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ return false;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean writeGrayImage(byte[] bImageData, int width,
+ int height, String szFilename) {
+ Bitmap bmp = Bitmap
+ .createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ int[] nImageData = new int[width * height];
+ for (int i = 0; i < width * height; i++) {
+ int nValue = 0xff & bImageData[i];
+ nImageData[i] = Color.argb(0xff, nValue, nValue, nValue);
+ }
+ bmp.setPixels(nImageData, 0, width, 0, 0, width, height);
+ return writeBitmap(szFilename, bmp);
+ }
+
+ public static boolean writeNv21Image(byte[] bImageData, int width,
+ int height, String szFilename) {
+ Bitmap bmp = Bitmap
+ .createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ int[] nImageData = new int[width * height];
+ int nVuOffset = width * height;
+ for (int i = 0; i < height; i++) {
+ // we produce two pixels for each VU pair in the color plane
+ for (int j = 0; j < width; j += 2) {
+ int nY = 0xff & bImageData[i * width + j];
+ int nV = 0xff & bImageData[nVuOffset + (i / 2) * width + j];
+ int nU = 0xff & bImageData[nVuOffset + (i / 2) * width + j + 1];
+ nImageData[i * width + j] = AndroidColors.yuv2Color(nY, nU, nV);
+ nY = 0xff & bImageData[i * width + j + 1];
+ nImageData[i * width + j + 1] = AndroidColors.yuv2Color(nY, nU,
+ nV);
+ }
+ }
+ bmp.setPixels(nImageData, 0, width, 0, 0, width, height);
+ return writeBitmap(szFilename, bmp);
+ }
+}
Oops, something went wrong.

0 comments on commit 44f8d48

Please sign in to comment.