Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I wrote some thing simple for you. It is a view with canvas buffer, that have combine method. It draw images on buffer and display them. Your application need to have two views, <code>CombineImages</code> and the view your user is currently moving. Once he set it's position you call the CombineImages.combine to add that image to your view and than you can delete that image, you are ready now to add another image.</p> <p>Currently I place all the images to top left, you should edit my code a bit to make this work with costume positions. </p> <p>Also note that it is safe to call <code>CombineImages.combine</code> not from UI-Thread</p> <pre><code> public class CombineImages extends View{ private Bitmap buffer; private Canvas canvas; private Matrix matrix = new Matrix(); public CombineImages(Context context, AttributeSet attrs) { super(context, attrs); } public CombineImages(Context context) { super(context); } public void combine(ImageView imageView){ Bitmap bitmap = ((BitmapDrawable)imageView.getDrawable()).getBitmap(); combine(bitmap); } public void combine(Bitmap bitmap) { updateBuffer(bitmap); draw(canvas); postInvalidate(); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawBitmap(buffer, matrix , null); } private void updateBuffer(Bitmap bitmap) { if(buffer == null){ createBuffer(bitmap); } else{ if(bitmap.getWidth() &gt; buffer.getWidth() || bitmap.getHeight() &gt; buffer.getHeight()){ Bitmap oldBuffer = buffer; createBuffer(bitmap); drawBitmnapToBuffer(oldBuffer); oldBuffer.recycle(); } drawBitmnapToBuffer(bitmap); } getLayoutParams().height = buffer.getHeight(); getLayoutParams().width = buffer.getWidth(); } private void drawBitmnapToBuffer(Bitmap bitmap) { canvas.save(); // add your translation logic here using canvas.translate(dx, dy); canvas.drawBitmap(bitmap, matrix, null); canvas.restore(); } private void createBuffer(Bitmap bitmap) { buffer = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); canvas = new Canvas(buffer); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload