You Are Here:

Community: Developer Discussion Boards

#1 Old please help !Bug on S40 DirectGraphics.createImage ? - 2005-08-30, 07:52

Join Date: Feb 2005
Posts: 7
xqwww
Offline
Registered User
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Display;
import com.nokia.mid.ui.DirectUtils;

public class GraphicsCanvas extends Canvas implements Runnable
{
Image source;
Image copy;
Thread myThread;
Runtime runtime = Runtime.getRuntime();
boolean running=true;


public GraphicsCanvas()
{
try
{
source=Image.createImage("/monkey.png");

}

catch(Exception e)
{
System.err.println("error on loading monkey.png");
}

try
{
copy=DirectUtils.createImage(source.getWidth(),source.getHeight(),0xFF<<24|0xFF<<16|0xFF<<8|0xFF);
}

catch(Exception e)
{
System.out.println(e);
}

if(copy==null) System.out.println("copy is null");

Graphics temp=copy.getGraphics();

temp.drawImage(source,0,0,Graphics.LEFT);



}

public void start()
{

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

}

public void run()
{
while(running)
{
repaint();

try{
Thread.sleep(33);
}
catch(Exception e)
{
}



}

}

public void paint(Graphics g)
{
g.setColor(126,126,126);
g.fillRect(0,0,getWidth(),getHeight());
g.drawImage(source,getWidth()/2,getHeight()/2, Graphics.TOP|Graphics.HCENTER);
g.drawImage(copy,getWidth()/2,0, Graphics.TOP|Graphics.HCENTER);

}

}

The monkey.png image is transparent background, I just copy source monkey to copy monkey, since midp 1.0 does not support transparent image copy. then I use Nokia s40 API, but I dont know even I only copy=DirectUtils.createImage(source.getWidth(),source.getHeight(),0xFF<<24|0xFF<<16|0xFF<<8|0xFF);
but copy always is null. why? this code should not be problem. and try catch can not print any error. is there a bug?

Thanks for tell me the result.
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
S40 DP2.0 FIRE button bug? huiben Mobile Java Tools & SDKs 5 2006-06-27 11:56
Nokia手机主要参数列表 cqucyf Other Programming Discussion 关于其他编程技术的讨论 0 2005-05-04 17:34
Alert bug in S40 - 6230 MIDP Concept SDK Beta 0.2 - Emulator dg1leo Mobile Java Tools & SDKs 0 2004-04-19 14:22
Does s40 has the same bug on createImage as s60? dying Mobile Java General 1 2003-12-15 07:54
Does s40 has the same bug on createImage as s60? dying Mobile Java Media (Graphics & Sounds) 0 2003-12-14 07:49

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: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ