Take Photo From Camera Without Losing The Quality Of The Image | Android Tutorial

Take Photo From Camera Without Losing The Quality Of The Image | Android Tutorial

heyletscode

5 лет назад

16,120 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@hieuvan347
@hieuvan347 - 25.03.2020 12:01

Thanks you somuch ❤️

Ответить
@AakashSharma-ug5pt
@AakashSharma-ug5pt - 27.04.2020 22:16

Bhai thanks yar! Hafte se error par atka hua tha! Tune theek karva dia yar! Thnx bro! Jai Shree Ram

Ответить
@FaxeelAhmed
@FaxeelAhmed - 02.06.2020 20:57

Best tutorial ❤️❤️❤️.... Can we check the quality of an image? I mean i want to store only high quality image otherwise show your image quality is bad please take another photo

Ответить
@alantony622
@alantony622 - 26.06.2020 12:06

Can u pls provide the source code..

Ответить
@hongnhungtuong8917
@hongnhungtuong8917 - 29.06.2020 21:34

My phone does not have sd card, can i do the same when save to cache? Thanks

Ответить
@shuaibalam7085
@shuaibalam7085 - 01.07.2020 14:31

Thanks a lot
Keep it up bro👍

Ответить
@jithusunny6735
@jithusunny6735 - 26.08.2020 10:28

After taking picture, onActivityResult is not calling, so the image is not displaying in image view in phone. But this works well when connected to emulator..

Ответить
@mohammadqabbani4553
@mohammadqabbani4553 - 09.09.2020 01:10

The Image Not saved on Gallery How i can saved it

Ответить
@jannaikodeyashwanthkumar8121
@jannaikodeyashwanthkumar8121 - 19.09.2020 13:59

Image is not seen in imageview after taking pic. Working on emulator but not on phone Moreover your manifest has no permissions? Help me with it how to get image on screen . Everything is same as in ur code

Ответить
@adityabansal1168
@adityabansal1168 - 20.09.2020 20:04

Did a great job! Thank you.

Ответить
@arvindjha4578
@arvindjha4578 - 16.10.2020 20:23

Bhai teri height kitni h

Ответить
@ujjwaldeep5175
@ujjwaldeep5175 - 29.10.2020 11:31

White hat Jr. Ads😂

Ответить
@nikhilnandhagopan5576
@nikhilnandhagopan5576 - 12.12.2020 11:16

how could you do that without giving camera permission

Ответить
@soumojyotiganguly8618
@soumojyotiganguly8618 - 03.01.2021 12:56

very helpfull.

Ответить
@nightmarexcvm
@nightmarexcvm - 07.01.2021 10:59

thanx very useful content

Ответить
@olhaonaipe
@olhaonaipe - 11.01.2021 02:04

Great tutorial man, thanks!

Ответить
@jessebett7552
@jessebett7552 - 23.01.2021 16:43

Awesome tutorial,thanks alot

Ответить
@jerryyap1516
@jerryyap1516 - 25.01.2021 21:20

what program you use to do all this and how to install to phone

Ответить
@officework1518
@officework1518 - 29.01.2021 10:20

Where the hell is declaration of "fileprovider" class?
How Android will know that "fileprovider" exists in the project?

Ответить
@venkatesh4307
@venkatesh4307 - 01.02.2021 06:05

Thanks. I've got another idea by this video

Ответить
@leventestancz4522
@leventestancz4522 - 05.03.2021 21:42

I have a problem, at the " intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); " it says: " Cannot resolve method 'putExtra(java.lang.String, Uri)' " why is that?

Ответить
@KY_7410
@KY_7410 - 18.03.2021 14:35

Thank you so much Sir!

Ответить
@KY_7410
@KY_7410 - 21.03.2021 18:03

Sir, why in the android studio emulator can open the camera but when I use my phone to open the app suddenly close...

Ответить
@woonie3134
@woonie3134 - 18.04.2021 05:18

how to save image my friend? I want close app and image is saved on phone

Ответить
@losespecialespodcast7319
@losespecialespodcast7319 - 16.05.2021 08:46

exelent

Ответить
@nicolewis8811
@nicolewis8811 - 13.07.2021 17:09

Thanks sir !

Ответить
@oussamaobs
@oussamaobs - 19.07.2021 14:03

thanks bro, helpful tutorial

Ответить
@林同學-u3x
@林同學-u3x - 22.07.2021 18:18

could you show the full code on the net?plz

Ответить
@abhishekjangam7924
@abhishekjangam7924 - 10.11.2021 13:24

thnxxx bro

Ответить
@abhishekjangam7924
@abhishekjangam7924 - 10.11.2021 17:12

how to save image after that

Ответить
@ashrafakib3750
@ashrafakib3750 - 01.01.2022 14:35

I don't know how to thank you, You've saved my job. God bless you.. never stop
making video and help people like me

Ответить
@user-qi7th4vc5s
@user-qi7th4vc5s - 24.01.2022 16:49

Great explanation.

Ответить
@yashagarwal2483
@yashagarwal2483 - 18.02.2022 07:35

I love you man! Saved my ass

Ответить
@kennyblaze6303
@kennyblaze6303 - 09.07.2022 19:26

hi, am quite new into this field of android application programming... so i am wondering if the image captured with the mobile camera is now stored into the computer specified file location? and can i access those images with openCV applications?

Ответить
@codersohum8257
@codersohum8257 - 10.08.2022 19:24

package com.whitegoldapps.imageposter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class MainActivity extends AppCompatActivity {
Button btnChoose;
ImageView imgView;
String currentPhotoPath;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnChoose=findViewById(R.id.btnChoose);
imgView=findViewById(R.id.imgView);
btnChoose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String filename="photo";
File storageDir=getExternalFilesDir(Environment.DIRECTORY_PICTURES);
try {
File ImageFile=File.createTempFile(filename,".jpg",storageDir);
currentPhotoPath=ImageFile.getAbsolutePath();
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri imgUri= FileProvider.getUriForFile(MainActivity.this,"com.whitegoldapps.imageposter.fileprovider",ImageFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT,imgUri);
startActivityForResult(intent,1);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if(requestCode==1&&resultCode==RESULT_OK){
Bitmap bitmap= BitmapFactory.decodeFile(currentPhotoPath);
imgView.setImageBitmap(bitmap);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bao); // bmp is bitmap from user image file

byte[] byteArray = bao.toByteArray();
StorageReference storageReference = FirebaseStorage.getInstance().getReference().child("document55Images").child(UUID.randomUUID().toString());
//StorageReference filePath = FirebaseStorage.getInstance().getReference().child("profile_images").child(userID);
storageReference.putBytes(byteArray).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
storageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
final Uri downloadUrl = uri;
Toast.makeText(MainActivity.this, "uploaded "+uri, Toast.LENGTH_SHORT).show();
}
});
// Uri downloadUrl = taskSnapshot.getDownloadUrl();
// Toast.makeText(MainActivity.this, "uploaded", Toast.LENGTH_SHORT).show();

}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this,"failed",Toast.LENGTH_LONG).show();


}
});

}




}
}
This The code I have integrated it with firebase firestore database

Ответить
@codersohum8257
@codersohum8257 - 10.08.2022 19:25

This is The code
package com.whitegoldapps.imageposter;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.FileProvider;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class MainActivity extends AppCompatActivity {
Button btnChoose;
ImageView imgView;
String currentPhotoPath;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnChoose=findViewById(R.id.btnChoose);
imgView=findViewById(R.id.imgView);
btnChoose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String filename="photo";
File storageDir=getExternalFilesDir(Environment.DIRECTORY_PICTURES);
try {
File ImageFile=File.createTempFile(filename,".jpg",storageDir);
currentPhotoPath=ImageFile.getAbsolutePath();
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri imgUri= FileProvider.getUriForFile(MainActivity.this,"com.whitegoldapps.imageposter.fileprovider",ImageFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT,imgUri);
startActivityForResult(intent,1);
} catch (IOException e) {
e.printStackTrace();
}
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if(requestCode==1&&resultCode==RESULT_OK){
Bitmap bitmap= BitmapFactory.decodeFile(currentPhotoPath);
imgView.setImageBitmap(bitmap);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bao); // bmp is bitmap from user image file

byte[] byteArray = bao.toByteArray();
StorageReference storageReference = FirebaseStorage.getInstance().getReference().child("document55Images").child(UUID.randomUUID().toString());
//StorageReference filePath = FirebaseStorage.getInstance().getReference().child("profile_images").child(userID);
storageReference.putBytes(byteArray).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
storageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
final Uri downloadUrl = uri;
Toast.makeText(MainActivity.this, "uploaded "+uri, Toast.LENGTH_SHORT).show();
}
});
// Uri downloadUrl = taskSnapshot.getDownloadUrl();
// Toast.makeText(MainActivity.this, "uploaded", Toast.LENGTH_SHORT).show();

}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this,"failed",Toast.LENGTH_LONG).show();


}
});

}




}
}

Ответить
@akshayhadiya7094
@akshayhadiya7094 - 13.10.2022 09:35

Hello sir,
I have an doubt!
Question:-how can i check captured image quality ?

Ответить
@chiranjeevshubham690
@chiranjeevshubham690 - 26.01.2023 10:03

Please, make a video on " How to make share images from imageview" app in Android Studio 🙏🙏🙏

Ответить
@toniuswar6148
@toniuswar6148 - 25.02.2023 22:25

Thank You, comrade!

Ответить
@dangr302
@dangr302 - 10.03.2023 00:15

Thank you very, very much

Ответить
@DaxyCZ
@DaxyCZ - 10.04.2023 11:54

Thank you! Very helpful!

Ответить
@mfaizhussain7
@mfaizhussain7 - 12.09.2023 07:33

Bro You didn't Give Permissions In Manifest

Ответить
@shatanikmahanty
@shatanikmahanty - 23.10.2023 19:30

This saved me today ❤❤

Ответить
@saurabhgoel8191
@saurabhgoel8191 - 13.11.2023 19:20

Absolutely terrific tutorial man. Thanks!!

Ответить
@BencENagy-qh8lv
@BencENagy-qh8lv - 07.01.2024 19:33

The code is awesome, thank you! But have a question:
Anyone of you guys met a problem like me below;?
When I create a picture it always has a 90° rotation.

Anyone know why?

Ответить
@ChandanKumar-vp1jw
@ChandanKumar-vp1jw - 07.05.2024 08:59

Thank you so much this method helps me

Ответить
@obrymec
@obrymec - 29.05.2024 18:11

Good tutorial

Ответить
@DavidMuchima
@DavidMuchima - 21.09.2024 07:34

You saved my life

Ответить