• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <android/bitmap.h>
18 #include <jni.h>
19 
20 #include "convolution.h"
21 #include "utils.h"
22 #include "_jni.h"
23 
24 using android::apps::photoeditor::convolution::SpecialConvolution;
25 using android::apps::photoeditor::utils::LockBitmaps;
26 using android::apps::photoeditor::utils::UnlockBitmaps;
27 
28 namespace {
29 
Java_com_android_photoeditor_filters_ImageUtils_nativeSharpen(JNIEnv * env,jobject obj,jobject src_bitmap,jobject dst_bitmap,jfloat scale)30 extern "C" JNIEXPORT void JNICALL Java_com_android_photoeditor_filters_ImageUtils_nativeSharpen(
31     JNIEnv *env, jobject obj, jobject src_bitmap, jobject dst_bitmap, jfloat scale) {
32    pSharpenType f = (pSharpenType)JNIFunc[JNI_Sharpen].func_ptr;
33    return f(env, obj, src_bitmap, dst_bitmap, scale);
34 }
35 
Sharpen(JNIEnv * env,jobject obj,jobject src_bitmap,jobject dst_bitmap,jfloat scale)36 extern "C" void Sharpen(
37     JNIEnv *env, jobject obj, jobject src_bitmap, jobject dst_bitmap, jfloat scale) {
38   AndroidBitmapInfo src_info;
39   AndroidBitmapInfo dst_info;
40   void* src_pixels;
41   void* dst_pixels;
42 
43   int ret = LockBitmaps(
44       env, src_bitmap, dst_bitmap, &src_info, &dst_info, &src_pixels, &dst_pixels);
45   if (ret < 0) {
46     LOGE("LockBitmaps in Sharpen failed, error=%d", ret);
47     return;
48   }
49 
50   SpecialConvolution(&src_info, &dst_info, src_pixels, dst_pixels, -scale);
51 
52   UnlockBitmaps(env, src_bitmap, dst_bitmap);
53 }
54 
55 }  // namespace
56