۱۳۹۴/۰۴/۲۹, ۰۲:۵۲ ب.ظ
سلام
به کد های زیر توجه کنید: با توجه به این کد ها مشخصه که ما سه دکمه دارمم :
zoom
move
crop
حالا به فرض اینکه دکمه ی چهارمی به نام چرخش 90 درجه هم داشته باشیم کد مخصوص به چرخش چیه میشه و باید اضاف بشه؟
تشکرر
به کد های زیر توجه کنید:
کد پیاچپی:
View touchview=findViewById(R.id.result);
touchview.setOnTouchListener(new OnTouchListener() {
int xstart,xend,ystart,yend,changex,changey;
@Override
public boolean onTouch(View arg0, MotionEvent event) {
if (event.getAction()==MotionEvent.ACTION_DOWN) {
xstart=(int) event.getRawX();
ystart=(int) event.getRawY();
}
if (event.getAction()==MotionEvent.ACTION_UP) {
xend=(int) event.getRawX();
yend=(int) event.getRawY();
changex = xend-xstart;
changey = yend-ystart;
if (imageselected == true)
{
if(textmove)
{
xtext = xtext + changex ;
ytext = ytext + changey ;
}
else if(editimage==1)
{
if(zoom){
bm1Widthzoom = bm1Widthzoom + changex;
bm1Heightzoom = bm1Heightzoom + changey;
bm1changed = Bitmap.createScaledBitmap(bm1, bm1Widthzoom, bm1Heightzoom, false);
}
if(move){
bm1ChangedXplace = bm1ChangedXplace + changex;
bm1ChangedYplace = bm1ChangedYplace + changey;
}
if(crop){
if(changex>changey && changex>0)
{
if( cropimage1right - cropimage1left > changex )
cropimage1left = cropimage1left + changex ;
}
else if(-changex>changey && changex<0)
{
if( cropimage1right - cropimage1left > -changex )
cropimage1right = cropimage1right + changex ;
}
else if(changex<changey && changey>0)
{
if( cropimage1down - cropimage1up > changey )
cropimage1up = cropimage1up + changey ;
}
else if(changex<-changey && changey<0)
{
if( cropimage1down - cropimage1up > -changey )
cropimage1down = cropimage1down + changey ;
}
}
}
else if(editimage==2){
if(zoom){
bm2Widthzoom = bm2Widthzoom + changex;
bm2Heightzoom = bm2Heightzoom + changey;
bm2changed = Bitmap.createScaledBitmap(bm2, bm2Widthzoom, bm2Heightzoom, false);
}
if(move){
bm2ChangedXplace = bm2ChangedXplace + changex;
bm2ChangedYplace = bm2ChangedYplace + changey;
}
if(crop){
if(changex>changey && changex>0)
cropimage1left = cropimage1left + changex ;
else if(-changex>changey && changex<0)
cropimage1right = cropimage1right + changex ;
else if(changex<changey && changey>0)
cropimage1up = cropimage1up + changey ;
else if(changex<-changey && changey<0)
cropimage1down = cropimage1down + changey ;
}
}
new ProcessingBitmapAsync().execute("");
}
}
return true;
}
});
zoom
move
crop
حالا به فرض اینکه دکمه ی چهارمی به نام چرخش 90 درجه هم داشته باشیم کد مخصوص به چرخش چیه میشه و باید اضاف بشه؟
تشکرر