कर सकते हैं (साथ-साइड) एंड्रॉयड में एक बिटमैपदो बिटमैप छवि (कंधे से कंधा मिलाकर) का मेल
में दो बिटमैप छवियों गठबंधन करने के लिए किसी भी एक मदद करते हैं।
धन्यवाद, Yuvaraj
कर सकते हैं (साथ-साइड) एंड्रॉयड में एक बिटमैपदो बिटमैप छवि (कंधे से कंधा मिलाकर) का मेल
में दो बिटमैप छवियों गठबंधन करने के लिए किसी भी एक मदद करते हैं।
धन्यवाद, Yuvaraj
आप उपयोग कर सकते हैं Canvas
- इस लेख पढ़ें:
public Bitmap combineImages(Bitmap c, Bitmap s) { // can add a 3rd parameter 'String loc' if you want to save the new image - left some code to do that at the bottom
Bitmap cs = null;
int width, height = 0;
if(c.getWidth() > s.getWidth()) {
width = c.getWidth() + s.getWidth();
height = c.getHeight();
} else {
width = s.getWidth() + s.getWidth();
height = c.getHeight();
}
cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs);
comboImage.drawBitmap(c, 0f, 0f, null);
comboImage.drawBitmap(s, c.getWidth(), 0f, null);
// this is an extra bit I added, just incase you want to save the new image somewhere and then return the location
/*String tmpImg = String.valueOf(System.currentTimeMillis()) + ".png";
OutputStream os = null;
try {
os = new FileOutputStream(loc + tmpImg);
cs.compress(CompressFormat.PNG, 100, os);
} catch(IOException e) {
Log.e("combineImages", "problem combining images", e);
}*/
return cs;
}
बहुत बढ़िया काम:
http://www.jondev.net/articles/Combining_2_Images_in_Android_using_Canvas
अपडेट किया गया कोड की ओर से यह पक्ष ऐसा करने के लिए चयनित उत्तर यदि आप इसे बिटमैप्स की सरणी सूची के साथ करना चाहते हैं और साइड साइड नीचे देखें:
private Bitmap combineImageIntoOneFlexWidth(ArrayList<Bitmap> bitmap) {
int w = 0, h = 0;
for (int i = 0; i < bitmap.size(); i++) {
if (i < bitmap.size() - 1) {
h = bitmap.get(i).getHeight() > bitmap.get(i + 1).getHeight() ? bitmap.get(i).getHeight() : bitmap.get(i + 1).getHeight();
}
w += bitmap.get(i).getWidth();
}
Bitmap temp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(temp);
int top = 0;
for (int i = 0; i < bitmap.size(); i++) {
Log.e("HTML", "Combine: " + i + "/" + bitmap.size() + 1);
top = (i == 0 ? 0 : top + bitmap.get(i).getWidth());
//attributes 1:bitmap,2:width that starts drawing,3:height that starts drawing
canvas.drawBitmap(bitmap.get(i), top, 0f, null);
}
return temp;
}
धन्यवाद xil3। मैंने उस पर कोशिश की लेकिन यह दो छवियों को एक दूसरे के नीचे जोड़ देगा। लेकिन मुझे 0 छवियों के पक्ष में दो छवियों को विलय करने की आवश्यकता है – Yuvaraj
मैंने कोड के साथ उत्तर अपडेट किया है, जो कि एक तरफ काम करना चाहिए। मूल से बस कुछ मामूली संशोधन। – xil3
बहुत बहुत धन्यवाद ... यह वह समाधान है जिसे मैं ढूंढ रहा हूं ... – Yuvaraj