You Are Here:

Community: Developer Discussion Boards

#1 Old Scrolling png image on canvas - 2006-05-18, 09:06

Join Date: May 2006
Posts: 2
raj_ba03
Offline
Registered User
Hi,
My problem is i want to scroll a image on canvas class to do that iam using a loop but the problem is the image is coming down at a time instead it must move down slowly,and if iam using threads to control paint method ,repaint is not calling paint.Its urgent if some one has idea regarding it pls helpme.
Reply With Quote

#2 Old Re: Scrolling png image on canvas - 2006-05-18, 09:39

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
Please check this link

http://www.microjava.com/developer/f...ontent_id=1835

Hope this will help you.

Thanks
Soku
Reply With Quote

#3 Old Re: Scrolling png image on canvas - 2006-05-18, 15:47

Join Date: May 2006
Posts: 2
raj_ba03
Offline
Registered User
Hi,
But it scroll only background image i want to scroll image on constant backroung.
Reply With Quote

#4 Old Re: Scrolling png image on canvas - 2006-05-18, 20:06

Join Date: Mar 2006
Posts: 518
wang_shui
Offline
Super Contributor
Hi raj,

Are u referring to a ticker like image scrolling??

U have to draw the image over the background image. Just change the x & y coordinate as u like. It will be better if u use a thread or a timer task.


Wang
Reply With Quote

#5 Old Re: Scrolling png image on canvas - 2006-05-19, 07:17

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
If you want to move an image over a background that doesnt change,then just
alter the X & Y co-ordinates of the image and just dont alter the background positions.

Thanks
Soku
Reply With Quote

#6 Old Re: Scrolling png image on canvas - 2006-05-19, 08:26

Join Date: Nov 2003
Posts: 3,641
Location: Bangalore , India
Send a message via Yahoo to balagopalks
balagopalks's Avatar
balagopalks
Offline
Forum Nokia Expert
Hi raj_ba03! Welcome to Nokia Discussion Boards!! :)

Here is the code that will work fine for vertical scrolling of an image in the Res folder
If you want to make horizontal scroll,
change "g.drawImage(image,0,count,Graphics.TOP|Graphics.LEFT);" to g.drawImage(image,count,0,Graphics.TOP|Graphics.LEFT);

Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class TestScroll extends MIDlet
{
	TestCanvas tc = new TestCanvas();
	public void startApp()
	{
		Display.getDisplay(this).setCurrent(tc);
	}
	public void pauseApp(){}

	public void destroyApp(boolean bl){}
}

class TestCanvas extends Canvas implements Runnable
{
	Thread thread;
	Image image;
	int count;
	int imageSplitHeight=10;

	public TestCanvas()
	{
		try
		{
			image = Image.createImage("/testImg.png");
		}catch(Exception e){System.out.println("image not found");}
		thread = new Thread(this);
		thread.start();
	}

	public void run()
	{
		while(true)
		{
			try
			{
				count++;
				Thread.sleep(100);
				repaint();
			}catch(Exception e)
			{
			}
		}
	}
public void paint(Graphics g)
	{
		g.setColor(200,200,200);
		g.fillRect(0,0,getWidth(),getHeight());
		g.drawImage(image,0,count,Graphics.TOP|Graphics.LEFT);
	}
}
Hope this helps!

Regards
Gopal

Ps: Tested in WTK2.3 Default Emulator.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP: Mutable Image to Immutable Image? rj_cybersilver Mobile Java Media (Graphics & Sounds) 1 2005-03-26 10:58
PNG Image won't load maaberge Mobile Java General 1 2003-11-16 19:13
Major problem with delegation to Canvas bartekn Mobile Java Media (Graphics & Sounds) 8 2003-10-08 18:46
Image Menu with canvas efeba Mobile Java Media (Graphics & Sounds) 2 2003-06-26 12:33
Managing PNG image Size ramka001 Mobile Java General 2 2003-05-21 18:54

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d127641X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZgamesQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ