mImageFlip = (ImageFlip) findViewById(R.id.imageFlip);
mImageTinyPlanet = (ImageTinyPlanet) findViewById(R.id.imageTinyPlanet);
+ mImageCrop.setAspectTextSize((int) getPixelsFromDip(18));
ImageCrop.setTouchTolerance((int) getPixelsFromDip(25));
mImageViews.add(mImageShow);
mImageViews.add(mImageCurves);
ImageCrop imageCrop = (ImageCrop) mCurrentImage;
switch (itemId) {
case R.id.crop_menu_1to1: {
- button.setText(mContext.getString(R.string.aspect1to1_effect));
+ String t = mContext.getString(R.string.aspect1to1_effect);
+ button.setText(t);
imageCrop.apply(1, 1);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_4to3: {
- button.setText(mContext.getString(R.string.aspect4to3_effect));
+ String t = mContext.getString(R.string.aspect4to3_effect);
+ button.setText(t);
imageCrop.apply(4, 3);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_3to4: {
- button.setText(mContext.getString(R.string.aspect3to4_effect));
+ String t = mContext.getString(R.string.aspect3to4_effect);
+ button.setText(t);
imageCrop.apply(3, 4);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_5to7: {
- button.setText(mContext.getString(R.string.aspect5to7_effect));
+ String t = mContext.getString(R.string.aspect5to7_effect);
+ button.setText(t);
imageCrop.apply(5, 7);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_7to5: {
- button.setText(mContext.getString(R.string.aspect7to5_effect));
+ String t = mContext.getString(R.string.aspect7to5_effect);
+ button.setText(t);
imageCrop.apply(7, 5);
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_none: {
- button.setText(mContext.getString(R.string.aspectNone_effect));
+ String t = mContext.getString(R.string.aspectNone_effect);
+ button.setText(t);
imageCrop.applyClear();
+ imageCrop.setAspectString(t);
break;
}
case R.id.crop_menu_original: {
- button.setText(mContext.getString(R.string.aspectOriginal_effect));
+ String t = mContext.getString(R.string.aspectOriginal_effect);
+ button.setText(t);
imageCrop.applyOriginal();
+ imageCrop.setAspectString(t);
break;
}
}
private static final String LOGTAG = "ImageCrop";
+ private String mAspect = "";
+ private int mAspectTextSize = 24;
+
+ public void setAspectTextSize(int textSize){
+ mAspectTextSize = textSize;
+ }
+
+ public void setAspectString(String a){
+ mAspect = a;
+ }
+
private static final Paint gPaint = new Paint();
public ImageCrop(Context context) {
gPaint.setStyle(Paint.Style.STROKE);
drawRuleOfThird(canvas, crop, gPaint);
+ if (mFixAspectRatio){
+ float w = crop.width();
+ float h = crop.height();
+ float diag = (float) Math.sqrt(w*w + h*h);
+
+ float dash_len = 20;
+ int num_intervals = (int) (diag / dash_len);
+ float [] tl = { crop.left, crop.top };
+ float centX = tl[0] + w/2;
+ float centY = tl[1] + h/2 + 5;
+ float [] br = { crop.right, crop.bottom };
+ float [] vec = GeometryMath.getUnitVectorFromPoints(tl, br);
+
+ float [] counter = tl;
+ for (int x = 0; x < num_intervals; x++ ){
+ float tempX = counter[0] + vec[0] * dash_len;
+ float tempY = counter[1] + vec[1] * dash_len;
+ if ((x % 2) == 0 && Math.abs(x - num_intervals / 2) > 2){
+ canvas.drawLine(counter[0], counter[1], tempX, tempY, gPaint);
+ }
+ counter[0] = tempX;
+ counter[1] = tempY;
+ }
+
+ gPaint.setTextAlign(Paint.Align.CENTER);
+ gPaint.setTextSize(mAspectTextSize);
+ canvas.drawText(mAspect, centX, centY, gPaint);
+ }
+
gPaint.setColor(mBorderColor);
gPaint.setStrokeWidth(3);
gPaint.setStyle(Paint.Style.STROKE);