मैं एक एप्लिकेशन बना रहा हूं और गैलरी व्यू सेट अप करना चाहता हूं। मैं नहीं चाहता कि गैलरी दृश्य में छवियां पूर्ण आकार हों। मैं एंड्रॉइड में छवियों का आकार कैसे बदलूं?एंड्रॉइड में छवि का आकार कैसे बदलें?
72
A
उत्तर
146
प्रयास करें:
Bitmap yourBitmap;
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, newWidth, newHeight, true);
या:
resized = Bitmap.createScaledBitmap(yourBitmap,(int)(yourBitmap.getWidth()*0.8), (int)(yourBitmap.getHeight()*0.8), true);
+8
यह कम स्केलिंग पर छवि धुंधला दिखाता है ... –
4
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize=2; //try to decrease decoded image
Bitmap bitmap=BitmapFactory.decodeStream(is, null, options);
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, fos); //compressed bitmap to file
6
आप अपने कैमरे छवि का आकार बदलने मैट्रिक्स का उपयोग कर सकते हैं ....
BitmapFactory.Options options=new BitmapFactory.Options();
InputStream is = getContentResolver().openInputStream(currImageURI);
bm = BitmapFactory.decodeStream(is,null,options);
int Height = bm.getHeight();
int Width = bm.getWidth();
int newHeight = 300;
int newWidth = 300;
float scaleWidth = ((float) newWidth)/Width;
float scaleHeight = ((float) newHeight)/Height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0,Width, Height, matrix, true);
BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
6
छवि कैद और आकार बदलने यह।
Bitmap image2 = (Bitmap) data.getExtras().get("data");
img.setImageBitmap(image2);
String incident_ID = IncidentFormActivity.incident_id;
imagepath="/sdcard/RDMS/"+incident_ID+ x + ".PNG";
File file = new File(imagepath);
try {
double xFactor = 0;
double width = Double.valueOf(image2.getWidth());
Log.v("WIDTH", String.valueOf(width));
double height = Double.valueOf(image2.getHeight());
Log.v("height", String.valueOf(height));
if(width>height){
xFactor = 841/width;
}
else{
xFactor = 595/width;
}
Log.v("Nheight", String.valueOf(width*xFactor));
Log.v("Nweight", String.valueOf(height*xFactor));
int Nheight = (int) ((xFactor*height));
int NWidth =(int) (xFactor * width) ;
bm = Bitmap.createScaledBitmap(image2,NWidth, Nheight, true);
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
bm.compress(CompressFormat.PNG, 100, ostream);
ostream.close();
4
bm = Bitmap.createScaledBitmap(bitmapSource, width, height, true);
:)
28
public Bitmap resizeBitmap(String photoPath, int targetW, int targetH) {
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inJustDecodeBounds = true;
BitmapFactory.decodeFile(photoPath, bmOptions);
int photoW = bmOptions.outWidth;
int photoH = bmOptions.outHeight;
int scaleFactor = 1;
if ((targetW > 0) || (targetH > 0)) {
scaleFactor = Math.min(photoW/targetW, photoH/targetH);
}
bmOptions.inJustDecodeBounds = false;
bmOptions.inSampleSize = scaleFactor;
bmOptions.inPurgeable = true; //Deprecated API 21
return BitmapFactory.decodeFile(photoPath, bmOptions);
}
5
// तस्वीर बिटमैप छवि
Bitmap btm00 = Utils.getResizedBitmap(photo, 200, 200);
setimage.setImageBitmap(btm00);
And in Utils class :
public static Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
int width = bm.getWidth();
int height = bm.getHeight();
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
Matrix matrix = new Matrix();
// RESIZE THE BIT MAP
matrix.postScale(scaleWidth, scaleHeight);
// RECREATE THE NEW BITMAP
Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height,
matrix, false);
return resizedBitmap;
}
2
resized = Bitmap.createScaledBitmap(yourImageBitmap,(int)(yourImageBitmap.getWidth()*0.9), (int)(yourBitmap.getHeight()*0.9), true);
0
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 10;
FixBitmap = BitmapFactory.decodeFile(ImagePath, options);
//FixBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.gv);
byteArrayOutputStream = new ByteArrayOutputStream();
FixBitmap.compress(Bitmap.CompressFormat.JPEG, 80, byteArrayOutputStream); //compress to 50% of original image quality
byteArray = byteArrayOutputStream.toByteArray();
ConvertImage = Base64.encodeToString(byteArray, Base64.DEFAULT);
संबंधित मुद्दे
- 1. बिटमैप छवि का आकार बदलें
- 2. छवि का आकार बदलें (जावा)
- 3. सीकेफ़िंडर छवि का आकार बदलें
- 4. छवि बटन का आकार बदलें?
- 5. एंड्रॉइड-सेकरबार का आकार बदलें?
- 6. निर्दिष्ट आकार में जेपीईजी छवि का आकार बदलें
- 7. जावा में छवि के एक सामान्य आकार में मूल छवि का आकार कैसे बदलें?
- 8. एंड्रॉइड कैमरा छवि का आकार
- 9. एंड्रॉइड वेबव्यू में फ़ॉन्ट आकार कैसे बदलें?
- 10. बदलें आकार: एंड्रॉइड रेडियो बटन
- 11. एंड्रॉइड में बिटमैप छवि रंग कैसे बदलें?
- 12. एंड्रॉइड में मेमोरी कुशल छवि का आकार
- 13. nivo स्लाइडर छवि आकार बदलें
- 14. एंड्रॉइड में टैबहोस्ट का फ़ॉन्ट आकार कैसे बदलें
- 15. एंड्रॉइड डेटपिकर नियंत्रण का आकार बदलें
- 16. एंड्रॉइड बिटमैप छवि आकार
- 17. विंडो आकार बदलने पर छवि मानचित्र का आकार बदलें
- 18. एंड्रॉइड में गैलरी से चुनी गई छवि का आकार कैसे बदलें?
- 19. pyCairo: छवि का आकार बदलने और स्थिति कैसे बदलें?
- 20. एक निपुणता छवि विजेट का आकार कैसे बदलें?
- 21. कोको, उद्देश्य-सी एक पीएनजी छवि का आकार कैसे बदलें?
- 22. बटन छवि आकार एंड्रॉइड
- 23. सी # छवि का आकार बदलने का आकार फ़ाइल आकार
- 24. एक्सआईबी में दृश्य का आकार कैसे बदलें?
- 25. छवि अपलोड करने से पहले आकार बदलें
- 26. वीडियो दृश्य का आकार बदलें
- 27. एमवीसी 3/रेजर थंबनेल/छवि विचारों का आकार बदलें?
- 28. पैरामीटर के रूप में प्रतिशत का उपयोग कर HTML में छवि का आकार कैसे बदलें?
- 29. सामग्री के साथ सम्मिलित एसवीजी छवि का आकार बदलें: यूआरएल()
- 30. एंड्रॉइड विजेट: पूर्वावलोकन छवि आकार
आप आकार को कम करना चाहते है अगर छवि या बस छोटे दिखाना चाहते हैं? – MAC