Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 834efce0 authored by John Hoford's avatar John Hoford Committed by Android (Google) Code Review
Browse files

Merge "vignette fix & enhance to remove center focus" into gb-ub-photos-carlsbad

parents 960e83bd 37f8e432
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ LOCAL_SRC_FILES := filters/gradient.c \
                   filters/vibrance.c \
                   filters/geometry.c \
                   filters/negative.c \
                   filters/vignette.c \
                   filters/redEyeMath.c \
                   filters/fx.c \
                   filters/wbalance.c \

jni/filters/vignette.c

deleted100644 → 0
+0 −49
Original line number Diff line number Diff line
/*
 * 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.
 */

#include "filters.h"
#include <math.h>

static int* gVignetteMap = 0;
static int gVignetteWidth = 0;
static int gVignetteHeight = 0;

void JNIFUNCF(ImageFilterVignette, nativeApplyFilter, jobject bitmap, jint width, jint height, jint centerx, jint centery, jfloat radiusx, jfloat radiusy, jfloat strength)
{
    char* destination = 0;
    AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
    int i;
    int len = width * height * 4;
    int vignette = 0;
    float d = centerx;
    if (radiusx == 0) radiusx = 10;
    if (radiusy == 0) radiusy = 10;
    float scalex = 1/radiusx;
    float scaley = 1/radiusy;

    for (i = 0; i < len; i += 4)
    {
        int p = i/4;
        float x = ((p%width)-centerx)*scalex;
        float y = ((p/width)-centery)*scaley;
        float dist = sqrt(x*x+y*y)-1;
        vignette = (int) (strength*256*MAX(dist,0));
        destination[RED] = CLAMP(destination[RED] - vignette);
        destination[GREEN] = CLAMP(destination[GREEN] - vignette);
        destination[BLUE] = CLAMP(destination[BLUE] - vignette);
    }
    AndroidBitmap_unlockPixels(env, bitmap);
}
+119 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">

    <ScrollView
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:fadeScrollbars="false">

        <GridLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:alignmentMode="alignBounds"
                android:useDefaultMargins="true"
                android:columnOrderPreserved="false"
                android:columnCount="2">

            <TextView
                    android:layout_gravity="left|center_vertical"
                    android:text="@string/vignette_exposure"
                    android:textStyle="bold"
                    android:layout_marginLeft="8dp"
                    android:visibility="gone"/>
            <TextView
                    android:layout_gravity="right|center_vertical"
                    android:id="@+id/exposureValue"
                    android:layout_marginRight="16dp"
                    android:visibility="gone"/>
            <SeekBar
                    android:id="@+id/exposureSeekBar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/FilterShowSlider"
                    android:layout_columnSpan="2"
                    android:visibility="gone"/>

            <TextView
                    android:layout_gravity="left|center_vertical"
                    android:text="@string/vignette_saturation"
                    android:textStyle="bold"
                    android:layout_marginLeft="8dp"/>
            <TextView
                    android:layout_gravity="right|center_vertical"
                    android:id="@+id/saturationValue"
                    android:layout_marginRight="16dp"/>
            <SeekBar
                    android:id="@+id/saturationSeekBar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/FilterShowSlider"
                    android:layout_columnSpan="2"/>

            <TextView
                    android:layout_gravity="left|center_vertical"
                    android:text="@string/vignette_contrast"
                    android:textStyle="bold"
                    android:layout_marginLeft="8dp"/>
            <TextView
                    android:layout_gravity="right|center_vertical"
                    android:id="@+id/contrastValue"
                    android:layout_marginRight="16dp"/>
            <SeekBar
                    android:id="@+id/contrastSeekBar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/FilterShowSlider"
                    android:layout_columnSpan="2"/>

            <TextView
                    android:layout_gravity="left|center_vertical"
                    android:text="@string/vignette_falloff"
                    android:textStyle="bold"
                    android:layout_marginLeft="8dp"/>
            <TextView
                    android:layout_gravity="right|center_vertical"
                    android:id="@+id/falloffValue"
                    android:layout_marginRight="16dp"/>
            <SeekBar
                    android:id="@+id/falloffSeekBar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    style="@style/FilterShowSlider"
                    android:layout_columnSpan="2"/>

        </GridLayout>
    </ScrollView>

    <GridLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="128dp"
            android:alignmentMode="alignBounds"
            android:useDefaultMargins="true"
            android:columnOrderPreserved="false"
            android:layout_weight="1"
            android:columnCount="2">

        <TextView
                android:layout_gravity="left|center_vertical"
                android:text="@string/vignette_main"
                android:layout_marginLeft="8dp"/>
        <TextView
                android:layout_gravity="right|center_vertical"
                android:id="@+id/mainVignetteValue"
                android:layout_marginRight="16dp"/>
        <SeekBar
                android:id="@+id/mainVignetteSeekbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/FilterShowSlider"
                android:layout_columnSpan="2"/>
    </GridLayout>

</LinearLayout>
 No newline at end of file
+38 −0
Original line number Diff line number Diff line
<!--
     Copyright (C) 2013 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.
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <group android:id="@+id/grunge_popupmenu" >
        <item
            android:id="@+id/editor_vignette_main"
            android:title="@string/vignette_main"/>
        <item
            android:id="@+id/editor_vignette_falloff"
            android:title="@string/vignette_falloff"/>
        <item
            android:id="@+id/editor_vignette_contrast"
            android:title="@string/vignette_contrast"/>
        <item
            android:id="@+id/editor_vignette_saturation"
            android:title="@string/vignette_saturation"/>
       <item
            android:id="@+id/editor_vignette_exposure"
            android:title="@string/vignette_exposure"
            android:visible= "false"/>
    </group>

</menu>
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
@@ -156,6 +156,17 @@
    <string name="curvesRGB">Curves</string>
    <!--  Label for the image vignette filter (darkens photo around edges) button [CHAR LIMIT=10] -->
    <string name="vignette">Vignette</string>
    <!--  Label for the image vignette main parameter ui [CHAR LIMIT=15] -->
    <string name="vignette_main">Vignette</string>
    <!--  Label for the image vignette exposure parameter ui [CHAR LIMIT=15] -->
    <string name="vignette_exposure">Exposure</string>
    <!--  Label for the image vignette saturation parameter ui [CHAR LIMIT=15] -->
    <string name="vignette_saturation">Saturation</string>
    <!--  Label for the image vignette contrast fparameter ui [CHAR LIMIT=15] -->
    <string name="vignette_contrast">Contrast</string>
    <!--  Label for the image vignette Falloff rate parameter ui [CHAR LIMIT=15] -->
    <string name="vignette_falloff">Falloff</string>

    <!--  Label for the image effect that removes redeye. [CHAR LIMIT=10] -->
    <string name="redeye">Red Eye</string>
    <!--  Label for the that allows drawing on Image [CHAR LIMIT=10] -->
Loading