├── bin ├── classes.dex ├── freePinTu.apk ├── resources.ap_ ├── classes │ └── com │ │ └── test │ │ ├── R.class │ │ ├── R$attr.class │ │ ├── R$layout.class │ │ ├── R$string.class │ │ ├── R$drawable.class │ │ ├── FreePinTuActivity.class │ │ ├── FreePinTuActivity$Bmp.class │ │ └── FreePinTuActivity$Draw.class └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-ldpi │ └── ic_launcher.png │ └── drawable-mdpi │ └── ic_launcher.png ├── res ├── drawable-hdpi │ ├── you.jpg │ └── ic_launcher.png ├── drawable-ldpi │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── values │ └── strings.xml └── layout │ └── main.xml ├── .settings └── org.eclipse.jdt.core.prefs ├── .classpath ├── project.properties ├── AndroidManifest.xml ├── gen └── com │ └── test │ └── R.java ├── .project ├── proguard.cfg └── src └── com └── test └── FreePinTuActivity.java /bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/classes.dex -------------------------------------------------------------------------------- /bin/freePinTu.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/freePinTu.apk -------------------------------------------------------------------------------- /bin/resources.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/resources.ap_ -------------------------------------------------------------------------------- /res/drawable-hdpi/you.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/res/drawable-hdpi/you.jpg -------------------------------------------------------------------------------- /bin/classes/com/test/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/classes/com/test/R.class -------------------------------------------------------------------------------- /bin/classes/com/test/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/classes/com/test/R$attr.class -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/classes/com/test/R$layout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/classes/com/test/R$layout.class -------------------------------------------------------------------------------- /bin/classes/com/test/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/classes/com/test/R$string.class -------------------------------------------------------------------------------- /bin/classes/com/test/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/classes/com/test/R$drawable.class -------------------------------------------------------------------------------- /bin/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /bin/classes/com/test/FreePinTuActivity.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/classes/com/test/FreePinTuActivity.class -------------------------------------------------------------------------------- /bin/classes/com/test/FreePinTuActivity$Bmp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/classes/com/test/FreePinTuActivity$Bmp.class -------------------------------------------------------------------------------- /bin/classes/com/test/FreePinTuActivity$Draw.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atupal/android_-imgage_mosaicking-/HEAD/bin/classes/com/test/FreePinTuActivity$Draw.class -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello World, FreePinTuActivity! 5 | FreePinTu 6 | 7 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Wed Mar 14 20:10:23 CST 2012 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 4 | org.eclipse.jdt.core.compiler.compliance=1.5 5 | org.eclipse.jdt.core.compiler.source=1.5 6 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /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 use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-10 12 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /gen/com/test/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.test; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class drawable { 14 | public static final int ic_launcher=0x7f020000; 15 | public static final int you=0x7f020001; 16 | } 17 | public static final class layout { 18 | public static final int main=0x7f030000; 19 | } 20 | public static final class string { 21 | public static final int app_name=0x7f040001; 22 | public static final int hello=0x7f040000; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | freePinTu 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /proguard.cfg: -------------------------------------------------------------------------------- 1 | -optimizationpasses 5 2 | -dontusemixedcaseclassnames 3 | -dontskipnonpubliclibraryclasses 4 | -dontpreverify 5 | -verbose 6 | -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* 7 | 8 | -keep public class * extends android.app.Activity 9 | -keep public class * extends android.app.Application 10 | -keep public class * extends android.app.Service 11 | -keep public class * extends android.content.BroadcastReceiver 12 | -keep public class * extends android.content.ContentProvider 13 | -keep public class * extends android.app.backup.BackupAgentHelper 14 | -keep public class * extends android.preference.Preference 15 | -keep public class com.android.vending.licensing.ILicensingService 16 | 17 | -keepclasseswithmembernames class * { 18 | native ; 19 | } 20 | 21 | -keepclasseswithmembers class * { 22 | public (android.content.Context, android.util.AttributeSet); 23 | } 24 | 25 | -keepclasseswithmembers class * { 26 | public (android.content.Context, android.util.AttributeSet, int); 27 | } 28 | 29 | -keepclassmembers class * extends android.app.Activity { 30 | public void *(android.view.View); 31 | } 32 | 33 | -keepclassmembers enum * { 34 | public static **[] values(); 35 | public static ** valueOf(java.lang.String); 36 | } 37 | 38 | -keep class * implements android.os.Parcelable { 39 | public static final android.os.Parcelable$Creator *; 40 | } 41 | -------------------------------------------------------------------------------- /src/com/test/FreePinTuActivity.java: -------------------------------------------------------------------------------- 1 | package com.test; 2 | 3 | import android.R.integer; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.graphics.Matrix; 9 | import android.graphics.Bitmap.Config; 10 | import android.graphics.Canvas; 11 | import android.os.Bundle; 12 | import android.util.Log; 13 | import android.view.MotionEvent; 14 | import android.view.View; 15 | 16 | public class FreePinTuActivity extends Activity 17 | { 18 | /** Called when the activity is first created. */ 19 | @Override 20 | public void onCreate(Bundle savedInstanceState) 21 | { 22 | super.onCreate(savedInstanceState); 23 | setContentView(new Draw(this)); 24 | } 25 | 26 | class Draw extends View 27 | { 28 | 29 | Bmp bmp[]; 30 | public Draw(Context context) 31 | { 32 | 33 | super(context); 34 | bmp = new Bmp[4]; 35 | { 36 | 37 | for(int i = 0; i < 4; i++) 38 | { 39 | bmp[i] = new Bmp(Bitmap.createScaledBitmap(BitmapFactory.decodeStream(getResources().openRawResource(R.drawable.you)), 240, 240, false), i, i * 50f, i * 60f); 40 | bmp[i].width = bmp[i].getPic().getWidth(); 41 | bmp[i].height = bmp[i].getPic().getWidth(); 42 | } 43 | } 44 | this.pic = bmp; 45 | 46 | this.canvas.drawColor(-232432445); 47 | for(int i = 0; i < 4; i++) 48 | { 49 | tempBitmap = pic[0].findByPiority(pic, i); 50 | tempBitmap.matrix.preTranslate(tempBitmap.getXY(1) - tempBitmap.getWidth() / 2, tempBitmap.getXY(2) - tempBitmap.getHeight() / 2); 51 | this.canvas.drawBitmap(tempBitmap.pic, tempBitmap.matrix, null); 52 | } 53 | } 54 | 55 | public Draw(Context context, Bmp[] pic) 56 | { 57 | this(context); 58 | this.pic = pic; 59 | } 60 | 61 | @Override 62 | public void onDraw(Canvas canvas) 63 | { 64 | super.onDraw(canvas); 65 | canvas.drawBitmap(canvasBitmap, 0, 0, null); 66 | } 67 | 68 | @Override 69 | public boolean onTouchEvent(MotionEvent event) 70 | { 71 | 72 | if(event.getAction() == MotionEvent.ACTION_DOWN) 73 | { 74 | order(event); 75 | this.X = event.getX(); 76 | this.Y = event.getY(); 77 | CX = pic[3].findByPiority(pic, 3).getXY(1) - event.getX(); 78 | CY = pic[3].findByPiority(pic, 3).getXY(2) - event.getY(); 79 | Begin = true; 80 | } 81 | 82 | if(event.getAction() == MotionEvent.ACTION_MOVE && Begin && event.getPointerCount() == 1) 83 | { 84 | this.X = event.getX(); 85 | this.Y = event.getY(); 86 | this.canvas.drawColor(-232432445); 87 | for(int i = 0; i < 3; i++) 88 | { 89 | tempBitmap = pic[0].findByPiority(pic, i); 90 | tempBitmap.matrix.preTranslate(0f, 0f); 91 | canvas.drawBitmap(tempBitmap.getPic(), tempBitmap.matrix, null); 92 | } 93 | tempBitmap = pic[0].findByPiority(pic, 3); 94 | rotalP = rotalPoint(new float[]{this.X, this.Y}, tempBitmap.preX, tempBitmap.preY, tempBitmap.width / 2, tempBitmap.height / 2, tempBitmap.matrix); 95 | if( 96 | // (Math.abs(pic[0].findByPiority(pic, 3).getXY(1) - this.X) < pic[0].findByPiority(pic, 3).getWidth() / 2) 97 | (Math.abs(rotalP[0] - pic[0].findByPiority(pic, 3).getXY(1)) < pic[0].findByPiority(pic, 3).getWidth() / 2) 98 | // && (Math.abs(pic[0].findByPiority(pic, 3).getXY(2) - this.Y) < pic[0].findByPiority(pic, 3).getHeight() / 2) 99 | && (Math.abs(rotalP[1] - pic[0].findByPiority(pic, 3).getXY(2)) < pic[0].findByPiority(pic, 3).getHeight() / 2) 100 | ) 101 | { 102 | //tempBitmap.matrix.preTranslate(X + CX - tempBitmap.preX, Y + CY - tempBitmap.preY); 103 | tempBitmap.matrix.preRotate(30); 104 | rotalC = this.getT(tempBitmap.width / 2, tempBitmap.height / 2 , X + CX, Y + CY, tempBitmap.matrix); 105 | 106 | Log.i("matrix", "the matrix"); 107 | // tempBitmap.matrix.setTranslate(T[0], T[1]); 108 | canvas.drawBitmap(tempBitmap.getPic(), tempBitmap.matrix, null); 109 | tempBitmap.preX = X + CX; 110 | tempBitmap.preY = Y + CY; 111 | } 112 | else 113 | { 114 | tempBitmap.matrix.preTranslate(0f, 0f); 115 | canvas.drawBitmap(tempBitmap.getPic(), tempBitmap.matrix, null); 116 | } 117 | } 118 | 119 | // 多点触控 120 | if (event.getPointerCount() >= 2) 121 | { 122 | X_1 = event.getX(0); 123 | X_2 = event.getX(1); 124 | Y_1 = event.getY(0); 125 | Y_2 = event.getY(1); 126 | Log.i("2 touch ", String.valueOf(event.getPointerCount())); 127 | tan = (Y_2 - Y_1) / (X_2 - X_1); 128 | rotary = (float) Math.atan((double)tan); 129 | tempBitmap.matrix.setRotate(rotary); 130 | 131 | this.canvas.drawColor(-232432445); 132 | for(int i = 0; i < 3; i++) 133 | { 134 | tempBitmap = pic[0].findByPiority(pic, i); 135 | tempBitmap.matrix.preTranslate(0f, 0f); 136 | canvas.drawBitmap(tempBitmap.getPic(), tempBitmap.matrix, null); 137 | } 138 | tempBitmap = pic[0].findByPiority(pic, 3); 139 | if( 140 | (Math.abs(pic[0].findByPiority(pic, 3).getXY(1) - this.X_1) < pic[0].findByPiority(pic, 3).getWidth() / 2) 141 | && (Math.abs(pic[0].findByPiority(pic, 3).getXY(2) - this.Y_1) < pic[0].findByPiority(pic, 3).getHeight() / 2) 142 | &&(Math.abs(pic[0].findByPiority(pic, 3).getXY(1) - this.X_2) < pic[0].findByPiority(pic, 3).getWidth() / 2) 143 | && (Math.abs(pic[0].findByPiority(pic, 3).getXY(2) - this.Y_2) < pic[0].findByPiority(pic, 3).getHeight() / 2) 144 | ) 145 | { 146 | tempBitmap.matrix.preTranslate(X + CX - tempBitmap.preX, Y + CY - tempBitmap.preY); 147 | canvas.drawBitmap(tempBitmap.getPic(), tempBitmap.matrix, null); 148 | 149 | tempBitmap.preX = X + CX; 150 | tempBitmap.preY = Y + CY; 151 | } 152 | else 153 | { 154 | tempBitmap.matrix.preTranslate(0f, 0f); 155 | canvas.drawBitmap(tempBitmap.getPic(), tempBitmap.matrix, null); 156 | } 157 | } 158 | 159 | if(event.getAction() == MotionEvent.ACTION_UP) 160 | { 161 | CX = 0f; 162 | CY = 0f; 163 | Begin = false; 164 | } 165 | 166 | invalidate(); 167 | 168 | return true; 169 | } 170 | 171 | public void order(MotionEvent event) 172 | { 173 | 174 | Bmp temp = null; 175 | for(int i = 3; i > -1; i--) 176 | { 177 | rotalP = rotalPoint(new float[]{event.getX(), event.getY()}, pic[0].findByPiority(pic, i).preX, pic[0].findByPiority(pic, i).preY, pic[0].findByPiority(pic, i).width / 2, pic[0].findByPiority(pic, i).height / 2, pic[0].findByPiority(pic, i).matrix); 178 | if( 179 | (Math.abs(pic[0].findByPiority(pic, i).getXY(1) - rotalP[0]) < pic[0].findByPiority(pic, i).getWidth() / 2) 180 | && (Math.abs(pic[0].findByPiority(pic, i).getXY(2) - rotalP[1]) < pic[0].findByPiority(pic, i).getHeight() / 2) 181 | ) 182 | { 183 | temp = pic[0].findByPiority(pic, i); 184 | for(Bmp bmp: pic) 185 | { 186 | if(bmp.getPriority() > pic[0].findByPiority(pic, i).getPriority()) 187 | { 188 | bmp.priority--; 189 | } 190 | } 191 | temp.setPiority(3); 192 | Begin = true; 193 | return; 194 | } 195 | } 196 | } 197 | 198 | public float[] getT(float preX, float preY, float x, float y, Matrix matrix) 199 | { 200 | float[] re = new float[2]; 201 | float[] matrixArray = new float[9]; 202 | matrix.getValues(matrixArray); 203 | float a = x - preX * matrixArray[0] - preY * matrixArray[1]; 204 | float b = y - preX * matrixArray[3] - preY * matrixArray[4]; 205 | matrixArray[2] = a; 206 | matrixArray[5] = b; 207 | matrix.setValues(matrixArray); 208 | re[0] = a; 209 | re[1] = b; 210 | Log.i("a", String.valueOf(a)); 211 | Log.i("b", String.valueOf(b)); 212 | return re; 213 | } 214 | 215 | public float[] rotalPoint(float[] p, float X, float Y, float width, float height, Matrix matrix) 216 | { 217 | float re[] = new float[2]; 218 | float matrixArray[] = new float[9]; 219 | matrix.getValues(matrixArray); 220 | float a = p[0] - X; 221 | float b = p[1] - Y; 222 | re[0] = a * matrixArray[0] - b * matrixArray[1] + X; 223 | re[1] = - a * matrixArray[3] + b * matrixArray[4] + Y; 224 | return re; 225 | } 226 | private Bitmap canvasBitmap = Bitmap.createBitmap(480, 500, Config.ARGB_8888); 227 | private Bmp tempBitmap = null; 228 | private Canvas canvas = new Canvas(canvasBitmap); 229 | private float X = 0f; 230 | private float Y = 0f; 231 | @SuppressWarnings("unused") 232 | private float DownX = 0f; 233 | @SuppressWarnings("unused") 234 | private float DownY = 0f; 235 | private Bmp[] pic = new Bmp[4]; 236 | private float X_1; 237 | private float X_2; 238 | private float Y_1; 239 | private float Y_2; 240 | private float tan; 241 | private float rotary; 242 | private float CX = 0f; 243 | private float CY = 0f; 244 | private boolean Begin = true; 245 | float rotalC[] = new float[2]; 246 | float rotalP[] = new float[2]; 247 | } 248 | 249 | 250 | 251 | 252 | // @param pic:the Bitmap to draw 253 | // @param piority: the order to draw picture 254 | // @param preX,preY: the X and Y 255 | class Bmp 256 | { 257 | // 构造器 258 | public Bmp(Bitmap pic, int piority) 259 | { 260 | this.pic = pic; 261 | this.priority = piority; 262 | } 263 | 264 | // 构造器 265 | public Bmp(Bitmap pic, int priority, float preX, float preY) 266 | { 267 | this(pic, priority); 268 | this.preX = preX + pic.getWidth() / 2 * 1.5f; 269 | this.preY = preY + pic.getHeight() / 2 * 1.5f; 270 | } 271 | 272 | // findPiority 273 | public Bmp findByPiority(Bmp[] pic, int priority) 274 | { 275 | for(Bmp p : pic) 276 | { 277 | if(p.priority == priority) 278 | { 279 | return p; 280 | } 281 | } 282 | return null; 283 | } 284 | 285 | // set Priority 286 | public void setPiority(int priority) 287 | { 288 | this.priority = priority; 289 | } 290 | 291 | // return Priority 292 | public int getPriority() 293 | { 294 | return this.priority; 295 | } 296 | 297 | // return X and Y 298 | public float getXY(int i) 299 | { 300 | if(i == 1) 301 | { 302 | return this.preX; 303 | } 304 | else if(i == 2) 305 | { 306 | return this.preY; 307 | } 308 | return (Float) null; 309 | } 310 | 311 | // getPicture 312 | public Bitmap getPic() 313 | { 314 | return this.pic; 315 | } 316 | 317 | // getWidth 318 | public float getWidth() 319 | { 320 | return width; 321 | } 322 | 323 | // getHeight 324 | public float getHeight() 325 | { 326 | return height; 327 | } 328 | 329 | float preX = 0; 330 | float preY = 0; 331 | float width = 0; 332 | float height = 0; 333 | Bitmap pic = null; 334 | int priority = 0; 335 | private Matrix matrix = new Matrix(); 336 | } 337 | } --------------------------------------------------------------------------------