×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    52

    Question image slide...................

    hello Every one..............................

    i have an application in which there is one button which will show image.....
    now when i click on button images show perfectly ok.....(image is in phone memory.)

    now i want to slide this image from left to right ...

    how to go?

    Related Thread or demo Example will b more useful

    Thanks in advance.....................

  2. #2
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: image slide...................

    Hi what your requirement is can be implemented using this
    what U have to do is that display your image in parts width wise on the screen until whole width of image is displayed and this will be done in thread the speed of transition depend upon the part you want to display the more part you display the more speed and vice versa
    eg width be 100
    so in paint one can write like this

    PHP Code:
    for(int x 10 0x--)
    graphics.drawImage(img,imgWidth x*10imgHegight1); 
    Regards,
    Saurabh

  3. #3
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    52

    Question Re: image slide...................

    Hi ingsaurabh,

    Thanks 4 reply...........

    but bad news............


    it thr' exception.............


    java.lang.IllegalArgumentException:

    if posible plz provide suitable example(any if u have)

    thanks once again...............

  4. #4
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: image slide...................

    post your code here I will try to make it work
    Regards,
    Saurabh

  5. #5
    Regular Contributor
    Join Date
    Feb 2010
    Posts
    52

    Question Re: image slide...................

    Here is d Code..............................


    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;

    public class UserImage extends MIDlet
    {
    private Display display;

    public UserImage()
    {
    display = Display.getDisplay(this);
    }

    protected void destroyApp(boolean arg0) throws MIDletStateChangeException
    {

    }

    protected void pauseApp()
    {

    }

    protected void startApp() throws MIDletStateChangeException
    {
    final MyCanvas can = new MyCanvas();

    display.setCurrent(can);
    }


    public class MyCanvas extends Canvas implements Runnable
    {
    Image img=null;
    public MyCanvas()
    {
    try
    {
    img=Image.createImage("/image1.png");
    }
    catch(Exception e)
    {
    System.out.println("Image Error " + e.getMessage());
    }

    Thread th=new Thread(this);
    th.start();

    }

    public void paint(Graphics g)
    {
    // g.drawImage(img,0,0,g.TOP|g.LEFT); // This Shows Image on screen............
    int imgWidth = img.getWidth();
    int imgHeight = img.getHeight();
    for(int x = 10 ; x > 0; x--)
    {
    int z = imgWidth - x*10;
    g.drawImage(img,z,imgHeight, 1);
    }
    }

    public void run()
    {
    while(true)
    {
    try
    {
    Thread.sleep(500);
    }
    catch(Exception e)
    {
    System.out.println("Error " + e.getMessage());
    }
    }
    }
    }
    }


    ................................

    Image is in the res folder.........

  6. #6
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: image slide...................

    use following code

    PHP Code:
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;

    public class 
    UserImage extends MIDlet
    {
    private 
    Display display;

    public 
    UserImage()
    {
    display Display.getDisplay(this);
    }

    protected 
    void destroyApp(boolean arg0throws MIDletStateChangeException
    {

    }

    protected 
    void pauseApp()
    {

    }

    protected 
    void startApp() throws MIDletStateChangeException
    {
    final 
    MyCanvas can = new MyCanvas();

    display.setCurrent(can);
    }


    public class 
    MyCanvas extends Canvas implements RunnableCommandListener
    {
        
    int x 0;
        
    Command slide;
        
    boolean slideEnabled false;
    Image img=null;
    int wid hgt;
    public 
    MyCanvas()
    {
    try
    {
    img=Image.createImage("/MCA.PNG");
    }
    catch(
    Exception e)
    {
    System.out.println("Image Error " e.getMessage());
    }
    wid getWidth();
    hgt getHeight();
    slide = new Command("Slide"Command.OK1);
    addCommand(slide);
    setCommandListener(this);
    Thread th=new Thread(this);
    th.start();

    }

    public 
    void paint(Graphics g)
    {
        
        
    g.setColor(0x000000);
        
    g.fillRect(00widhgt);
        if(
    slideEnabled)
        {

            
    int imgWidth img.getWidth();
            
    int imgHeight img.getHeight();
            
                
    g.setColor(0x000000);
                
    g.fillRect(00widhgt);
                 
    //int z = imgWidth - x*10;
                
    g.drawImage(img,,0g.TOP|g.LEFT);
                        try {
                            
    Thread.sleep(20);
                        } catch (
    InterruptedException ex) {
                            
    ex.printStackTrace();
                        }
                
    x++;
                
            
        }
        else
        
    g.drawImage(img,0,0,g.TOP|g.LEFT); // This Shows Image on screen............

    }

    public 
    void run()
    {
    while(
    true)
    {

    repaint();
    }
    }

            public 
    void commandAction(Command cDisplayable d)
            {
             if( 
    == slide)
             {
                    
    slideEnabled true;
             }
            }
        }

    Regards,
    Saurabh

Similar Threads

  1. Image - byte[] - String (re)conversion
    By lampz in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2008-02-19, 11:47
  2. AknIconUtils is caching the image
    By Tatanka.nbr1 in forum Symbian
    Replies: 12
    Last Post: 2007-01-05, 19:08
  3. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31
  4. image failed to load
    By killarkai in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2003-07-25, 13:07
  5. image transparency gets lost with DirectUtils.createImage
    By rawpsycho in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2003-05-28, 08:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×