double minhh = pa.maxheadtop;
double maxhh = pa.minheadbottom;
double maxheadsize = maxhh - minhh;
int hwidth = bioPoints.get(16).x - bioPoints.get(0).x;
hwidth = hwidth + (int)(hwidth * 0.2);
int hheight = hwidth + (int)(hwidth * 0.35);
int finalheight = (int)(hheight * 100) / (int)(maxheadsize * 100);
int finalwidth = (int)(finalheight * ratio);
//maxhh -= 0.02;
double chin = bioPoints.get(8).y - (bioPoints.get(27).y - (finalheight * 0.5));
double cper = chin / finalheight;
int yoffset = (int)((maxhh - cper) * finalheight);
int cx = bioPoints.get(27).x - (int)(finalwidth * 0.5);
int cy = bioPoints.get(27).y - (int)(finalheight * 0.5);
cy -= yoffset;
if (cx >= 0 && cy >= 0 && cy + finalheight < bmp.getHeight() && cx + finalwidth < bmp.getWidth()) {
GlobalData.failedcrop = false;
bmp = Bitmap.createBitmap(bmp, cx, cy, finalwidth, finalheight);
Logger.log("PhotoEdit Crop to: Width " + finalwidth + " Height " + finalheight + "");
Logger.log("Screen Box Width " + dpWidthInPx + " Height " + dpHeightInPx + "");
} else {
TextView t = (TextView) findViewById(R.id.bioautocrop);
t.setText(R.string.failed);
t.setTextColor(getResources().getColor(R.color.black));
okpreview.setBackgroundColor(getResources().getColor(R.color.red));
GlobalData.failedcrop = true;
acceptphoto.setVisibility(GONE);
copytousb.setVisibility(GONE);
}
// end crop for photo
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(dpWidthInPx, dpHeightInPx);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
preview.setLayoutParams(layoutParams);
preview.setScaleType(ImageView.ScaleType.CENTER_CROP);
overlay.setImageBitmap(createOverlay(height));
PhotoUtils photoUtils = new PhotoUtils();
bmp = photoUtils.progressiveDownSample(bmp, dpWidthInPx, dpHeightInPx);
preview.setImageBitmap(bmp);
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.