├── AndroidManifest.xml
├── README.md
├── bin
├── AndroidManifest.xml
├── Camera Overlay.apk
├── classes.dex
├── classes
│ └── com
│ │ └── sailabs
│ │ └── photo
│ │ ├── BuildConfig.class
│ │ ├── MainActivity$1.class
│ │ ├── MainActivity$2.class
│ │ ├── MainActivity$3.class
│ │ ├── MainActivity$4.class
│ │ ├── MainActivity.class
│ │ ├── R$attr.class
│ │ ├── R$dimen.class
│ │ ├── R$drawable.class
│ │ ├── R$id.class
│ │ ├── R$layout.class
│ │ ├── R$menu.class
│ │ ├── R$string.class
│ │ ├── R$style.class
│ │ └── R.class
├── dexedLibs
│ └── android-support-v4-602c936ecaa99f57dfcbd7353dc8b7bc.jar
├── res
│ ├── drawable-hdpi
│ │ ├── camera.png
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ ├── ic_launcher.png
│ │ └── mark3.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ └── drawable-xxhdpi
│ │ └── ic_launcher.png
└── resources.ap_
├── gen
└── com
│ └── sailabs
│ └── photo
│ ├── BuildConfig.java
│ └── R.java
├── ic_launcher-web.png
├── libs
└── android-support-v4.jar
├── proguard-project.txt
├── project.properties
├── res
├── drawable-hdpi
│ ├── camera.png
│ └── ic_launcher.png
├── drawable-mdpi
│ ├── ic_launcher.png
│ └── mark3.png
├── drawable-xhdpi
│ └── ic_launcher.png
├── drawable-xxhdpi
│ └── ic_launcher.png
├── layout
│ └── activity_main.xml
├── menu
│ └── main.xml
├── values-sw600dp
│ └── dimens.xml
├── values-sw720dp-land
│ └── dimens.xml
├── values-v11
│ └── styles.xml
├── values-v14
│ └── styles.xml
└── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── result.jpg
└── src
└── com
└── sailabs
└── photo
└── MainActivity.java
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Camera-Overlay-Android
2 | ======================
3 |
4 | Overlay Image in Camera Android and take picture
5 |
6 | Custom Surface View and overlay image, and show and save the picture fo folder photoAR SDcard
7 |
8 | 
9 |
10 |
--------------------------------------------------------------------------------
/bin/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/bin/Camera Overlay.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/Camera Overlay.apk
--------------------------------------------------------------------------------
/bin/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes.dex
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/BuildConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/BuildConfig.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/MainActivity$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/MainActivity$1.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/MainActivity$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/MainActivity$2.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/MainActivity$3.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/MainActivity$3.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/MainActivity$4.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/MainActivity$4.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/MainActivity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/MainActivity.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/R$attr.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/R$attr.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/R$dimen.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/R$dimen.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/R$drawable.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/R$drawable.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/R$id.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/R$id.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/R$layout.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/R$layout.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/R$menu.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/R$menu.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/R$string.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/R$string.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/R$style.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/R$style.class
--------------------------------------------------------------------------------
/bin/classes/com/sailabs/photo/R.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/classes/com/sailabs/photo/R.class
--------------------------------------------------------------------------------
/bin/dexedLibs/android-support-v4-602c936ecaa99f57dfcbd7353dc8b7bc.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/dexedLibs/android-support-v4-602c936ecaa99f57dfcbd7353dc8b7bc.jar
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/res/drawable-hdpi/camera.png
--------------------------------------------------------------------------------
/bin/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-mdpi/mark3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/res/drawable-mdpi/mark3.png
--------------------------------------------------------------------------------
/bin/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/bin/resources.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/bin/resources.ap_
--------------------------------------------------------------------------------
/gen/com/sailabs/photo/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /** Automatically generated file. DO NOT MODIFY */
2 | package com.sailabs.photo;
3 |
4 | public final class BuildConfig {
5 | public final static boolean DEBUG = true;
6 | }
--------------------------------------------------------------------------------
/gen/com/sailabs/photo/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * aapt tool from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 |
8 | package com.sailabs.photo;
9 |
10 | public final class R {
11 | public static final class attr {
12 | }
13 | public static final class dimen {
14 | /** Default screen margins, per the Android Design guidelines.
15 |
16 | Customize dimensions originally defined in res/values/dimens.xml (such as
17 | screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
18 |
19 | */
20 | public static final int activity_horizontal_margin=0x7f040000;
21 | public static final int activity_vertical_margin=0x7f040001;
22 | }
23 | public static final class drawable {
24 | public static final int camera=0x7f020000;
25 | public static final int ic_launcher=0x7f020001;
26 | public static final int mark3=0x7f020002;
27 | }
28 | public static final class id {
29 | public static final int action_settings=0x7f080004;
30 | public static final int button1=0x7f080003;
31 | public static final int containerImg=0x7f080000;
32 | public static final int imageView1=0x7f080002;
33 | public static final int surfaceView1=0x7f080001;
34 | }
35 | public static final class layout {
36 | public static final int activity_main=0x7f030000;
37 | }
38 | public static final class menu {
39 | public static final int main=0x7f070000;
40 | }
41 | public static final class string {
42 | public static final int action_settings=0x7f050001;
43 | public static final int app_name=0x7f050000;
44 | public static final int hello_world=0x7f050002;
45 | }
46 | public static final class style {
47 | /**
48 | Base application theme, dependent on API level. This theme is replaced
49 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
50 |
51 |
52 | Theme customizations available in newer API levels can go in
53 | res/values-vXX/styles.xml, while customizations related to
54 | backward-compatibility can go here.
55 |
56 |
57 | Base application theme for API 11+. This theme completely replaces
58 | AppBaseTheme from res/values/styles.xml on API 11+ devices.
59 |
60 | API 11 theme customizations can go here.
61 |
62 | Base application theme for API 14+. This theme completely replaces
63 | AppBaseTheme from BOTH res/values/styles.xml and
64 | res/values-v11/styles.xml on API 14+ devices.
65 |
66 | API 14 theme customizations can go here.
67 | */
68 | public static final int AppBaseTheme=0x7f060000;
69 | /** Application theme.
70 | All customizations that are NOT specific to a particular API-level can go here.
71 | */
72 | public static final int AppTheme=0x7f060001;
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/ic_launcher-web.png
--------------------------------------------------------------------------------
/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-17
15 |
--------------------------------------------------------------------------------
/res/drawable-hdpi/camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/res/drawable-hdpi/camera.png
--------------------------------------------------------------------------------
/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-mdpi/mark3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/res/drawable-mdpi/mark3.png
--------------------------------------------------------------------------------
/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
17 |
18 |
26 |
27 |
28 |
29 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/res/values-sw720dp-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 128dp
8 |
9 |
10 |
--------------------------------------------------------------------------------
/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Camera Overlay
5 | Settings
6 | Hello world!
7 |
8 |
9 |
--------------------------------------------------------------------------------
/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/result.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SeptiyanAndika/Camera-Overlay-Android/81a78cdaa1a60944330f5f1cc69d5dea331c548c/result.jpg
--------------------------------------------------------------------------------
/src/com/sailabs/photo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.sailabs.photo;
2 |
3 | import java.io.File;
4 | import java.io.FileNotFoundException;
5 | import java.io.FileOutputStream;
6 | import java.io.IOException;
7 |
8 |
9 | import android.app.Activity;
10 | import android.content.Intent;
11 | import android.content.res.Configuration;
12 | import android.graphics.Bitmap;
13 | import android.graphics.BitmapFactory;
14 | import android.graphics.Canvas;
15 | import android.graphics.PixelFormat;
16 | import android.graphics.drawable.Drawable;
17 | import android.hardware.Camera;
18 | import android.hardware.Camera.PictureCallback;
19 | import android.hardware.Camera.ShutterCallback;
20 | import android.net.Uri;
21 | import android.os.Bundle;
22 | import android.os.Environment;
23 | import android.util.Log;
24 | import android.view.Display;
25 | import android.view.LayoutInflater;
26 | import android.view.SurfaceHolder;
27 | import android.view.SurfaceView;
28 | import android.view.View;
29 | import android.view.Window;
30 | import android.view.WindowManager;
31 | import android.view.View.OnClickListener;
32 | import android.widget.Button;
33 | import android.widget.FrameLayout;
34 | import android.widget.RelativeLayout;
35 | import android.widget.Toast;
36 | import android.widget.RelativeLayout.LayoutParams;
37 |
38 | public class MainActivity extends Activity implements SurfaceHolder.Callback
39 | {
40 | private Camera camera = null;
41 | private SurfaceView cameraSurfaceView = null;
42 | private SurfaceHolder cameraSurfaceHolder = null;
43 | private boolean previewing = false;
44 | RelativeLayout relativeLayout;
45 |
46 |
47 |
48 |
49 |
50 | private Button btnCapture = null;
51 |
52 | @Override
53 | protected void onCreate(Bundle savedInstanceState)
54 | {
55 | // TODO Auto-generated method stub
56 | super.onCreate(savedInstanceState);
57 |
58 |
59 |
60 | getWindow().setFormat(PixelFormat.TRANSLUCENT);
61 | requestWindowFeature(Window.FEATURE_NO_TITLE);
62 | getWindow().setFlags(
63 | WindowManager.LayoutParams.FLAG_FULLSCREEN,
64 | WindowManager.LayoutParams.FLAG_FULLSCREEN);
65 |
66 | setContentView(R.layout.activity_main);
67 |
68 | relativeLayout=(RelativeLayout) findViewById(R.id.containerImg);
69 | relativeLayout.setDrawingCacheEnabled(true);
70 | cameraSurfaceView = (SurfaceView)
71 | findViewById(R.id.surfaceView1);
72 | // cameraSurfaceView.setLayoutParams(new FrameLayout.LayoutParams(640, 480));
73 | cameraSurfaceHolder = cameraSurfaceView.getHolder();
74 | cameraSurfaceHolder.addCallback(this);
75 | // cameraSurfaceHolder.setType(SurfaceHolder.
76 | // SURFACE_TYPE_PUSH_BUFFERS);
77 |
78 |
79 |
80 |
81 | btnCapture = (Button)findViewById(R.id.button1);
82 | btnCapture.setOnClickListener(new OnClickListener()
83 | {
84 | @Override
85 | public void onClick(View v)
86 | {
87 | // TODO Auto-generated method stub
88 | camera.takePicture(cameraShutterCallback,
89 | cameraPictureCallbackRaw,
90 | cameraPictureCallbackJpeg);
91 | }
92 | });
93 | }
94 |
95 | ShutterCallback cameraShutterCallback = new ShutterCallback()
96 | {
97 | @Override
98 | public void onShutter()
99 | {
100 | // TODO Auto-generated method stub
101 | }
102 | };
103 |
104 | PictureCallback cameraPictureCallbackRaw = new PictureCallback()
105 | {
106 | @Override
107 | public void onPictureTaken(byte[] data, Camera camera)
108 | {
109 | // TODO Auto-generated method stub
110 | }
111 | };
112 |
113 | PictureCallback cameraPictureCallbackJpeg = new PictureCallback()
114 | {
115 | @Override
116 | public void onPictureTaken(byte[] data, Camera camera)
117 | {
118 | // TODO Auto-generated method stub
119 | Bitmap cameraBitmap = BitmapFactory.decodeByteArray
120 | (data, 0, data.length);
121 |
122 | int wid = cameraBitmap.getWidth();
123 | int hgt = cameraBitmap.getHeight();
124 |
125 | // Toast.makeText(getApplicationContext(), wid+""+hgt, Toast.LENGTH_SHORT).show();
126 | Bitmap newImage = Bitmap.createBitmap
127 | (wid, hgt, Bitmap.Config.ARGB_8888);
128 |
129 | Canvas canvas = new Canvas(newImage);
130 |
131 | canvas.drawBitmap(cameraBitmap, 0f, 0f, null);
132 |
133 | Drawable drawable = getResources().getDrawable
134 | (R.drawable.mark3);
135 | drawable.setBounds(20, 30, drawable.getIntrinsicWidth()+20, drawable.getIntrinsicHeight()+30);
136 | drawable.draw(canvas);
137 |
138 |
139 |
140 | File storagePath = new File(Environment.
141 | getExternalStorageDirectory() + "/PhotoAR/");
142 | storagePath.mkdirs();
143 |
144 | File myImage = new File(storagePath,
145 | Long.toString(System.currentTimeMillis()) + ".jpg");
146 |
147 | try
148 | {
149 | FileOutputStream out = new FileOutputStream(myImage);
150 | newImage.compress(Bitmap.CompressFormat.JPEG, 80, out);
151 |
152 |
153 | out.flush();
154 | out.close();
155 | }
156 | catch(FileNotFoundException e)
157 | {
158 | Log.d("In Saving File", e + "");
159 | }
160 | catch(IOException e)
161 | {
162 | Log.d("In Saving File", e + "");
163 | }
164 |
165 | camera.startPreview();
166 |
167 |
168 |
169 | newImage.recycle();
170 | newImage = null;
171 |
172 | Intent intent = new Intent();
173 | intent.setAction(Intent.ACTION_VIEW);
174 |
175 | intent.setDataAndType(Uri.parse("file://" + myImage.getAbsolutePath()), "image/*");
176 | startActivity(intent);
177 |
178 | }
179 | };
180 |
181 | @Override
182 | public void surfaceChanged(SurfaceHolder holder,
183 | int format, int width, int height)
184 | {
185 | // TODO Auto-generated method stub
186 |
187 | if(previewing)
188 | {
189 | camera.stopPreview();
190 | previewing = false;
191 | }
192 | try
193 | {
194 | Camera.Parameters parameters = camera.getParameters();
195 | parameters.setPreviewSize(640, 480);
196 | parameters.setPictureSize(640, 480);
197 | if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
198 | camera.setDisplayOrientation(90);
199 |
200 | }
201 |
202 | // parameters.setRotation(90);
203 | camera.setParameters(parameters);
204 |
205 | camera.setPreviewDisplay(cameraSurfaceHolder);
206 | camera.startPreview();
207 | previewing = true;
208 | }
209 | catch (IOException e)
210 | {
211 | // TODO Auto-generated catch block
212 | e.printStackTrace();
213 | }
214 | }
215 |
216 | @Override
217 | public void surfaceCreated(SurfaceHolder holder)
218 | {
219 | // TODO Auto-generated method stub
220 | try
221 | {
222 | camera = Camera.open();
223 | }
224 | catch(RuntimeException e)
225 | {
226 | Toast.makeText(getApplicationContext(), "Device camera is not working properly, please try after sometime.", Toast.LENGTH_LONG).show();
227 | }
228 | }
229 |
230 | @Override
231 | public void surfaceDestroyed(SurfaceHolder holder)
232 | {
233 | // TODO Auto-generated method stub
234 | camera.stopPreview();
235 | camera.release();
236 | camera = null;
237 | previewing = false;
238 | }
239 | }
240 |
--------------------------------------------------------------------------------