190b1d251973bfa748d435896fc277cb4024451adJohn Hoford/*
290b1d251973bfa748d435896fc277cb4024451adJohn Hoford * Copyright (C) 2012 The Android Open Source Project
390b1d251973bfa748d435896fc277cb4024451adJohn Hoford *
490b1d251973bfa748d435896fc277cb4024451adJohn Hoford * Licensed under the Apache License, Version 2.0 (the "License");
590b1d251973bfa748d435896fc277cb4024451adJohn Hoford * you may not use this file except in compliance with the License.
690b1d251973bfa748d435896fc277cb4024451adJohn Hoford * You may obtain a copy of the License at
790b1d251973bfa748d435896fc277cb4024451adJohn Hoford *
890b1d251973bfa748d435896fc277cb4024451adJohn Hoford *      http://www.apache.org/licenses/LICENSE-2.0
990b1d251973bfa748d435896fc277cb4024451adJohn Hoford *
1090b1d251973bfa748d435896fc277cb4024451adJohn Hoford * Unless required by applicable law or agreed to in writing, software
1190b1d251973bfa748d435896fc277cb4024451adJohn Hoford * distributed under the License is distributed on an "AS IS" BASIS,
1290b1d251973bfa748d435896fc277cb4024451adJohn Hoford * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1390b1d251973bfa748d435896fc277cb4024451adJohn Hoford * See the License for the specific language governing permissions and
1490b1d251973bfa748d435896fc277cb4024451adJohn Hoford * limitations under the License.
1590b1d251973bfa748d435896fc277cb4024451adJohn Hoford */
1690b1d251973bfa748d435896fc277cb4024451adJohn Hoford
1790b1d251973bfa748d435896fc277cb4024451adJohn Hoford#include <math.h>
1890b1d251973bfa748d435896fc277cb4024451adJohn Hoford#include "filters.h"
1990b1d251973bfa748d435896fc277cb4024451adJohn Hoford
2090b1d251973bfa748d435896fc277cb4024451adJohn Hoford void JNIFUNCF(ImageFilterRedEye, nativeApplyFilter, jobject bitmap, jint width, jint height, jshortArray vrect)
2190b1d251973bfa748d435896fc277cb4024451adJohn Hoford {
2290b1d251973bfa748d435896fc277cb4024451adJohn Hoford     char* destination = 0;
2390b1d251973bfa748d435896fc277cb4024451adJohn Hoford     AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
2490b1d251973bfa748d435896fc277cb4024451adJohn Hoford     unsigned char * rgb = (unsigned char * )destination;
2590b1d251973bfa748d435896fc277cb4024451adJohn Hoford     short* rect = (*env)->GetShortArrayElements(env, vrect,0);
2690b1d251973bfa748d435896fc277cb4024451adJohn Hoford
2790b1d251973bfa748d435896fc277cb4024451adJohn Hoford     filterRedEye(rgb,rgb,width,height,rect);
2890b1d251973bfa748d435896fc277cb4024451adJohn Hoford
2990b1d251973bfa748d435896fc277cb4024451adJohn Hoford     (*env)->ReleaseShortArrayElements(env, vrect, rect, 0);
3090b1d251973bfa748d435896fc277cb4024451adJohn Hoford     AndroidBitmap_unlockPixels(env, bitmap);
3190b1d251973bfa748d435896fc277cb4024451adJohn Hoford }
32