diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/gallery3d/filtershow/FilterShowActivity.java | 6 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/cache/ImageLoader.java | 18 | ||||
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java (renamed from src/com/android/gallery3d/filtershow/filters/ImageFilterBrightness.java) | 7 | ||||
-rw-r--r-- | src/com/android/gallery3d/ui/ExtTexture.java | 5 | ||||
-rw-r--r-- | src/com/android/gallery3d/util/TextureBuffer.java | 49 |
5 files changed, 74 insertions, 11 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index eb95d7452..4570eb017 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -753,14 +753,14 @@ public class FilterShowActivity extends Activity implements OnItemClickListener mImageShow.setVisibility(View.VISIBLE); mImageShow.setShowControls(true); ImagePreset preset = mImageShow.getImagePreset(); - ImageFilter filter = preset.getFilter("Brightness"); + ImageFilter filter = preset.getFilter("Exposure"); if (filter == null) { - ImageFilterBrightness bright = new ImageFilterBrightness(); + ImageFilterExposure bright = new ImageFilterExposure(); ImagePreset copy = new ImagePreset(preset); copy.add(bright); copy.setHistoryName(bright.getName()); copy.setIsFx(false); - filter = copy.getFilter("Brightness"); + filter = copy.getFilter("Exposure"); mImageShow.setImagePreset(copy); } mImageShow.setCurrentFilter(filter); diff --git a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java index 19a841a4b..2c8fff9a2 100644 --- a/src/com/android/gallery3d/filtershow/cache/ImageLoader.java +++ b/src/com/android/gallery3d/filtershow/cache/ImageLoader.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Vector; +import com.android.gallery3d.common.Utils; import com.android.gallery3d.filtershow.FilterShowActivity; import com.android.gallery3d.filtershow.HistoryAdapter; import com.android.gallery3d.filtershow.imageshow.ImageShow; @@ -17,6 +18,7 @@ import com.android.gallery3d.R; import android.content.Context; import android.content.res.Resources; import android.database.Cursor; +import android.database.sqlite.SQLiteException; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; @@ -58,11 +60,17 @@ public class ImageLoader { } private int getOrientation(Uri uri) { - Cursor cursor = mContext.getContentResolver().query(uri, - new String[] { - MediaStore.Images.ImageColumns.ORIENTATION - }, - null, null, null); + Cursor cursor = null; + try { + cursor = mContext.getContentResolver().query(uri, + new String[] { + MediaStore.Images.ImageColumns.ORIENTATION + }, + null, null, null); + } catch (SQLiteException e){ + Utils.closeSilently(cursor); + return ExifInterface.ORIENTATION_UNDEFINED; + } if (cursor.getCount() != 1) { return -1; diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBrightness.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java index ab61a00c2..85b6e4f6b 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBrightness.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterExposure.java @@ -3,14 +3,15 @@ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; -public class ImageFilterBrightness extends ImageFilter { +public class ImageFilterExposure extends ImageFilter { - public ImageFilterBrightness() { - mName = "Brightness"; + public ImageFilterExposure() { + mName = "Exposure"; } native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright); + @Override public void apply(Bitmap bitmap) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); diff --git a/src/com/android/gallery3d/ui/ExtTexture.java b/src/com/android/gallery3d/ui/ExtTexture.java index eac504fe5..72b214ff4 100644 --- a/src/com/android/gallery3d/ui/ExtTexture.java +++ b/src/com/android/gallery3d/ui/ExtTexture.java @@ -33,6 +33,11 @@ public class ExtTexture extends BasicTexture { mTarget = target; } + public ExtTexture(int target, int width, int height) { + this(target); + setSize(width, height); + } + private void uploadToCanvas(GLCanvas canvas) { GL11 gl = canvas.getGLInstance(); diff --git a/src/com/android/gallery3d/util/TextureBuffer.java b/src/com/android/gallery3d/util/TextureBuffer.java new file mode 100644 index 000000000..509433b53 --- /dev/null +++ b/src/com/android/gallery3d/util/TextureBuffer.java @@ -0,0 +1,49 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.gallery3d.util; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +/** + * Keeps a buffer of data as read from a frame buffer. This can be used with + * glTexSubImage2D to write to a texture. + */ +public class TextureBuffer { + private int mWidth; + private int mHeight; + private ByteBuffer mBuffer; + + public TextureBuffer(int width, int height) { + mWidth = width; + mHeight = height; + + mBuffer = ByteBuffer.allocateDirect(width * height * 4).order(ByteOrder.nativeOrder()); + } + + public int getWidth() { + return mWidth; + } + + public int getHeight() { + return mHeight; + } + + public ByteBuffer getBuffer() { + return mBuffer; + } +} |