2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 void JNIFUNCF(ImageFilterBW, nativeApplyFilter, jobject bitmap, jint width, jint height)
21 char* destination = 0;
22 AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
24 int len = width * height * 4;
29 for (i = 0; i < len; i+=4)
31 int r = destination[RED];
32 int g = destination[GREEN];
33 int b = destination[BLUE];
34 int t = CLAMP(Rf * r + Gf * g + Bf *b);
37 destination[GREEN] = t;
38 destination[BLUE] = t;
40 AndroidBitmap_unlockPixels(env, bitmap);
43 void JNIFUNCF(ImageFilterBWRed, nativeApplyFilter, jobject bitmap, jint width, jint height)
45 char* destination = 0;
46 AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
48 int len = width * height * 4;
49 for (i = 0; i < len; i+=4)
51 int r = destination[RED];
52 int g = destination[GREEN];
53 int b = destination[BLUE];
59 destination[GREEN] = g;
60 destination[BLUE] = b;
62 AndroidBitmap_unlockPixels(env, bitmap);
65 void JNIFUNCF(ImageFilterBWGreen, nativeApplyFilter, jobject bitmap, jint width, jint height)
67 char* destination = 0;
68 AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
70 int len = width * height * 4;
71 for (i = 0; i < len; i+=4)
73 int r = destination[RED];
74 int g = destination[GREEN];
75 int b = destination[BLUE];
81 destination[GREEN] = g;
82 destination[BLUE] = b;
84 AndroidBitmap_unlockPixels(env, bitmap);
87 void JNIFUNCF(ImageFilterBWBlue, nativeApplyFilter, jobject bitmap, jint width, jint height)
89 char* destination = 0;
90 AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
92 int len = width * height * 4;
93 for (i = 0; i < len; i+=4)
95 int r = destination[RED];
96 int g = destination[GREEN];
97 int b = destination[BLUE];
102 destination[RED] = r;
103 destination[GREEN] = g;
104 destination[BLUE] = b;
106 AndroidBitmap_unlockPixels(env, bitmap);