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(ImageFilterGeometry, nativeApplyFilterFlip, jobject src, jint srcWidth, jint srcHeight, jobject dst, jint dstWidth, jint dstHeight, jint flip) {
20 char* destination = 0;
22 int len = dstWidth * dstHeight * 4;
23 if (srcWidth != dstWidth || srcHeight != dstHeight) {
26 AndroidBitmap_lockPixels(env, src, (void**) &source);
27 AndroidBitmap_lockPixels(env, dst, (void**) &destination);
29 for (; i < len; i += 4) {
31 int g = source[GREEN];
33 // TODO: implement flip
34 destination[RED] = 255;
35 destination[GREEN] = g;
36 destination[BLUE] = b;
38 AndroidBitmap_unlockPixels(env, dst);
39 AndroidBitmap_unlockPixels(env, src);
42 void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterRotate, jobject src, jint srcWidth, jint srcHeight, jobject dst, jint dstWidth, jint dstHeight, jfloat rotate) {
43 char* destination = 0;
45 int len = dstWidth * dstHeight * 4;
46 AndroidBitmap_lockPixels(env, src, (void**) &source);
47 AndroidBitmap_lockPixels(env, dst, (void**) &destination);
48 // TODO: implement rotate
50 for (; i < len; i += 4) {
52 int g = source[GREEN];
55 destination[GREEN] = 255;
56 destination[BLUE] = b;
58 AndroidBitmap_unlockPixels(env, dst);
59 AndroidBitmap_unlockPixels(env, src);
62 void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterCrop, jobject src, jint srcWidth, jint srcHeight, jobject dst, jint dstWidth, jint dstHeight, jint offsetWidth, jint offsetHeight) {
63 char* destination = 0;
65 int len = dstWidth * dstHeight * 4;
66 AndroidBitmap_lockPixels(env, src, (void**) &source);
67 AndroidBitmap_lockPixels(env, dst, (void**) &destination);
68 // TODO: implement crop
70 for (; i < len; i += 4) {
72 int g = source[GREEN];
75 destination[GREEN] = g;
76 destination[BLUE] = 255;
78 AndroidBitmap_unlockPixels(env, dst);
79 AndroidBitmap_unlockPixels(env, src);
82 void JNIFUNCF(ImageFilterGeometry, nativeApplyFilterStraighten, jobject src, jint srcWidth, jint srcHeight, jobject dst, jint dstWidth, jint dstHeight, jfloat straightenAngle) {
83 char* destination = 0;
85 int len = dstWidth * dstHeight * 4;
86 AndroidBitmap_lockPixels(env, src, (void**) &source);
87 AndroidBitmap_lockPixels(env, dst, (void**) &destination);
88 // TODO: implement straighten
90 for (; i < len; i += 4) {
92 int g = source[GREEN];
94 destination[RED] = 128;
95 destination[GREEN] = g;
96 destination[BLUE] = 128;
98 AndroidBitmap_unlockPixels(env, dst);
99 AndroidBitmap_unlockPixels(env, src);