android - How to resize image by using seekbar? -
I want to resize the image using the seekbar. Seekbar is working, but it is not giving any good results, with the following code, the image has been resized, but when you first change the progress of the explorer. Please help
listener seekbar
seekBar.setOnSeekBarChangeListener (New OnSeekBarChangeListener () {@Override public void onStopTrackingTouch (seekbar arg0) {// TODO Auto-generated method stub} @ public override void onStartTrackingTouch (seekbar arg0) {// TODO auto-generated method stub} @Override public void onProgressChanged (seekbar seekbar, ProgresValue integer, boolean fromUser) {// TODO auto-generated method stub progresValue = progress; resizeImage (image, Progas Vel);}}); Function Image resizing
public void resizeImage (Bitmap Bitmap, int stride) {bitmap bitmapSource = bitmap; Float bHight = bitmapSource.getHeight (); Float bWidth = bitmapSource.getWidth (); Float Factor H = Progress / (Float) BHEight; Float factor w = progress / (float) bewd; Float Factor to Use = (Factor> Factor)? FactorW: Factor H; Bitmap bm = Bitmap.createScaledBitmap (bitmapSource, (int) (bWidth * factorToUse), (int) (bHeight * factorToUse), false); QImage.setImageBitmap (BM); }
Last seekbar Sk1 = (seekbar) findViewById (R.id. SeekBar1); Sk1.setMax (500); Sk1.setOnSeekBarChangeListener (New OnSeekBarChangeListener) (public void Prtopatrakingtuc (SeekBar seekBar) {// TODO Auto-generated method stub} public void Starttrakingtuc (SeekBar seekBar) {// TODO Auto-generated method stub} public void (SeekBar seekBar progress progress, Boolean fromUser int) {// TODO auto-generated method stub img.setScaleType (ImageView.ScaleType.CENTER_INSIDE); RelativeLayout.LayoutParams parameter = new RelativeLayout.LayoutParams (progress, progress); img.setLayoutParams (parameters); img Minimum speed (progress); img.setMinimumHeight Rgti);}});
Comments
Post a Comment