1d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford/* 2d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * Copyright (C) 2012 The Android Open Source Project 3d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * 4d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * Licensed under the Apache License, Version 2.0 (the "License"); 5d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * you may not use this file except in compliance with the License. 6d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * You may obtain a copy of the License at 7d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * 8d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * http://www.apache.org/licenses/LICENSE-2.0 9d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * 10d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * Unless required by applicable law or agreed to in writing, software 11d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * distributed under the License is distributed on an "AS IS" BASIS, 12d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * See the License for the specific language governing permissions and 14d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford * limitations under the License. 15d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford */ 16d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 17d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford#include "filters.h" 18d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 19bf97d3aaeddfba06f6a00ee7abb23fcd28eb2e7dJohn Hofordvoid JNIFUNCF(ImageFilterExposure, nativeApplyFilter, jobject bitmap, jint width, jint height, jfloat bright) 20d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford{ 21d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford char* destination = 0; 22d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford AndroidBitmap_lockPixels(env, bitmap, (void**) &destination); 23d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford unsigned char * rgb = (unsigned char * )destination; 24d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford int i; 25d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford int len = width * height * 4; 26bf97d3aaeddfba06f6a00ee7abb23fcd28eb2e7dJohn Hoford 27bf97d3aaeddfba06f6a00ee7abb23fcd28eb2e7dJohn Hoford int m = (255-bright); 28d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 29d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford for (i = 0; i < len; i+=4) 30d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford { 31bf97d3aaeddfba06f6a00ee7abb23fcd28eb2e7dJohn Hoford rgb[RED] = clamp((255*(rgb[RED]))/m); 32bf97d3aaeddfba06f6a00ee7abb23fcd28eb2e7dJohn Hoford rgb[GREEN] = clamp((255*(rgb[GREEN]))/m); 33bf97d3aaeddfba06f6a00ee7abb23fcd28eb2e7dJohn Hoford rgb[BLUE] = clamp((255*(rgb[BLUE]))/m); 34d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford } 35d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford AndroidBitmap_unlockPixels(env, bitmap); 36d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford} 37d42f6c69c5980110c16cd679f914c4e4e7caa29dJohn Hoford 38