summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--graphics/java/android/renderscript/Matrix4f.java28
-rw-r--r--graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java94
-rw-r--r--graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java2
-rw-r--r--tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/city.pngbin611708 -> 0 bytes
-rw-r--r--tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067.jpgbin0 -> 1062402 bytes
-rw-r--r--tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img640x427.jpgbin0 -> 199029 bytes
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java4
7 files changed, 120 insertions, 8 deletions
diff --git a/graphics/java/android/renderscript/Matrix4f.java b/graphics/java/android/renderscript/Matrix4f.java
index a85d464..4600424 100644
--- a/graphics/java/android/renderscript/Matrix4f.java
+++ b/graphics/java/android/renderscript/Matrix4f.java
@@ -113,6 +113,34 @@ public class Matrix4f {
}
/**
+ * Sets the values of the matrix to those of the parameter
+ *
+ * @param src matrix to load the values from
+ * @hide
+ */
+ public void load(Matrix3f src) {
+ mMat[0] = src.mMat[0];
+ mMat[1] = src.mMat[1];
+ mMat[2] = src.mMat[2];
+ mMat[3] = 0;
+
+ mMat[4] = src.mMat[3];
+ mMat[5] = src.mMat[4];
+ mMat[6] = src.mMat[5];
+ mMat[7] = 0;
+
+ mMat[8] = src.mMat[6];
+ mMat[9] = src.mMat[7];
+ mMat[10] = src.mMat[8];
+ mMat[11] = 0;
+
+ mMat[12] = 0;
+ mMat[13] = 0;
+ mMat[14] = 0;
+ mMat[15] = 1;
+ }
+
+ /**
* Sets current values to be a rotation matrix of certain angle
* about a given axis
*
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
index 41e7e00..dce1939 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
@@ -39,8 +39,7 @@ public class ScriptIntrinsicColorMatrix extends ScriptIntrinsic {
}
/**
- * Supported elements types are float, float4, uchar, uchar4
- *
+ * Supported elements types are uchar4
*
* @param rs
* @param e
@@ -53,13 +52,98 @@ public class ScriptIntrinsicColorMatrix extends ScriptIntrinsic {
}
- public void setColorMatrix(Matrix4f m) {
- mMatrix.load(m);
+ private void setMatrix() {
FieldPacker fp = new FieldPacker(16*4);
- fp.addMatrix(m);
+ fp.addMatrix(mMatrix);
setVar(0, fp);
}
+ /**
+ * Set the color matrix which will be applied to each cell of the image.
+ *
+ * @param m The 4x4 matrix to set.
+ */
+ public void setColorMatrix(Matrix4f m) {
+ mMatrix.load(m);
+ setMatrix();
+ }
+
+ /**
+ * Set the color matrix which will be applied to each cell of the image.
+ * This will set the alpha channel to be a copy.
+ *
+ * @param m The 3x3 matrix to set.
+ */
+ public void setColorMatrix(Matrix3f m) {
+ mMatrix.load(m);
+ setMatrix();
+ }
+
+ /**
+ * Set a color matrix to convert from RGB to luminace. The alpha channel
+ * will be a copy.
+ *
+ */
+ public void setGreyscale() {
+ mMatrix.loadIdentity();
+ mMatrix.set(0, 0, 0.299f);
+ mMatrix.set(1, 0, 0.587f);
+ mMatrix.set(2, 0, 0.114f);
+ mMatrix.set(0, 1, 0.299f);
+ mMatrix.set(1, 1, 0.587f);
+ mMatrix.set(2, 1, 0.114f);
+ mMatrix.set(0, 2, 0.299f);
+ mMatrix.set(1, 2, 0.587f);
+ mMatrix.set(2, 2, 0.114f);
+ setMatrix();
+ }
+
+ /**
+ * Set the matrix to convert from YUV to RGB with a direct copy of the 4th
+ * channel.
+ *
+ */
+ public void setYUVtoRGB() {
+ mMatrix.loadIdentity();
+ mMatrix.set(0, 0, 1.f);
+ mMatrix.set(1, 0, 0.f);
+ mMatrix.set(2, 0, 1.13983f);
+ mMatrix.set(0, 1, 1.f);
+ mMatrix.set(1, 1, -0.39465f);
+ mMatrix.set(2, 1, -0.5806f);
+ mMatrix.set(0, 2, 1.f);
+ mMatrix.set(1, 2, 2.03211f);
+ mMatrix.set(2, 2, 0.f);
+ setMatrix();
+ }
+
+ /**
+ * Set the matrix to convert from RGB to YUV with a direct copy of the 4th
+ * channel.
+ *
+ */
+ public void setRGBtoYUV() {
+ mMatrix.loadIdentity();
+ mMatrix.set(0, 0, 0.299f);
+ mMatrix.set(1, 0, 0.587f);
+ mMatrix.set(2, 0, 0.114f);
+ mMatrix.set(0, 1, -0.14713f);
+ mMatrix.set(1, 1, -0.28886f);
+ mMatrix.set(2, 1, 0.436f);
+ mMatrix.set(0, 2, 0.615f);
+ mMatrix.set(1, 2, -0.51499f);
+ mMatrix.set(2, 2, -0.10001f);
+ setMatrix();
+ }
+
+
+ /**
+ * Invoke the kernel and apply the matrix to each cell of ain and copy to
+ * aout.
+ *
+ * @param ain Input allocation
+ * @param aout Output allocation
+ */
public void forEach(Allocation ain, Allocation aout) {
forEach(0, ain, aout, null);
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java b/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java
index ee5f938..b4a228b 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicYuvToRGB.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/city.png b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/city.png
deleted file mode 100644
index 856eeff..0000000
--- a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/city.png
+++ /dev/null
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067.jpg b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067.jpg
new file mode 100644
index 0000000..05d3ee2
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img1600x1067.jpg
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img640x427.jpg b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img640x427.jpg
new file mode 100644
index 0000000..5bce392
--- /dev/null
+++ b/tests/RenderScriptTests/ImageProcessing/res/drawable-nodpi/img640x427.jpg
Binary files differ
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
index 001dea8..2e7c671 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/ImageProcessingActivity.java
@@ -243,8 +243,8 @@ public class ImageProcessingActivity extends Activity
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
- mBitmapIn = loadBitmap(R.drawable.city);
- mBitmapOut = loadBitmap(R.drawable.city);
+ mBitmapIn = loadBitmap(R.drawable.img1600x1067);
+ mBitmapOut = loadBitmap(R.drawable.img1600x1067);
mSurfaceView = (SurfaceView) findViewById(R.id.surface);