Help on Resizing of the image

Put your problem here if it does not fit any of the other categories.

Postby dkkundudolan » Fri Nov 28, 2008 11:48 am

Hi Danuubz,

I am attaching the code: please reply me .

Thanks again....
Attachments
ImageView1.zip
(74.64 KiB) Downloaded 98 times
dkkundudolan
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Mon Mar 03, 2008 12:50 pm

Top

Postby Danuubz » Fri Nov 28, 2008 12:55 pm

@Tanuja:

I defined two areas that get enlarged if you click on them. 1-40 and 41-80 are these areas. You can specify as many areas as you want in this part:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.  
  3.          public boolean onSingleTapUp(MotionEvent e)    
  4.  
  5.          {    
  6.  
  7.            if(!isOn)
  8.  
  9.            {
  10.  
  11.                 if(e.getX() < 40)
  12.  
  13.                 {
  14.  
  15.                     m.setScale(2, 1);
  16.  
  17.                     partialBitmap = Bitmap.createBitmap(fullBitmap,0,0,40,80,m,false);
  18.  
  19.                     imgView.setImageBitmap(partialBitmap);  
  20.  
  21.                     main.invalidate();
  22.  
  23.                 }
  24.  
  25.                 else if(e.getX() >= 40)
  26.  
  27.                 {
  28.  
  29.                      m.setScale(2, 1);
  30.  
  31.                      partialBitmap = Bitmap.createBitmap(fullBitmap,40,0,40,80,m,false);
  32.  
  33.                      imgView.setImageBitmap(partialBitmap);
  34.  
  35.                      main.invalidate();
  36.  
  37.                 }
  38.  
  39.                
  40.  
  41.                 isOn = true;
  42.  
  43.            }
  44.  
  45.            else
  46.  
  47.            {
  48.  
  49.                 imgView.setImageBitmap(fullBitmap);
  50.  
  51.                 isOn = false;
  52.  
  53.            }
  54.  
  55.          
  56.  
  57.            return true;
  58.  
  59.          }          
  60.  
  61.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


You have to define what you mean by 'part' (which area is concerned by the click). For the problem you described, it is better to implement view.View.OnTouchListener and override its onTouch(View v, MotionEvent me) method.
There you call me.getAction() to find out if it is ACTION_DOWN or ACTION_CANCEL:

- If it is ACTION_DOWN, you receive the coordinates from the MotionEvent to calculate the area that got to be enlarged.

- If it is ACTION_CANCEL, you receive the coordinates from the MotionEvent to calculate the area for the enlarged picture. After this you do the necessary scaling of the 'part', create a new picture with the new size.

Then, you override onDraw(Canvas c) of the View that holds the Images and draw first the entire background and then the enlarged picture on top of it like:

c.drawBitmap(background, ...);
c.drawBitmap(largePicture, ...)

This might take some hours of work.
Last edited by Danuubz on Fri Nov 28, 2008 2:42 pm, edited 1 time in total.
User avatar
Danuubz
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Wed Dec 19, 2007 10:44 pm
Location: Germany

Postby Danuubz » Fri Nov 28, 2008 1:08 pm

@dkkundudolan:

I just made a general example how it works. You can easily copy the code of the checkbox into the activity class that is desired and replace or remove one of the buttons.
Selection of the checkbox works with:

checkBox.performClick();

You can set some flags that show which one is actually selected or not selected.
User avatar
Danuubz
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Wed Dec 19, 2007 10:44 pm
Location: Germany

Postby Tanuja » Fri Nov 28, 2008 2:19 pm

Thanx for the help danuubz.........
i wil try it out.... and work on it.......

Thanks and regards
Tanuja
Tanuja
Junior Developer
Junior Developer
 
Posts: 15
Joined: Thu Oct 30, 2008 7:13 am

Postby dkkundudolan » Tue Dec 02, 2008 10:01 am

Hi Danuubz,

Thanks for your help. I did that by using Bundle.

Thanks a lot................
dkkundudolan
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Mon Mar 03, 2008 12:50 pm

Postby dkkundudolan » Wed Dec 03, 2008 6:05 am

Hi Danuubz,

I have one more question. That is:

In that application i have total 14 screens. so the image button is in second screen. Now problem is , when i move from second screen to other screens, the changing color is not stayable. means, as the color change from red to green, the green color will be persistable upto the next time running of the project.

If i use SharedPreferences in this case database is needed. But now i dont want to execute program with database.

so please can you tell me, without database, how can i do that?

Thanks.
dkkundudolan
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Mon Mar 03, 2008 12:50 pm

Top

Postby Tanuja » Fri Dec 05, 2008 5:46 am

Hi danuubz..........
Thanks for the help from u............ now...
i need the picture to accupy the new frame........ wer the mouse is clicked.... that is .... is 80x80 frame is set first to the image...... later the mouse is clicked on the image dragged to a particular point say.......... noe the frame may be 120x120.......... so the new image should occupy the frame after the mouse is released
.......... please help me on this..........

Thanks and reagards
Tanuja
Tanuja
Junior Developer
Junior Developer
 
Posts: 15
Joined: Thu Oct 30, 2008 7:13 am

Top
Previous

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 27 guests