android - ImageView bigger than screen resolution is re scaled wrong -


i trying build drawing tool, drawing tool allow users select images , place them in sketch afterwards can manipulated within. images belong project have been set same scale (1:100): steps program follows create work area following, first dialog pops , ask user enter work area in x axis:

//prompts user area size string areax = txtlargearea.gettext().tostring();  //parse int  int area = integer.parseint(areax); if (area > 14 && area < 101) {     //set atributes myconvert class     // 15 fixed size y axis    myconvert.setareaselected(new pointf(area, 15));                                                  myconvert.setscale(myconvert.setsizeworkare()); 

scale set whatever function setsizeworkare returns:

public static float setsizeworkare() {    pointf offsetmtrs = pixstomts(offset);//65x100 default value set offset point plot    scale = 1;    pointf screeninmts = pixstomts(screenresolution);    return ((areaselected.x + offsetmtrs.x) / screeninmts.x); 

this method converts pixels meters:

public static pointf pixstomts(pointf coordenate) {   return new pointf((float) ((((coordenate.x * 2.54) / dpi) * scale) / 100),  (float) ((((coordenate.y * 2.54) / dpi) * scale) / 100)); } 

then screen resolution:

// class allows obtain info device displaymetrics metrics = getresources().getdisplaymetrics();                                 //set atributes myconvert class myconvert.setdpi(metrics.densitydpi);   myconvert.setscreenresolution(new  pointf(metrics.widthpixels,metrics.heightpixels)); 

now set screen working area, proceed place images:

imageview newimage = new imageview(getcontext()); //set properties imageview                                                    newimage.setscaletype(imageview.scaletype.center);                                           newimage.setadjustviewbounds(true); newimage.setdrawingcacheenabled(true); newimage.setontouchlistener(this);  

this image gets re-scaled

imgviewselected.getlayoutparams().width = (int)  myconvert.scalevalue(newimage.getdrawable().getintrinsicwidth());  imgviewselected.getlayoutparams().height = (int)  myconvert.scalevalue(newimage.getdrawable().getintrinsicheight()); 

and scalevalue method:

public static float scalevalue(float value){ float resscale= getscale()/122;  float salida=    value/resscale;      return salida;  } 

this working until select 1 image has bigger size screen resolution, if android re scaling automaticly , doing re scale instructions.

some images give idea of happening:

in image, appears working should, when working area set 40 or more (mts) looks better, greater value better approach

in case area set 30 (mts) , can see how re scaling image smaller, remember happens images larger screen res

is there image handler expert out there? hints on matter highly appreciated.

use frame layout wraps image inserted.

example:

<framelayout             android:id="@+id/yourid"             android:layout_width="match_parent"             android:layout_height="match_parent">        <imageview             android:layout_width="match_parent"             android:layout_height="match_parent">       </imageview>   </framelayout> 

framelayout or scroll view don´t limitations screen size, image won´t re-scaled android.


Comments