blob: 01707de44b616d2273da481bc614beb6aeafe372 [file] [log] [blame]
/*
* Copyright (C) 2010 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 <android/bitmap.h>
#include <jni.h>
#include <cstdlib>
#include "utils.h"
#include "_jni.h"
using android::apps::photoeditor::utils::LockBitmaps;
using android::apps::photoeditor::utils::UnlockBitmaps;
namespace {
extern "C" JNIEXPORT void JNICALL Java_com_android_photoeditor_filters_ImageUtils_nativeCopy(
JNIEnv *env, jobject obj, jobject src_bitmap, jobject dst_bitmap) {
pCopyType f = (pCopyType)JNIFunc[JNI_Copy].func_ptr;
return f(env, obj, src_bitmap, dst_bitmap);
}
extern "C" void Copy(
JNIEnv *env, jobject obj, jobject src_bitmap, jobject dst_bitmap) {
AndroidBitmapInfo src_info;
AndroidBitmapInfo dst_info;
void* src_pixels;
void* dst_pixels;
int ret = LockBitmaps(
env, src_bitmap, dst_bitmap, &src_info, &dst_info, &src_pixels, &dst_pixels);
if (ret < 0) {
LOGE("LockBitmaps in Copy failed, error=%d", ret);
return;
}
memcpy(dst_pixels, src_pixels, src_info.stride * src_info.height);
UnlockBitmaps(env, src_bitmap, dst_bitmap);
}
} // namespace