aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/cyanogenmod/wallpapers/photophase/utils
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-08-20 00:33:19 +0200
committerJorge Ruesga <jorge@ruesga.com>2013-08-20 00:33:19 +0200
commit1b537a79ceedcd2369941ef6d7ca1371d395bcef (patch)
tree4b4a2719191d5f7c60e8fa10d90bfa4e00eb2c4a /src/org/cyanogenmod/wallpapers/photophase/utils
parent8a28e0b1dd9386c70732860e71d5ee91643d61f8 (diff)
downloadandroid_packages_wallpapers_PhotoPhase-1b537a79ceedcd2369941ef6d7ca1371d395bcef.tar.gz
android_packages_wallpapers_PhotoPhase-1b537a79ceedcd2369941ef6d7ca1371d395bcef.tar.bz2
android_packages_wallpapers_PhotoPhase-1b537a79ceedcd2369941ef6d7ca1371d395bcef.zip
Force to use image dimensions instead of screen dimensions (#26)
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/org/cyanogenmod/wallpapers/photophase/utils')
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java8
-rw-r--r--src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java21
2 files changed, 18 insertions, 11 deletions
diff --git a/src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java b/src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java
index fb49c72..3848402 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/utils/BitmapUtils.java
@@ -58,8 +58,12 @@ public class BitmapUtils {
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(file.getAbsolutePath(), options);
- // Calculate inSampleSize
- options.inSampleSize = calculateBitmapRatio(options, reqWidth, reqHeight);
+ // Calculate inSampleSize (use 1024 as maximum size, the minimum supported
+ // by all the gles20 devices)
+ options.inSampleSize = calculateBitmapRatio(
+ options,
+ Math.min(reqWidth, 1024),
+ Math.min(reqHeight, 1024));
// Decode the bitmap with inSampleSize set
options.inJustDecodeBounds = false;
diff --git a/src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java b/src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java
index cc1073c..ec5834f 100644
--- a/src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java
+++ b/src/org/cyanogenmod/wallpapers/photophase/utils/GLESUtil.java
@@ -312,12 +312,12 @@ public final class GLESUtil {
* @param file The image file
* @param dimensions The desired dimensions
* @param effect The effect to apply to the image or null if no effect is needed
- * @param screenDim The screen dimensions
+ * @param dimen The new dimensions
* @param recycle If the bitmap should be recycled
* @return GLESTextureInfo The texture info
*/
public static GLESTextureInfo loadTexture(
- File file, Rect dimensions, Effect effect, Rect screenDim, boolean recycle) {
+ File file, Rect dimensions, Effect effect, Rect dimen, boolean recycle) {
Bitmap bitmap = null;
try {
// Decode and associate the bitmap (invert the desired dimensions)
@@ -328,7 +328,7 @@ public final class GLESUtil {
}
if (DEBUG) Log.d(TAG, "image: " + file.getAbsolutePath());
- GLESTextureInfo ti = loadTexture(bitmap, effect, screenDim);
+ GLESTextureInfo ti = loadTexture(bitmap, effect, dimen);
ti.path = file;
return ti;
@@ -351,12 +351,12 @@ public final class GLESUtil {
* @param ctx The current context
* @param resourceId The resource identifier
* @param effect The effect to apply to the image or null if no effect is needed
- * @param screenDim The screen dimensions
+ * @param dimen The new dimensions
* @param recycle If the bitmap should be recycled
* @return GLESTextureInfo The texture info
*/
public static GLESTextureInfo loadTexture(
- Context ctx, int resourceId, Effect effect, Rect screenDim, boolean recycle) {
+ Context ctx, int resourceId, Effect effect, Rect dimen, boolean recycle) {
Bitmap bitmap = null;
InputStream raw = null;
try {
@@ -370,7 +370,7 @@ public final class GLESUtil {
}
if (DEBUG) Log.d(TAG, "resourceId: " + resourceId);
- GLESTextureInfo ti = loadTexture(bitmap, effect, screenDim);
+ GLESTextureInfo ti = loadTexture(bitmap, effect, dimen);
return ti;
} catch (Exception e) {
@@ -399,10 +399,10 @@ public final class GLESUtil {
*
* @param bitmap The bitmap reference
* @param effect The effect to apply to the image or null if no effect is needed
- * @param screenDim The screen dimensions
+ * @param dimen The new dimensions
* @return GLESTextureInfo The texture info
*/
- public static GLESTextureInfo loadTexture(Bitmap bitmap, Effect effect, Rect screenDim) {
+ public static GLESTextureInfo loadTexture(Bitmap bitmap, Effect effect, Rect dimen) {
// Check that we have a valid image name reference
if (bitmap == null) {
return new GLESTextureInfo();
@@ -444,7 +444,10 @@ public final class GLESUtil {
if (effect != null) {
// Apply the effect (we need a thread-safe call here)
synchronized (sSync) {
- effect.apply(textureNames[0], screenDim.width(), screenDim.height(), textureNames[1]);
+ // No more than 1024 (the minimum supported by all the gles20 devices)
+ int w = Math.min(dimen.width(), 1024);
+ int h = Math.min(dimen.width(), 1024);
+ effect.apply(textureNames[0], w, h, textureNames[1]);
}
handle = textureNames[1];